diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-08-25 10:58:53 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-08-25 10:58:53 +0100 |
commit | 05f5c01ba6b609f8b15574412fd874adda322590 (patch) | |
tree | d662fd13157a613e21111fae72e74c93c11e18a1 /test | |
parent | a278292101608a2fc1c2ebb3a46f883b2ffc7076 (diff) | |
download | clod-05f5c01ba6b609f8b15574412fd874adda322590.tar.gz |
CLOD: Simple list methods with simple algorithm for replacement strategy
Diffstat (limited to 'test')
-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) |