-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a test to validate line numbers and fix for multiline strings
### What's done: - On multiline strings we forgot to update isMultiline flag while decoding and parsing - Adding extra info to prettyPrint - Adding a test for validation of line numbers - Removing deprecated 'content' from the TomlNode
- Loading branch information
Showing
4 changed files
with
76 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
ktoml-core/src/commonTest/kotlin/com/akuleshov7/ktoml/parsers/SetLineNoTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.akuleshov7.ktoml.parsers | ||
|
||
import com.akuleshov7.ktoml.Toml | ||
import com.akuleshov7.ktoml.tree.nodes.TomlKeyValuePrimitive | ||
import kotlin.test.Test | ||
import kotlin.test.assertContentEquals | ||
import kotlin.test.assertEquals | ||
|
||
class SetLineNoTest { | ||
@Test | ||
fun checkingLineNumbers() { | ||
val string = """ | ||
# comment 1 | ||
[a] # comment 2 | ||
# comment 3 | ||
test = 1 # comment 4 | ||
# ==== | ||
[[a.b]] # comment 5 | ||
test = 1 | ||
mls = ''' | ||
1 | ||
2 | ||
3 | ||
''' | ||
mla = [ | ||
"a", | ||
"b", | ||
"c" | ||
] | ||
""".trimIndent() | ||
val parsedToml = Toml.tomlParser.parseString(string) | ||
|
||
parsedToml.prettyPrint(true) | ||
assertEquals( | ||
""" | ||
| - TomlFile (rootNode)[line:0] | ||
| - TomlTablePrimitive ([a])[line:4] | ||
| - TomlKeyValuePrimitive (test=1)[line:6] | ||
| - TomlArrayOfTables ([[a.b]])[line:10] | ||
| - TomlArrayOfTablesElement (technical_node)[line:10] | ||
| - TomlKeyValuePrimitive (test=1)[line:11] | ||
| - TomlKeyValuePrimitive (mls=''' 1 | ||
| 2 | ||
| 3 | ||
| ''')[line:13] | ||
| - TomlKeyValueArray (mla=[ "a", "b", "c" ])[line:18] | ||
| | ||
""".trimMargin(), | ||
parsedToml.prettyStr(true) | ||
) | ||
} | ||
} |