2021-11-02 18:07:27 +01:00
|
|
|
import toml
|
|
|
|
|
|
|
|
fn test_crlf() {
|
|
|
|
str_value := 'test string'
|
2021-11-29 21:15:22 +01:00
|
|
|
mut toml_txt := 'crlf_string = "test string"\r\n
|
|
|
|
# Comment with CRLF is not allowed'
|
2022-03-18 22:32:06 +01:00
|
|
|
toml_doc := toml.parse_text(toml_txt) or { panic(err) }
|
2021-11-02 18:07:27 +01: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 17:13:43 +01:00
|
|
|
|
|
|
|
fn test_crlf_is_parsable_just_like_lf() ? {
|
|
|
|
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-05-13 05:56:21 +02:00
|
|
|
res := toml.parse_text(content)?
|
2022-01-02 17:13:43 +01:00
|
|
|
assert res.value('title') == toml.Any('TOML Example')
|
2022-05-13 05:56:21 +02:00
|
|
|
assert (res.value('database') as map[string]toml.Any)['server']? == toml.Any('192.168.1.1')
|
2022-01-02 17:13:43 +01:00
|
|
|
}
|
|
|
|
}
|