2013-01-07 05:43:01 +01:00
|
|
|
TESTING "test configuration system" ./test-configloader
|
2008-08-07 06:09:50 +02:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
2008-08-07 14:55:17 +02:00
|
|
|
TEST "number get, default" number_get test.number.1 '1234567890 # comment' <<END
|
2008-08-07 11:43:06 +02:00
|
|
|
out: 1234567890
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
export LUMIERA_TEST_NUMBER_1=987654321
|
2008-08-08 08:21:38 +02:00
|
|
|
|
2008-08-07 14:55:17 +02:00
|
|
|
TEST "number get, env override" number_get test.number.1 '1234567890 # comment' <<END
|
2008-08-07 11:43:06 +02:00
|
|
|
out: 987654321
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
export LUMIERA_TEST_NUMBER_1=barf
|
2008-08-07 14:55:17 +02:00
|
|
|
TEST "number get, type error" number_get_nodefault test.number.1 <<END
|
2008-08-08 08:21:38 +02:00
|
|
|
out: LUMIERA_ERROR_CONFIG_SYNTAX_VALUE:syntax error in value
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
LUMIERA_TEST_NUMBER_1=NAN
|
2008-09-08 07:47:46 +02:00
|
|
|
TEST "number get, type error" number_get test.number.1 '1234 # comment' <<END
|
|
|
|
|
out: LUMIERA_ERROR_CONFIG_SYNTAX_VALUE:syntax error in value, 0
|
2008-08-07 11:43:06 +02:00
|
|
|
END
|
2008-08-08 08:21:38 +02:00
|
|
|
|
2008-08-07 11:43:06 +02:00
|
|
|
unset LUMIERA_TEST_NUMBER_1
|
|
|
|
|
|
|
|
|
|
|
2008-08-08 08:21:38 +02:00
|
|
|
TEST "number get, syntax error" number_get_nodefault test.NUMBER.1 <<END
|
2008-08-07 14:55:17 +02:00
|
|
|
out: LUMIERA_ERROR_CONFIG_SYNTAX_KEY:syntax error in key
|
2008-08-07 11:43:06 +02:00
|
|
|
END
|
|
|
|
|
|
|
|
|
|
|
2008-08-07 14:55:17 +02:00
|
|
|
TEST "number get, no default, no env" number_get_nodefault test.number.1 <<END
|
|
|
|
|
out: LUMIERA_ERROR_CONFIG_NO_ENTRY:no configuration entry
|
2008-08-07 11:43:06 +02:00
|
|
|
END
|
|
|
|
|
|
|
|
|
|
|
2008-09-10 15:16:40 +02:00
|
|
|
TEST "number set" number_set test.number '-123456789012345' <<END
|
|
|
|
|
out: '-123456789012345'
|
2008-08-07 11:43:06 +02:00
|
|
|
END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PLANNED "real get" <<END
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PLANNED "real set" <<END
|
|
|
|
|
END
|
|
|
|
|
|
|
|
|
|
|
2008-08-08 08:28:07 +02:00
|
|
|
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'
|
2008-08-07 11:43:06 +02:00
|
|
|
END
|
2008-08-10 11:52:24 +02:00
|
|
|
unset LUMIERA_TEST_STRING
|
2008-08-07 11:43:06 +02:00
|
|
|
|
|
|
|
|
|
2008-08-10 11:52:24 +02:00
|
|
|
TEST "string set" string_set test.string 'foo bar' <<END
|
|
|
|
|
out: 'foo bar'
|
2008-08-07 11:43:06 +02:00
|
|
|
END
|
|
|
|
|
|
|
|
|
|
|
2008-08-10 11:52:24 +02:00
|
|
|
export LUMIERA_TEST_WORD=' " double quote is just right'
|
|
|
|
|
|
|
|
|
|
TEST "word get" word_get test.word default <<END
|
|
|
|
|
out: '"'
|
2008-08-07 11:43:06 +02:00
|
|
|
END
|
|
|
|
|
|
2008-08-10 11:52:24 +02:00
|
|
|
unset LUMIERA_TEST_WORD
|
|
|
|
|
|
2008-08-07 11:43:06 +02:00
|
|
|
|
2008-09-10 15:16:40 +02:00
|
|
|
TEST "word set" word_set test.word 'word foo bar' <<END
|
|
|
|
|
out: 'word'
|
2008-08-07 11:43:06 +02:00
|
|
|
END
|
|
|
|
|
|
|
|
|
|
|
2008-08-10 11:52:24 +02:00
|
|
|
|
2008-08-07 11:43:06 +02:00
|
|
|
PLANNED "bool get" <<END
|
2008-08-07 06:09:50 +02:00
|
|
|
END
|
|
|
|
|
|
|
|
|
|
|
2008-08-07 11:43:06 +02:00
|
|
|
PLANNED "bool set" <<END
|
2008-08-07 06:09:50 +02:00
|
|
|
END
|
|
|
|
|
|
2008-09-22 22:38:17 +02:00
|
|
|
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
|
|
|
|
|
|
2008-09-25 17:29:00 +02:00
|
|
|
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
|
2008-09-26 03:31:22 +02:00
|
|
|
|
|
|
|
|
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
|
2009-02-12 02:38:58 +01:00
|
|
|
out: ^' baz barf gnarf same'$
|
2008-09-26 03:31:22 +02:00
|
|
|
END
|
|
|
|
|
|
|
|
|
|
TEST "wordlist add to empty list" wordlist_add 'foo.bar' '' first second << END
|
2009-02-12 02:38:58 +01:00
|
|
|
out: ^' first'$
|
|
|
|
|
out: ^' first second'$
|
2008-09-26 03:31:22 +02:00
|
|
|
END
|
|
|
|
|
|
|
|
|
|
TEST "wordlist add to empty list, same" wordlist_add 'foo.bar' '' same same << END
|
2009-02-12 02:38:58 +01:00
|
|
|
out: ^' same'$
|
2008-09-26 03:31:22 +02:00
|
|
|
END
|
2008-09-22 22:38:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|