diff options
Diffstat (limited to 'test/test-clod.lua')
-rw-r--r-- | test/test-clod.lua | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/test-clod.lua b/test/test-clod.lua index f8baa77..7fc05cd 100644 --- a/test/test-clod.lua +++ b/test/test-clod.lua @@ -256,6 +256,65 @@ owner.name "Daniel" assert(not had_owner) end +function suite.get_list() + local input_str = [[ +foo["*"] "Hello" +foo["*"] "World" +]] + local conf = clod.parse(input_str) + local list = conf:get_list('foo') + assert(#list == 2) + assert(list[1] == "Hello") + assert(list[2] == "World") +end + +function suite.set_list_same_length() + local input_str = [[ +foo["*"] "Hello" +foo["*"] "World" +]] + local conf = clod.parse(input_str) + local list = { "Yeesh", "Gawd" } + conf:set_list("foo", list) + local output_str = [[ +foo["*"] "Yeesh" +foo["*"] "Gawd" +]] + assert(conf:serialise() == output_str) +end + +function suite.set_list_longer_length() + local input_str = [[ +foo["*"] "Hello" +foo["*"] "World" +]] + local conf = clod.parse(input_str) + local list = { "Yeesh", "Gawd", "Cripes" } + conf:set_list("foo", list) + local output_str = [[ +foo["*"] "Yeesh" +foo["*"] "Gawd" +foo["*"] "Cripes" +]] + assert(conf:serialise() == output_str) +end + +function suite.set_list_shorter_length() + local input_str = [[ +foo["*"] "Hello" +foo["*"] "World" +foo["*"] "Badger" +]] + local conf = clod.parse(input_str) + local list = { "Yeesh", "Gawd" } + conf:set_list("foo", list) + local output_str = [[ +foo["*"] "Yeesh" +foo["*"] "Gawd" +]] + assert(conf:serialise() == output_str) +end + local count_ok = 0 for _, testname in ipairs(testnames) do -- print("Run: " .. testname) |