~repos /only-bible-app
git clone https://pyrossh.dev/repos/only-bible-app.git
The only bible app you will ever need. No ads. No in-app purchases. No distractions.
f21c82f9
—
pyrossh 1 year ago
add SimpleParser
composeApp/src/commonTest/kotlin/dev/pyrossh/only_bible_app/utils/SimpleParserTest.kt
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package dev.pyrossh.only_bible_app.utils
|
|
2
|
+
|
|
3
|
+
import kotlin.test.Test
|
|
4
|
+
import kotlin.test.assertEquals
|
|
5
|
+
|
|
6
|
+
class SimpleParserTest {
|
|
7
|
+
|
|
8
|
+
@Test
|
|
9
|
+
fun parseTextOnly() {
|
|
10
|
+
val parser = SimpleParser("lorem ipsum 123 dorem")
|
|
11
|
+
assertEquals(
|
|
12
|
+
listOf(TextNode(pos = Pos(0, 12), value = "lorem ipsum 123 dorem")),
|
|
13
|
+
parser.parse(),
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Test
|
|
18
|
+
fun parseTextWithBr() {
|
|
19
|
+
val parser = SimpleParser("lorem ipsum <red>dorum</red> data 123")
|
|
20
|
+
assertEquals(
|
|
21
|
+
listOf(
|
|
22
|
+
TextNode(pos = Pos(0, 12), value = "lorem ipsum "),
|
|
23
|
+
TagNode(
|
|
24
|
+
pos = Pos(start = 12, end = 28),
|
|
25
|
+
name = "red",
|
|
26
|
+
child = TextNode(pos = Pos(start = 17, end = 22), value = "dorum")
|
|
27
|
+
),
|
|
28
|
+
TextNode(pos = Pos(start = 28, end = 37), value = " data 123"),
|
|
29
|
+
),
|
|
30
|
+
parser.parse(),
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
}
|