예제 #1
0
파일: NBTests.cs 프로젝트: kkl713/GitSharp
        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);
        }
 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);
         }
     }
 }