v2 / vlib / toml / tests / json_test.v
18 lines · 16 sloc · 509 bytes · ee6b23c2a780522c1a4ecf31eda44bf883c98954
Raw
1import os
2import toml
3import toml.to
4
5fn test_parse() {
6 toml_file :=
7 os.real_path(os.join_path(os.dir(@FILE), 'testdata', os.file_name(@FILE).all_before_last('.'))) +
8 '.toml'
9 toml_doc := toml.parse_file(toml_file) or { panic(err) }
10
11 toml_json := to.json(toml_doc)
12 out_file :=
13 os.real_path(os.join_path(os.dir(@FILE), 'testdata', os.file_name(@FILE).all_before_last('.'))) +
14 '.out'
15 out_file_json := os.read_file(out_file) or { panic(err) }
16 println(toml_json)
17 assert toml_json == out_file_json
18}
19