Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
morisil committed Jan 17, 2025
1 parent 32e36da commit 2ff0fa2
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/commonTest/kotlin/compare/TextComparisonTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class TextComparisonTest {
- actual: "foo"
- expected: "bar"
- changes: "[-f-]{+b+}[-o-]{+a+}[-o-]{+r+}"
""".trimIndent()
)

Expand Down Expand Up @@ -96,12 +97,19 @@ class TextComparisonTest {
│ * List item 1
│ * List item three
└─ differences
• line 3: "This is a paragraph" vs "This is paragraph"
changes: "This is [-a-][ -]paragraph"
• line 4: "with two lines." vs "with 2 lines."
changes: "with [-t-][-w-][-o-]{+2+} lines."
• line 7: "* List item 2" vs "* List item three"
changes: "* List item [-2-]{+t+}{+h+}{+r+}{+e+}{+e+}"
• line 3: strings differ
- actual: "This is a paragraph"
- expected: "This is paragraph"
- changes: "This is [-a-][ -]paragraph"
• line 4: strings differ
- actual: "with two lines."
- expected: "with 2 lines."
- changes: "with [-t-][-w-][-o-]{+2+} lines."
• line 7: strings differ
- actual: "* List item 2"
- expected: "* List item three"
- changes: "* List item [-2-]{+t+}{+h+}{+r+}{+e+}{+e+}"
""".trimIndent()
)

Expand Down Expand Up @@ -132,6 +140,7 @@ class TextComparisonTest {
- actual: " <p>Hello</p>" (4 spaces)
- expected: " <p>Hello</p>" (3 spaces)
- changes: " <p>Hello</p>[-⠀-]"
""".trimIndent()
)

Expand Down Expand Up @@ -170,6 +179,7 @@ class TextComparisonTest {
changes: "Line with two spaces{+⠀+}{+⠀+}"
• structural: missing newline at end of file
Note: ⠀ represents a space character
""".trimIndent()
)

Expand Down Expand Up @@ -240,6 +250,7 @@ class TextComparisonTest {
changes: '<div class="[-c-][-o-][-n-][-t-][-a-][-i-][-n-][-e-][-r-]{+m+}{+a+}{+i+}{+n+}{+-+}{+c+}{+o+}{+n+}{+t+}{+a+}{+i+}{+n+}{+e+}{+r+}">'
• line 8: 'Hello World' vs 'Hello, World!'
changes: "Hello[-⠀-]{+,+}{+⠀+}World{+!+}"
""".trimIndent()
)

Expand Down Expand Up @@ -338,13 +349,13 @@ class TextComparisonTest {
changes: "> with multiple lines{+.+}"
• line 16: indentation and missing semicolon
changes: "[-⠀-][-⠀-][-⠀-][-⠀-]println("Hello"){+;+}"
""".trimIndent()
)

private fun assertDifference(text1: String, text2: String, difference: String) {
val diff = text1 diff text2
assertEquals(expected = difference, actual = diff)
if (diff.isNotEmpty()) {
if ((diff != difference) && diff.isNotEmpty()) {
fail("The actual difference message was:\n${diff}")
}
}
Expand Down

0 comments on commit 2ff0fa2

Please sign in to comment.