2021-11-02 20:07:27 +03:00
|
|
|
import toml
|
|
|
|
|
|
|
|
fn test_crlf() {
|
|
|
|
str_value := 'test string'
|
2021-11-29 23:15:22 +03:00
|
|
|
mut toml_txt := 'crlf_string = "test string"\r\n
|
|
|
|
# Comment with CRLF is not allowed'
|
2022-03-19 00:32:06 +03:00
|
|
|
toml_doc := toml.parse_text(toml_txt) or { panic(err) }
|
2021-11-02 20:07:27 +03:00
|
|
|
|
|
|
|
value := toml_doc.value('crlf_string')
|
|
|
|
assert value == toml.Any(str_value)
|
|
|
|
assert value as string == str_value
|
|
|
|
assert value.string() == str_value
|
|
|
|
}
|
2022-01-02 19:13:43 +03:00
|
|
|
|
2022-09-21 19:45:43 +03:00
|
|
|
fn test_crlf_is_parsable_just_like_lf() {
|
2022-01-02 19:13:43 +03:00
|
|
|
crlf_content := '# a comment\r\ntitle = "TOML Example"\r\n[database]\r\nserver = "192.168.1.1"\r\nports = [ 8000, 8001, 8002 ]\r\n'
|
|
|
|
all := [crlf_content, crlf_content.replace('\r\n', '\n')]
|
|
|
|
for content in all {
|
2022-12-15 11:16:42 +03:00
|
|
|
res := toml.parse_text(content)!
|
2022-01-02 19:13:43 +03:00
|
|
|
assert res.value('title') == toml.Any('TOML Example')
|
2022-10-19 21:04:16 +03:00
|
|
|
assert (res.value('database') as map[string]toml.Any)['server']! == toml.Any('192.168.1.1')
|
2022-01-02 19:13:43 +03:00
|
|
|
}
|
|
|
|
}
|