private static void AssertParse(FileHeader fh) { int ptr = fh.ParseGitFileName(0, fh.buf.Length); NUnit.Framework.Assert.IsTrue(ptr > 0); ptr = fh.ParseGitHeaders(ptr, fh.buf.Length); NUnit.Framework.Assert.IsTrue(ptr > 0); }
public virtual void TestParseGitFileName_Empty() { FileHeader fh = Data(string.Empty); NUnit.Framework.Assert.AreEqual(-1, fh.ParseGitFileName(0, fh.buf.Length)); NUnit.Framework.Assert.IsNotNull(fh.GetHunks()); NUnit.Framework.Assert.IsTrue(fh.GetHunks().IsEmpty()); NUnit.Framework.Assert.IsFalse(fh.HasMetaDataChanges()); }
public virtual void TestParseGitFileName_FailFooBar() { FileHeader fh = Data("a/foo b/bar\n-"); NUnit.Framework.Assert.IsTrue(fh.ParseGitFileName(0, fh.buf.Length) > 0); NUnit.Framework.Assert.IsNull(fh.GetOldPath()); NUnit.Framework.Assert.IsNull(fh.GetNewPath()); NUnit.Framework.Assert.IsFalse(fh.HasMetaDataChanges()); }
public virtual void TestParseGitFileName_Foo() { string name = "foo"; FileHeader fh = Header(name); NUnit.Framework.Assert.AreEqual(GitLine(name).Length, fh.ParseGitFileName(0, fh.buf .Length)); NUnit.Framework.Assert.AreEqual(name, fh.GetOldPath()); NUnit.Framework.Assert.AreSame(fh.GetOldPath(), fh.GetNewPath()); NUnit.Framework.Assert.IsFalse(fh.HasMetaDataChanges()); }
public virtual void TestParseGitFileName_SrcFooCNonStandardPrefix() { string name = "src/foo/bar/argh/code.c"; string header = "project-v-1.0/" + name + " mydev/" + name + "\n"; FileHeader fh = Data(header + "-"); NUnit.Framework.Assert.AreEqual(header.Length, fh.ParseGitFileName(0, fh.buf.Length )); NUnit.Framework.Assert.AreEqual(name, fh.GetOldPath()); NUnit.Framework.Assert.AreSame(fh.GetOldPath(), fh.GetNewPath()); NUnit.Framework.Assert.IsFalse(fh.HasMetaDataChanges()); }
public virtual void TestParseGitFileName_DqFooSpLfNulBar() { string name = "foo \n\x0bar"; string dqName = "foo \\n\\0bar"; FileHeader fh = DqHeader(dqName); NUnit.Framework.Assert.AreEqual(DqGitLine(dqName).Length, fh.ParseGitFileName(0, fh.buf.Length)); NUnit.Framework.Assert.AreEqual(name, fh.GetOldPath()); NUnit.Framework.Assert.AreSame(fh.GetOldPath(), fh.GetNewPath()); NUnit.Framework.Assert.IsFalse(fh.HasMetaDataChanges()); }
private int ParseDiffGit(byte[] buf, int start, int end) { FileHeader fh = new FileHeader(buf, start); int ptr = fh.ParseGitFileName(start + DIFF_GIT.Length, end); if (ptr < 0) { return(SkipFile(buf, start)); } ptr = fh.ParseGitHeaders(ptr, end); ptr = ParseHunks(fh, ptr, end); fh.endOffset = ptr; AddFile(fh); return(ptr); }
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()); }
private int ParseDiffGit(byte[] buf, int start, int end) { FileHeader fh = new FileHeader(buf, start); int ptr = fh.ParseGitFileName(start + DIFF_GIT.Length, end); if (ptr < 0) { return SkipFile(buf, start); } ptr = fh.ParseGitHeaders(ptr, end); ptr = ParseHunks(fh, ptr, end); fh.endOffset = ptr; AddFile(fh); return ptr; }
public virtual void TestParseGitFileName_EmptyHeader() { FileHeader fh = Data("\n\n"); NUnit.Framework.Assert.AreEqual(1, fh.ParseGitFileName(0, fh.buf.Length)); }
public virtual void TestParseGitFileName_NoSecondLine() { FileHeader fh = Data("\n"); NUnit.Framework.Assert.AreEqual(-1, fh.ParseGitFileName(0, fh.buf.Length)); }