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 writeMin(int n, BinaryPackerWriter w)
 {
     w.Write(makeArray <byte>(n, byte.MinValue));
     w.Write(makeArray <Int16>(n, Int16.MinValue));
     w.Write(makeArray <Int32>(n, Int32.MinValue));
     w.Write(makeArray <Int64>(n, Int64.MinValue));
     w.Write(makeArray <UInt16>(n, UInt16.MinValue));
     w.Write(makeArray <UInt32>(n, UInt32.MinValue));
     w.Write(makeArray <UInt64>(n, UInt64.MinValue));
     w.Write(makeArray <Single>(n, Single.MinValue));
     w.Write(makeArray <Double>(n, Double.MinValue));
     w.Write(makeArray <Boolean>(n, false));
     w.Write(makeArray <String>(n, ""));
 }
Example #3
0
 void writeMax(int n, BinaryPackerWriter w)
 {
     w.Write(makeArray <byte>(n, byte.MaxValue));
     w.Write(makeArray <Int16>(n, Int16.MaxValue));
     w.Write(makeArray <Int32>(n, Int32.MaxValue));
     w.Write(makeArray <Int64>(n, Int64.MaxValue));
     w.Write(makeArray <UInt16>(n, UInt16.MaxValue));
     w.Write(makeArray <UInt32>(n, UInt32.MaxValue));
     w.Write(makeArray <UInt64>(n, UInt64.MaxValue));
     w.Write(makeArray <Single>(n, Single.MaxValue));
     w.Write(makeArray <Double>(n, Double.MaxValue));
     w.Write(makeArray <Boolean>(n, true));
     w.Write(makeArray <String>(n, maxString));
 }
Example #4
0
 void writeNull(BinaryPackerWriter w)
 {
     w.Write((string)null);
     w.Write((byte[])null);
     w.Write((Int16[])null);
     w.Write((Int32[])null);
     w.Write((Int64[])null);
     w.Write((UInt16[])null);
     w.Write((UInt32[])null);
     w.Write((UInt64[])null);
     w.Write((Single[])null);
     w.Write((Double[])null);
     w.Write((Boolean[])null);
     w.Write((String[])null);
 }
Example #5
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);
            }
        }