wordlists are simple not quoted words delimited by semicolon, tab, space or commas. Some special functions will allow to access each of this words by index etc.
246 lines
5.7 KiB
Text
246 lines
5.7 KiB
Text
TESTING "test configuration system" ./test-config
|
|
|
|
PLANNED "loading configfile, simple" <<END
|
|
END
|
|
|
|
|
|
PLANNED "loading configfile, with includes" <<END
|
|
END
|
|
|
|
|
|
PLANNED "env var override" <<END
|
|
END
|
|
|
|
|
|
PLANNED "lowlevel get" <<END
|
|
END
|
|
|
|
|
|
PLANNED "lowlevel set" <<END
|
|
END
|
|
|
|
|
|
PLANNED "saving simple configfile" <<END
|
|
END
|
|
|
|
|
|
PLANNED "complex saving user file" <<END
|
|
END
|
|
|
|
|
|
TEST "number get, default" number_get test.number.1 '1234567890 # comment' <<END
|
|
out: 1234567890
|
|
END
|
|
|
|
export LUMIERA_TEST_NUMBER_1=987654321
|
|
|
|
TEST "number get, env override" number_get test.number.1 '1234567890 # comment' <<END
|
|
out: 987654321
|
|
END
|
|
|
|
export LUMIERA_TEST_NUMBER_1=barf
|
|
TEST "number get, type error" number_get_nodefault test.number.1 <<END
|
|
out: LUMIERA_ERROR_CONFIG_SYNTAX_VALUE:syntax error in value
|
|
END
|
|
|
|
LUMIERA_TEST_NUMBER_1=NAN
|
|
TEST "number get, type error" number_get test.number.1 '1234 # comment' <<END
|
|
out: LUMIERA_ERROR_CONFIG_SYNTAX_VALUE:syntax error in value, 0
|
|
END
|
|
|
|
unset LUMIERA_TEST_NUMBER_1
|
|
|
|
|
|
TEST "number get, syntax error" number_get_nodefault test.NUMBER.1 <<END
|
|
out: LUMIERA_ERROR_CONFIG_SYNTAX_KEY:syntax error in key
|
|
END
|
|
|
|
|
|
TEST "number get, no default, no env" number_get_nodefault test.number.1 <<END
|
|
out: LUMIERA_ERROR_CONFIG_NO_ENTRY:no configuration entry
|
|
END
|
|
|
|
|
|
TEST "number set" number_set test.number '-123456789012345' <<END
|
|
out: '-123456789012345'
|
|
END
|
|
|
|
|
|
PLANNED "real get" <<END
|
|
END
|
|
|
|
|
|
PLANNED "real set" <<END
|
|
END
|
|
|
|
|
|
export LUMIERA_TEST_STRING="teststring"
|
|
|
|
TEST "string get" string_get test.string default <<END
|
|
out: 'teststring'
|
|
END
|
|
|
|
|
|
TEST "string get, default" string_get test.doesntexist default <<END
|
|
out: 'default'
|
|
END
|
|
|
|
LUMIERA_TEST_STRING=' no leading and trailing blanks '
|
|
TEST "string get, chopped" string_get test.string default <<END
|
|
out: 'no leading and trailing blanks'
|
|
END
|
|
|
|
|
|
LUMIERA_TEST_STRING=' " quoted string with spaces " "ignored" #comment'
|
|
TEST "string get, quoted" string_get test.string default <<END
|
|
out: ' quoted string with spaces '
|
|
END
|
|
|
|
|
|
LUMIERA_TEST_STRING=' "quoted string "" not ignored" #comment'
|
|
TEST "string get, quoted, escaped" string_get test.string default <<END
|
|
out: 'quoted string " not ignored'
|
|
END
|
|
unset LUMIERA_TEST_STRING
|
|
|
|
|
|
TEST "string set" string_set test.string 'foo bar' <<END
|
|
out: 'foo bar'
|
|
END
|
|
|
|
|
|
export LUMIERA_TEST_WORD=' " double quote is just right'
|
|
|
|
TEST "word get" word_get test.word default <<END
|
|
out: '"'
|
|
END
|
|
|
|
unset LUMIERA_TEST_WORD
|
|
|
|
|
|
TEST "word set" word_set test.word 'word foo bar' <<END
|
|
out: 'word'
|
|
END
|
|
|
|
|
|
|
|
PLANNED "bool get" <<END
|
|
END
|
|
|
|
|
|
PLANNED "bool set" <<END
|
|
END
|
|
|
|
TEST "wordlist get item from empty list should fail" wordlist_get_nth 'foo.bar' '' 0 << END
|
|
out: 'NULL'
|
|
END
|
|
|
|
TEST "wordlist get item past end should fail" wordlist_get_nth 'foo.bar' 'baz barf gnarf' 3 << END
|
|
out: 'NULL'
|
|
END
|
|
|
|
TEST "wordlist get first item" wordlist_get_nth 'foo.bar' 'baz barf gnarf' 0 << END
|
|
out: 'baz'
|
|
END
|
|
|
|
TEST "wordlist get last item" wordlist_get_nth 'foo.bar' 'baz barf; gnarf' 2 << END
|
|
out: 'gnarf'
|
|
END
|
|
|
|
TEST "wordlist get middle" wordlist_get_nth 'foo.bar' 'baz barf, gnarf' 1 << END
|
|
out: 'barf'
|
|
END
|
|
|
|
TEST "wordlist find, non existing" wordlist_find 'foo.bar' 'baz barf, gnarf' blah << END
|
|
out: '-1'
|
|
END
|
|
|
|
TEST "wordlist find, first" wordlist_find 'foo.bar' 'baz barf, gnarf' baz << END
|
|
out: '0'
|
|
END
|
|
|
|
TEST "wordlist find, middle" wordlist_find 'foo.bar' 'baz barf, gnarf' barf << END
|
|
out: '1'
|
|
END
|
|
|
|
TEST "wordlist find, last" wordlist_find 'foo.bar' 'baz barf, gnarf' gnarf << END
|
|
out: '2'
|
|
END
|
|
|
|
TEST "wordlist replace, middle, insert after" wordlist_replace 'foo.bar' 'baz barf gnarf' barf barf foof << END
|
|
out: ' baz barf foof gnarf'
|
|
END
|
|
|
|
TEST "wordlist replace, middle, insert before" wordlist_replace 'foo.bar' 'baz barf gnarf' barf foof barf << END
|
|
out: ' baz foof barf gnarf'
|
|
END
|
|
|
|
TEST "wordlist replace, middle, remove" wordlist_replace 'foo.bar' 'baz barf gnarf' barf '' '' << END
|
|
out: ' baz gnarf'
|
|
END
|
|
|
|
TEST "wordlist replace, middle, replace1" wordlist_replace 'foo.bar' 'baz barf gnarf' barf 'foof' '' << END
|
|
out: ' baz foof gnarf'
|
|
END
|
|
|
|
TEST "wordlist replace, middle, replace2" wordlist_replace 'foo.bar' 'baz barf gnarf' barf '' 'foof' << END
|
|
out: ' baz foof gnarf'
|
|
END
|
|
|
|
TEST "wordlist replace, first, insert before" wordlist_replace 'foo.bar' 'baz barf gnarf' baz 'first' 'baz' << END
|
|
out: ' first baz barf gnarf'
|
|
END
|
|
|
|
TEST "wordlist replace, first, replace1" wordlist_replace 'foo.bar' 'baz barf gnarf' baz 'first' '' << END
|
|
out: ' first barf gnarf'
|
|
END
|
|
|
|
TEST "wordlist replace, first, replace2" wordlist_replace 'foo.bar' 'baz barf gnarf' baz '' 'first' << END
|
|
out: ' first barf gnarf'
|
|
END
|
|
|
|
TEST "wordlist replace, last, insert after" wordlist_replace 'foo.bar' 'baz barf gnarf' gnarf 'gnarf' 'last' << END
|
|
out: ' baz barf gnarf last'
|
|
END
|
|
|
|
TEST "wordlist add 2 words" wordlist_add 'foo.bar' 'baz barf gnarf' first second << END
|
|
out: ' baz barf gnarf first'
|
|
out: ' baz barf gnarf first second'
|
|
END
|
|
|
|
TEST "wordlist add same word" wordlist_add 'foo.bar' 'baz barf gnarf' same same << END
|
|
out: ' baz barf gnarf same'
|
|
out: ' baz barf gnarf same'
|
|
END
|
|
|
|
TEST "wordlist add to empty list" wordlist_add 'foo.bar' '' first second << END
|
|
out: ' first'
|
|
out: ' first second'
|
|
END
|
|
|
|
TEST "wordlist add to empty list, same" wordlist_add 'foo.bar' '' same same << END
|
|
out: ' same'
|
|
out: ' same'
|
|
END
|
|
|
|
|
|
TEST "wordlist get item from empty list should fail" wordlist_get_nth 'foo.bar' '' 0 << END
|
|
out: 'NULL'
|
|
END
|
|
|
|
TEST "wordlist get item past end should fail" wordlist_get_nth 'foo.bar' 'baz barf gnarf' 3 << END
|
|
out: 'NULL'
|
|
END
|
|
|
|
TEST "wordlist get first item" wordlist_get_nth 'foo.bar' 'baz barf gnarf' 0 << END
|
|
out: 'baz'
|
|
END
|
|
|
|
TEST "wordlist get last item" wordlist_get_nth 'foo.bar' 'baz barf; gnarf' 2 << END
|
|
out: 'gnarf'
|
|
END
|
|
|
|
TEST "wordlist get middle" wordlist_get_nth 'foo.bar' 'baz barf, gnarf' 1 << END
|
|
out: 'barf'
|
|
END
|
|
|