X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ftext%2FSoneTextParserTest.java;h=b680daa51be09ea3852ff986abfff33564c0bfe4;hp=ece45f03c5991241365d92b468a7a868a9e84d9b;hb=fcbcbab864988bc4abaf2cc5a8bfafd69e9b9f7f;hpb=15d615074733889c8e1553581a2cae2846070fa8 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 //