Ejemplo n.º 1
0
        public void testEncodeInt64()
        {
            var @out = new byte[16];

            PrepareOutput(@out);
            NB.encodeInt64(@out, 0, 0L);
            AssertOutput(b(0, 0, 0, 0, 0, 0, 0, 0), @out, 0);

            PrepareOutput(@out);
            NB.encodeInt64(@out, 3, 0L);
            AssertOutput(b(0, 0, 0, 0, 0, 0, 0, 0), @out, 3);

            PrepareOutput(@out);
            NB.encodeInt64(@out, 0, 3L);
            AssertOutput(b(0, 0, 0, 0, 0, 0, 0, 3), @out, 0);

            PrepareOutput(@out);
            NB.encodeInt64(@out, 3, 3L);
            AssertOutput(b(0, 0, 0, 0, 0, 0, 0, 3), @out, 3);

            PrepareOutput(@out);
            NB.encodeInt64(@out, 0, 0xdeacL);
            AssertOutput(b(0, 0, 0, 0, 0, 0, 0xde, 0xac), @out, 0);

            PrepareOutput(@out);
            NB.encodeInt64(@out, 3, 0xdeacL);
            AssertOutput(b(0, 0, 0, 0, 0, 0, 0xde, 0xac), @out, 3);

            PrepareOutput(@out);
            NB.encodeInt64(@out, 0, 0xdeac9853L);
            AssertOutput(b(0, 0, 0, 0, 0xde, 0xac, 0x98, 0x53), @out, 0);

            PrepareOutput(@out);
            NB.encodeInt64(@out, 3, 0xdeac9853L);
            AssertOutput(b(0, 0, 0, 0, 0xde, 0xac, 0x98, 0x53), @out, 3);

            PrepareOutput(@out);
            unchecked
            {
                NB.encodeInt64(@out, 0, (long)0xac431242deac9853L);
            }
            AssertOutput(b(0xac, 0x43, 0x12, 0x42, 0xde, 0xac, 0x98, 0x53), @out, 0);

            PrepareOutput(@out);
            unchecked
            {
                NB.encodeInt64(@out, 3, (long)0xac431242deac9853L);
            }
            AssertOutput(b(0xac, 0x43, 0x12, 0x42, 0xde, 0xac, 0x98, 0x53), @out, 3);

            PrepareOutput(@out);
            NB.encodeInt64(@out, 3, -1L);
            AssertOutput(b(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff), @out, 3);
        }
Ejemplo n.º 2
0
 private void WriteOffset64()
 {
     foreach (PackedObjectInfo oe in entries)
     {
         long o = oe.Offset;
         if (o > int.MaxValue)
         {
             NB.encodeInt64(tmp, 0, o);
             _stream.BaseStream.Write(tmp, 0, 8);
         }
     }
 }