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)); } }
/// <exception cref="System.Exception"></exception> public override void SetUp() { base.SetUp(); smallIdx = PackIndex.Open(GetFileForPack34be9032()); denseIdx = PackIndex.Open(GetFileForPackdf2982f28()); }