public void testParse_GitBinaryLiteral() { GitSharp.Core.Patch.Patch p = ParseTestPatchFile(PatchsDir + "testParse_GitBinaryLiteral.patch"); int[] binsizes = { 359, 393, 372, 404 }; Assert.AreEqual(5, p.getFiles().Count); Assert.IsTrue(p.getErrors().Count == 0); for (int i = 0; i < 4; i++) { FileHeader fh = p.getFiles()[i]; Assert.AreEqual(FileHeader.ChangeTypeEnum.ADD, fh.getChangeType()); Assert.IsNotNull(fh.getOldId()); Assert.IsNotNull(fh.getNewId()); Assert.AreEqual(ObjectId.ZeroId.Name, fh.getOldId().name()); Assert.AreEqual(FileMode.RegularFile, fh.NewMode); Assert.IsTrue(fh.NewName.StartsWith( "org.spearce.egit.ui/icons/toolbar/")); Assert.AreEqual(FileHeader.PatchTypeEnum.GIT_BINARY, fh.getPatchType()); Assert.IsTrue(fh.Hunks.Count == 0); Assert.IsTrue(fh.hasMetaDataChanges()); BinaryHunk fwd = fh.getForwardBinaryHunk(); BinaryHunk rev = fh.getReverseBinaryHunk(); Assert.IsNotNull(fwd); Assert.IsNotNull(rev); Assert.AreEqual(binsizes[i], fwd.getSize()); Assert.AreEqual(0, rev.getSize()); Assert.AreEqual(fh, fwd.getFileHeader()); Assert.AreEqual(fh, rev.getFileHeader()); Assert.AreEqual(BinaryHunk.Type.LITERAL_DEFLATED, fwd.getType()); Assert.AreEqual(BinaryHunk.Type.LITERAL_DEFLATED, rev.getType()); } { FileHeader fh = p.getFiles()[4]; Assert.AreEqual("org.spearce.egit.ui/plugin.xml", fh.NewName); Assert.AreEqual(FileHeader.ChangeTypeEnum.MODIFY, fh.getChangeType()); Assert.AreEqual(FileHeader.PatchTypeEnum.UNIFIED, fh.getPatchType()); Assert.IsFalse(fh.hasMetaDataChanges()); Assert.AreEqual("ee8a5a0", fh.getNewId().name()); Assert.IsNull(fh.getForwardBinaryHunk()); Assert.IsNull(fh.getReverseBinaryHunk()); Assert.AreEqual(1, fh.Hunks.Count); Assert.AreEqual(272, fh.Hunks[0].OldImage.StartLine); } }
public void testParse_GitBinaryDelta() { GitSharp.Core.Patch.Patch p = ParseTestPatchFile(PatchsDir + "testParse_GitBinaryDelta.patch"); Assert.AreEqual(1, p.getFiles().Count); Assert.IsTrue(p.getErrors().Count == 0); FileHeader fh = p.getFiles()[0]; Assert.IsTrue(fh.NewName.StartsWith("zero.bin")); Assert.AreEqual(FileHeader.ChangeTypeEnum.MODIFY, fh.getChangeType()); Assert.AreEqual(FileHeader.PatchTypeEnum.GIT_BINARY, fh.getPatchType()); Assert.AreEqual(FileMode.RegularFile, fh.NewMode); Assert.IsNotNull(fh.getOldId()); Assert.IsNotNull(fh.getNewId()); Assert.AreEqual("08e7df176454f3ee5eeda13efa0adaa54828dfd8", fh.getOldId() .name()); Assert.AreEqual("d70d8710b6d32ff844af0ee7c247e4b4b051867f", fh.getNewId() .name()); Assert.IsTrue(fh.Hunks.Count == 0); Assert.IsFalse(fh.hasMetaDataChanges()); BinaryHunk fwd = fh.getForwardBinaryHunk(); BinaryHunk rev = fh.getReverseBinaryHunk(); Assert.IsNotNull(fwd); Assert.IsNotNull(rev); Assert.AreEqual(12, fwd.getSize()); Assert.AreEqual(11, rev.getSize()); Assert.AreEqual(fh, fwd.getFileHeader()); Assert.AreEqual(fh, rev.getFileHeader()); Assert.AreEqual(BinaryHunk.Type.DELTA_DEFLATED, fwd.getType()); Assert.AreEqual(BinaryHunk.Type.DELTA_DEFLATED, rev.getType()); Assert.AreEqual(496, fh.EndOffset); }