From: David ‘Bombe’ Roden Date: Thu, 9 Jun 2011 10:31:23 +0000 (+0200) Subject: Add test for KSK links. X-Git-Tag: 0.6.5^2~8^2~1 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=fcbcbab864988bc4abaf2cc5a8bfafd69e9b9f7f;p=Sone.git Add test for KSK links. --- diff --git a/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java b/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java index ece45f0..b680daa 100644 --- a/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java +++ b/src/test/java/net/pterodactylus/sone/text/SoneTextParserTest.java @@ -55,6 +55,32 @@ public class SoneTextParserTest extends TestCase { assertEquals("Part Text", "Test.\n\nTest.", convertText(parts, PlainTextPart.class)); } + /** + * Tests parsing of KSK links. + * + * @throws IOException + * if an I/O error occurs + */ + public void testKSKLinks() throws IOException { + SoneTextParser soneTextParser = new SoneTextParser(null, null); + Iterable parts; + + /* check basic links. */ + parts = soneTextParser.parse(null, new StringReader("KSK@gpl.txt")); + assertNotNull("Parts", parts); + assertEquals("Part Text", "[KSK@gpl.txt|gpl.txt|gpl.txt]", convertText(parts, FreenetLinkPart.class)); + + /* check embedded links. */ + parts = soneTextParser.parse(null, new StringReader("Link is KSK@gpl.txt\u200b.")); + assertNotNull("Parts", parts); + assertEquals("Part Text", "Link is [KSK@gpl.txt|gpl.txt|gpl.txt]\u200b.", convertText(parts, PlainTextPart.class, FreenetLinkPart.class)); + + /* check embedded links and line breaks. */ + parts = soneTextParser.parse(null, new StringReader("Link is KSK@gpl.txt\nKSK@test.dat\n")); + assertNotNull("Parts", parts); + assertEquals("Part Text", "Link is [KSK@gpl.txt|gpl.txt|gpl.txt]\n[KSK@test.dat|test.dat|test.dat]", convertText(parts, PlainTextPart.class, FreenetLinkPart.class)); + } + // // PRIVATE METHODS //