public void testParse_OnlyLFMessage() { RevTag c = create("\n"); Assert.AreEqual("\n", c.getFullMessage()); Assert.AreEqual(string.Empty, c.getShortMessage()); }
public void testParse_explicit_bad_encoded() { RevTag c; using (var b = new BinaryWriter(new MemoryStream())) { b.Write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("UTF-8")); b.Write("type tree\n".getBytes("UTF-8")); b.Write("tag v1.2.3.4.5\n".getBytes("UTF-8")); b.Write("tagger F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n".getBytes("ISO-8859-1")); b.Write("encoding EUC-JP\n".getBytes("UTF-8")); b.Write("\n".getBytes("UTF-8")); b.Write("\u304d\u308c\u3044\n".getBytes("UTF-8")); b.Write("\n".getBytes("UTF-8")); b.Write("Hi\n".getBytes("UTF-8")); c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); c.parseCanonical(new Core.RevWalk.RevWalk(db), ((MemoryStream)b.BaseStream).ToArray()); } AssertHelper.IgnoreOnMono(() => Assert.AreEqual("F\u00f6r fattare", c.getTaggerIdent().Name), "Will fail in mono due to https://bugzilla.novell.com/show_bug.cgi?id=547902"); Assert.AreEqual("\u304d\u308c\u3044", c.getShortMessage()); Assert.AreEqual("\u304d\u308c\u3044\n\nHi\n", c.getFullMessage()); }
public void testParse_ShortLineOnlyNoLF() { const string shortMsg = "This is a short message."; RevTag c = create(shortMsg); Assert.AreEqual(shortMsg, c.getFullMessage()); Assert.AreEqual(shortMsg, c.getShortMessage()); }
public void testParse_NoMessage() { const string msg = ""; RevTag c = create(msg); Assert.AreEqual(msg, c.getFullMessage()); Assert.AreEqual(msg, c.getShortMessage()); }
public void testParse_ShortLineOnlyEmbeddedAndEndingLF() { const string fullMsg = "This is a\nshort message.\n"; const string shortMsg = "This is a short message."; RevTag c = create(fullMsg); Assert.AreEqual(fullMsg, c.getFullMessage()); Assert.AreEqual(shortMsg, c.getShortMessage()); }
public void testParse_ShortLineOnlyEmbeddedLF() { const string fullMsg = "This is a\nshort message."; string shortMsg = fullMsg.Replace('\n', ' '); RevTag c = create(fullMsg); Assert.AreEqual(fullMsg, c.getFullMessage()); Assert.AreEqual(shortMsg, c.getShortMessage()); }
public void testParse_GitStyleMessage() { const string shortMsg = "This fixes a bug."; const string body = "We do it with magic and pixie dust and stuff.\n" + "\n" + "Signed-off-by: A U. Thor <*****@*****.**>\n"; const string fullMsg = shortMsg + "\n" + "\n" + body; RevTag c = create(fullMsg); Assert.AreEqual(fullMsg, c.getFullMessage()); Assert.AreEqual(shortMsg, c.getShortMessage()); }
public void testParseOldStyleNoTagger() { ObjectId treeId = Id("9788669ad918b6fcce64af8882fc9a81cb6aba67"); string name = "v1.2.3.4.5"; string message = "test\n" // + "\n" // + "-----BEGIN PGP SIGNATURE-----\n" // + "Version: GnuPG v1.4.1 (GNU/Linux)\n" // + "\n" // + "iD8DBQBC0b9oF3Y\n" // + "-----END PGP SIGNATURE------n"; var body = new StringBuilder(); body.Append("object "); body.Append(treeId.Name); body.Append("\n"); body.Append("type tree\n"); body.Append("tag "); body.Append(name); body.Append("\n"); body.Append("\n"); body.Append(message); var rw = new Core.RevWalk.RevWalk(db); RevTag c; c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); Assert.IsNull(c.getObject()); Assert.IsNull(c.getTagName()); c.parseCanonical(rw, body.ToString().getBytes("UTF-8")); Assert.IsNotNull(c.getObject()); Assert.AreEqual(treeId, c.getObject().getId()); Assert.AreSame(rw.lookupTree(treeId), c.getObject()); Assert.IsNotNull(c.getTagName()); Assert.AreEqual(name, c.getTagName()); Assert.AreEqual("test", c.getShortMessage()); Assert.AreEqual(message, c.getFullMessage()); Assert.IsNull(c.getTaggerIdent()); }
public void testParse_implicit_UTF8_encoded() { RevTag c; using (var b = new BinaryWriter(new MemoryStream())) { b.Write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("UTF-8")); b.Write("type tree\n".getBytes("UTF-8")); b.Write("tag v1.2.3.4.5\n".getBytes("UTF-8")); b.Write("tagger F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n".getBytes("UTF-8")); b.Write("\n".getBytes("UTF-8")); b.Write("Sm\u00f6rg\u00e5sbord\n".getBytes("UTF-8")); b.Write("\n".getBytes("UTF-8")); b.Write("\u304d\u308c\u3044\n".getBytes("UTF-8")); c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); c.parseCanonical(new Core.RevWalk.RevWalk(db), ((MemoryStream)b.BaseStream).ToArray()); } Assert.AreEqual("F\u00f6r fattare", c.getTaggerIdent().Name); Assert.AreEqual("Sm\u00f6rg\u00e5sbord", c.getShortMessage()); Assert.AreEqual("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage()); }
public void testParse_explicit_encoded() { Assert.Ignore("We are going to deal with encoding problems later. For now, they are only disturbing the build."); RevTag c; using (var b = new BinaryWriter(new MemoryStream())) { b.Write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("EUC-JP")); b.Write("type tree\n".getBytes("EUC-JP")); b.Write("tag v1.2.3.4.5\n".getBytes("EUC-JP")); b.Write("tagger F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n".getBytes("EUC-JP")); b.Write("encoding euc_JP\n".getBytes("EUC-JP")); b.Write("\n".getBytes("EUC-JP")); b.Write("\u304d\u308c\u3044\n".getBytes("EUC-JP")); b.Write("\n".getBytes("EUC-JP")); b.Write("Hi\n".getBytes("EUC-JP")); c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); c.parseCanonical(new Core.RevWalk.RevWalk(db), ((MemoryStream)b.BaseStream).ToArray()); } Assert.AreEqual("F\u00f6r fattare", c.getTaggerIdent().Name); Assert.AreEqual("\u304d\u308c\u3044", c.getShortMessage()); Assert.AreEqual("\u304d\u308c\u3044\n\nHi\n", c.getFullMessage()); }