public virtual void TestParseModeChange() { FileHeader fh = Data("diff --git a/a b b/a b\n" + "old mode 100644\n" + "new mode 100755\n" ); AssertParse(fh); NUnit.Framework.Assert.AreEqual("a b", fh.GetOldPath()); NUnit.Framework.Assert.AreEqual("a b", fh.GetNewPath()); NUnit.Framework.Assert.AreEqual(DiffEntry.ChangeType.MODIFY, fh.GetChangeType()); NUnit.Framework.Assert.AreEqual(FileHeader.PatchType.UNIFIED, fh.GetPatchType()); NUnit.Framework.Assert.IsTrue(fh.HasMetaDataChanges()); NUnit.Framework.Assert.IsNull(fh.GetOldId()); NUnit.Framework.Assert.IsNull(fh.GetNewId()); NUnit.Framework.Assert.AreSame(FileMode.REGULAR_FILE, fh.GetOldMode()); NUnit.Framework.Assert.AreSame(FileMode.EXECUTABLE_FILE, fh.GetNewMode()); NUnit.Framework.Assert.AreEqual(0, fh.GetScore()); }
public virtual void TestParseUnicodeName_DeleteFile() { FileHeader fh = Data("diff --git \"a/\\303\\205ngstr\\303\\266m\" \"b/\\303\\205ngstr\\303\\266m\"\n" + "deleted file mode 100644\n" + "index 7898192..0000000\n" + "--- \"a/\\303\\205ngstr\\303\\266m\"\n" + "+++ /dev/null\n" + "@@ -1 +0,0 @@\n" + "-a\n"); AssertParse(fh); NUnit.Framework.Assert.AreEqual("\u00c5ngstr\u00f6m", fh.GetOldPath()); NUnit.Framework.Assert.AreEqual("/dev/null", fh.GetNewPath()); NUnit.Framework.Assert.AreSame(DiffEntry.DEV_NULL, fh.GetNewPath()); NUnit.Framework.Assert.AreEqual(DiffEntry.ChangeType.DELETE, fh.GetChangeType()); NUnit.Framework.Assert.AreEqual(FileHeader.PatchType.UNIFIED, fh.GetPatchType()); NUnit.Framework.Assert.IsTrue(fh.HasMetaDataChanges()); NUnit.Framework.Assert.AreSame(FileMode.REGULAR_FILE, fh.GetOldMode()); NUnit.Framework.Assert.AreSame(FileMode.MISSING, fh.GetNewMode()); NUnit.Framework.Assert.AreEqual("7898192", fh.GetOldId().Name); NUnit.Framework.Assert.AreEqual("0000000", fh.GetNewId().Name); NUnit.Framework.Assert.AreEqual(0, fh.GetScore()); }
public virtual void TestParseCopy100() { FileHeader fh = Data("diff --git a/a b/ c/\\303\\205ngstr\\303\\266m\n" + "similarity index 100%\n" + "copy from a\n" + "copy to \" c/\\303\\205ngstr\\303\\266m\"\n"); int ptr = fh.ParseGitFileName(0, fh.buf.Length); NUnit.Framework.Assert.IsTrue(ptr > 0); NUnit.Framework.Assert.IsNull(fh.GetOldPath()); // can't parse names on a copy NUnit.Framework.Assert.IsNull(fh.GetNewPath()); ptr = fh.ParseGitHeaders(ptr, fh.buf.Length); NUnit.Framework.Assert.IsTrue(ptr > 0); NUnit.Framework.Assert.AreEqual("a", fh.GetOldPath()); NUnit.Framework.Assert.AreEqual(" c/\u00c5ngstr\u00f6m", fh.GetNewPath()); NUnit.Framework.Assert.AreEqual(DiffEntry.ChangeType.COPY, fh.GetChangeType()); NUnit.Framework.Assert.AreEqual(FileHeader.PatchType.UNIFIED, fh.GetPatchType()); NUnit.Framework.Assert.IsTrue(fh.HasMetaDataChanges()); NUnit.Framework.Assert.IsNull(fh.GetOldId()); NUnit.Framework.Assert.IsNull(fh.GetNewId()); NUnit.Framework.Assert.IsNull(fh.GetOldMode()); NUnit.Framework.Assert.IsNull(fh.GetNewMode()); NUnit.Framework.Assert.AreEqual(100, fh.GetScore()); }