예제 #1
0
        public void testWriteIndex()
        {
            _writer.setIndexVersion(2);
            WriteVerifyPack4(false);

            // Validate that IndexPack came up with the right CRC32 value.
            PackIndex idx1 = PackIndex.Open(_indexFile);

            Assert.IsTrue(idx1 is PackIndexV2);
            Assert.AreEqual(0x4743F1E4L, idx1.FindCRC32(ObjectId.FromString("82c6b885ff600be425b4ea96dee75dca255b69e7")));

            // Validate that an index written by PackWriter is the same.
            FileInfo idx2File = new FileInfo(_indexFile.FullName + ".2");

            using (var @is = new FileStream(idx2File.FullName, System.IO.FileMode.CreateNew))
            {
                _writer.writeIndex(@is);
            }

            PackIndex idx2 = PackIndex.Open(idx2File);

#pragma warning disable 0612
            Assert.IsInstanceOfType(typeof(PackIndexV2), idx2); // [henon] IsInstanceOfType is obsolete
#pragma warning restore 0612
            Assert.AreEqual(idx1.ObjectCount, idx2.ObjectCount);
            Assert.AreEqual(idx1.Offset64Count, idx2.Offset64Count);

            for (int i = 0; i < idx1.ObjectCount; i++)
            {
                ObjectId id = idx1.GetObjectId(i);
                Assert.AreEqual(id, idx2.GetObjectId(i));
                Assert.AreEqual(idx1.FindOffset(id), idx2.FindOffset(id));
                Assert.AreEqual(idx1.FindCRC32(id), idx2.FindCRC32(id));
            }
        }
예제 #2
0
        public void testCompareEntriesOffsetsWithFindOffsets()
        {
            foreach (var me in smallIdx)
            {
                Assert.AreEqual(smallIdx.FindOffset(me.ToObjectId()), me.Offset);
            }

            foreach (var me in _denseIdx)
            {
                Assert.AreEqual(_denseIdx.FindOffset(me.ToObjectId()), me.Offset);
            }
        }
예제 #3
0
        public void testFindNextOffset()
        {
            long offset = FindFirstOffset();

            Assert.IsTrue(offset > 0);

            for (int i = 0; i < _idx.ObjectCount; i++)
            {
                long newOffset = _reverseIdx.FindNextOffset(offset, long.MaxValue);
                Assert.IsTrue(newOffset > offset);

                if (i == _idx.ObjectCount - 1)
                {
                    Assert.AreEqual(newOffset, long.MaxValue);
                }
                else
                {
                    Assert.AreEqual(newOffset, _idx.FindOffset(_reverseIdx.FindObject(newOffset)));
                }

                offset = newOffset;
            }
        }