| 1 | import toml |
| 2 | |
| 3 | fn test_crlf() { |
| 4 | str_value := 'test string' |
| 5 | mut toml_txt := 'crlf_string = "test string"\r\n |
| 6 | # Comment with CRLF is not allowed' |
| 7 | toml_doc := toml.parse_text(toml_txt) or { panic(err) } |
| 8 | |
| 9 | value := toml_doc.value('crlf_string') |
| 10 | assert value == toml.Any(str_value) |
| 11 | assert value as string == str_value |
| 12 | assert value.string() == str_value |
| 13 | } |
| 14 | |
| 15 | fn test_crlf_is_parsable_just_like_lf() { |
| 16 | crlf_content := '# a comment\r\ntitle = "TOML Example"\r\n[database]\r\nserver = "192.168.1.1"\r\nports = [ 8000, 8001, 8002 ]\r\n' |
| 17 | all := [crlf_content, crlf_content.replace('\r\n', '\n')] |
| 18 | for content in all { |
| 19 | res := toml.parse_text(content)! |
| 20 | assert res.value('title') == toml.Any('TOML Example') |
| 21 | assert (res.value('database') as map[string]toml.Any)['server']! == toml.Any('192.168.1.1') |
| 22 | } |
| 23 | } |
| 24 | |