Ejemplo n.º 1
0
 public virtual void TestCompareEntriesOffsetsWithFindOffsets()
 {
     foreach (PackIndex.MutableEntry me in smallIdx)
     {
         NUnit.Framework.Assert.AreEqual(smallIdx.FindOffset(me.ToObjectId()), me.GetOffset
                                             ());
     }
     foreach (PackIndex.MutableEntry me_1 in denseIdx)
     {
         NUnit.Framework.Assert.AreEqual(denseIdx.FindOffset(me_1.ToObjectId()), me_1.GetOffset
                                             ());
     }
 }
        public virtual void TestFindNextOffset()
        {
            long offset = FindFirstOffset();

            NUnit.Framework.Assert.IsTrue(offset > 0);
            for (int i = 0; i < idx.GetObjectCount(); i++)
            {
                long newOffset = reverseIdx.FindNextOffset(offset, long.MaxValue);
                NUnit.Framework.Assert.IsTrue(newOffset > offset);
                if (i == idx.GetObjectCount() - 1)
                {
                    NUnit.Framework.Assert.AreEqual(newOffset, long.MaxValue);
                }
                else
                {
                    NUnit.Framework.Assert.AreEqual(newOffset, idx.FindOffset(reverseIdx.FindObject(newOffset
                                                                                                    )));
                }
                offset = newOffset;
            }
        }
Ejemplo n.º 3
0
        public virtual void TestWriteIndex()
        {
            config.SetIndexVersion(2);
            WriteVerifyPack4(false);
            FilePath packFile  = pack.GetPackFile();
            string   name      = packFile.GetName();
            string   @base     = Sharpen.Runtime.Substring(name, 0, name.LastIndexOf('.'));
            FilePath indexFile = new FilePath(packFile.GetParentFile(), @base + ".idx");
            // Validate that IndexPack came up with the right CRC32 value.
            PackIndex idx1 = PackIndex.Open(indexFile);

            NUnit.Framework.Assert.IsTrue(idx1 is PackIndexV2);
            NUnit.Framework.Assert.AreEqual(unchecked ((long)(0x4743F1E4L)), idx1.FindCRC32(ObjectId
                                                                                            .FromString("82c6b885ff600be425b4ea96dee75dca255b69e7")));
            // Validate that an index written by PackWriter is the same.
            FilePath         idx2File = new FilePath(indexFile.GetAbsolutePath() + ".2");
            FileOutputStream @is      = new FileOutputStream(idx2File);

            try
            {
                writer.WriteIndex(@is);
            }
            finally
            {
                @is.Close();
            }
            PackIndex idx2 = PackIndex.Open(idx2File);

            NUnit.Framework.Assert.IsTrue(idx2 is PackIndexV2);
            NUnit.Framework.Assert.AreEqual(idx1.GetObjectCount(), idx2.GetObjectCount());
            NUnit.Framework.Assert.AreEqual(idx1.GetOffset64Count(), idx2.GetOffset64Count());
            for (int i = 0; i < idx1.GetObjectCount(); i++)
            {
                ObjectId id = idx1.GetObjectId(i);
                NUnit.Framework.Assert.AreEqual(id, idx2.GetObjectId(i));
                NUnit.Framework.Assert.AreEqual(idx1.FindOffset(id), idx2.FindOffset(id));
                NUnit.Framework.Assert.AreEqual(idx1.FindCRC32(id), idx2.FindCRC32(id));
            }
        }