Example #1
0
 public void TestMax()
 {
     for (int i = 0; i < 3; ++i)
     {
         var m = new MemoryStream();
         var w = new BinaryPackerWriter(m);
         var r = new BinaryPackerReader(m);
         writeMax(i, w);
         m.Seek(0, SeekOrigin.Begin);
         readMax(i, r);
         Assert.AreEqual(m.Length, m.Position);
     }
 }
Example #2
0
 void readMin(int n, BinaryPackerReader r)
 {
     Assert.AreEqual(makeArray <byte>(n, byte.MinValue), r.ReadByteArray());
     Assert.AreEqual(makeArray <Int16>(n, Int16.MinValue), r.ReadInt16Array());
     Assert.AreEqual(makeArray <Int32>(n, Int32.MinValue), r.ReadInt32Array());
     Assert.AreEqual(makeArray <Int64>(n, Int64.MinValue), r.ReadInt64Array());
     Assert.AreEqual(makeArray <UInt16>(n, UInt16.MinValue), r.ReadInt16Array());
     Assert.AreEqual(makeArray <UInt32>(n, UInt32.MinValue), r.ReadInt32Array());
     Assert.AreEqual(makeArray <UInt64>(n, UInt64.MinValue), r.ReadInt64Array());
     Assert.AreEqual(makeArray <Single>(n, Single.MinValue), r.ReadSingleArray());
     Assert.AreEqual(makeArray <Double>(n, Double.MinValue), r.ReadDoubleArray());
     Assert.AreEqual(makeArray <Boolean>(n, false), r.ReadBooleanArray());
     Assert.AreEqual(makeArray <String>(n, ""), r.ReadStringArray());
 }
Example #3
0
 void readNull(BinaryPackerReader r)
 {
     Assert.AreEqual(0, r.ReadString().Length);
     Assert.AreEqual(0, r.ReadByteArray().Length);
     Assert.AreEqual(0, r.ReadInt16Array().Length);
     Assert.AreEqual(0, r.ReadInt32Array().Length);
     Assert.AreEqual(0, r.ReadInt64Array().Length);
     Assert.AreEqual(0, r.ReadInt16Array().Length);
     Assert.AreEqual(0, r.ReadInt32Array().Length);
     Assert.AreEqual(0, r.ReadInt64Array().Length);
     Assert.AreEqual(0, r.ReadSingleArray().Length);
     Assert.AreEqual(0, r.ReadDoubleArray().Length);
     Assert.AreEqual(0, r.ReadBooleanArray().Length);
     Assert.AreEqual(0, r.ReadStringArray().Length);
 }
Example #4
0
        public void TestLongStream()
        {
            var  m = new MemoryStream();
            var  w = new BinaryPackerWriter(m);
            var  r = new BinaryPackerReader(m);
            long pos;

            for (int i = 0; i < 3; ++i)
            {
                pos = m.Position;
                writeMin(i, w);
                m.Seek(pos, SeekOrigin.Begin);
                readMin(i, r);

                pos = m.Position;
                writeMax(i, w);
                m.Seek(pos, SeekOrigin.Begin);
                readMax(i, r);

                Assert.AreEqual(m.Length, m.Position);
            }
        }