From b44e94cb16fe4b7b85972e9ec246d227f16424f0 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Wed, 29 Nov 2023 16:50:36 -0500 Subject: [PATCH] Adds a test case for urls ending with a period. --- .../amethyst/RichTextParserTest.kt | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/src/androidTest/java/com/vitorpamplona/amethyst/RichTextParserTest.kt b/app/src/androidTest/java/com/vitorpamplona/amethyst/RichTextParserTest.kt index 9fbc7ce43..f9f8cf2c3 100644 --- a/app/src/androidTest/java/com/vitorpamplona/amethyst/RichTextParserTest.kt +++ b/app/src/androidTest/java/com/vitorpamplona/amethyst/RichTextParserTest.kt @@ -4127,6 +4127,31 @@ https://nostr.build/i/fd53fcf5ad950fbe45127e4bcee1b59e8301d41de6beee211f45e344db } } + @Test + fun testUrlsEndingInPeriod() { + val text = "That’s it! http://vitorpamplona.com/. That’s the note" + + val state = RichTextParser().parseText(text, EmptyTagList) + + printStateForDebug(state) + + val expectedResult = listOf( + "RegularText(That’s)", + "RegularText(it!)", + "Link(http://vitorpamplona.com/.)", + "RegularText(That’s)", + "RegularText(the)", + "RegularText(note)" + ) + + state.paragraphs.map { it.words }.flatten().forEachIndexed { index, seg -> + Assert.assertEquals( + expectedResult[index], + "${seg.javaClass.simpleName.replace("Segment", "")}(${seg.segmentText})" + ) + } + } + private fun printStateForDebug(state: RichTextViewerState) { state.paragraphs.forEach { paragraph -> paragraph.words.forEach { seg ->