v2 / vlib / toml / tests / array_of_tables_1_level_test.v
26 lines · 19 sloc · 503 bytes · f09826e928f9612bab9299faefff7cf34a503362
Raw
1import os
2import toml
3import toml.to
4
5const toml_table_text = '
6[[products]]
7name = "Hammer"
8sku = 738594937
9
10[[products]] # empty table within the array
11
12[[products]]
13name = "Nail"
14sku = 284758393
15
16color = "gray"'
17
18fn test_tables() {
19 mut toml_doc := toml.parse_text(toml_table_text) or { panic(err) }
20
21 toml_json := to.json(toml_doc)
22
23 assert toml_json == os.read_file(
24 os.real_path(os.join_path(os.dir(@FILE), 'testdata', os.file_name(@FILE).all_before_last('.'))) +
25 '.out') or { panic(err) }
26}
27