コード例 #1
0
        public void TestBufferedWrite()
        {
            using (var unmanagedArray = new UnmanagedArray(16))
            {
                var stream = new DoubleOutStream(unmanagedArray.PPData, unmanagedArray.Resize);

                var buffer = new double[16];
                buffer[1] = 3.0;
                buffer[2] = 4.0;

                using (var writer = stream.GetWriter())
                {
                    for (int stepSize = 1; stepSize < unmanagedArray.Length; stepSize++)
                    {
                        writer.Reset();

                        int n = writer.Write(buffer, 1, 2, stepSize);
                        unmanagedArray.CheckBoundaries();

                        writer.Reset();

                        var doubleArray = unmanagedArray.ToArray();
                        for (int i = 0; i < n; i++)
                        {
                            Assert.AreEqual(buffer[i + 1], doubleArray[i], "Step size was: {0}", stepSize);
                        }
                    }
                }
            }
        }
コード例 #2
0
        public void TestWrite()
        {
            using (var unmanagedArray = new UnmanagedArray(16))
            {
                var stream = new DoubleOutStream(unmanagedArray.PPData, unmanagedArray.Resize);

                var buffer = new double[16];
                using (var writer = stream.GetWriter())
                {
                    for (int stepSize = 1; stepSize < unmanagedArray.Length; stepSize++)
                    {
                        while (!writer.Eos)
                        {
                            writer.Write((double)stepSize, stepSize);
                        }
                        unmanagedArray.CheckBoundaries();
                        writer.Reset();
                    }
                }
            }
        }