diff --git a/src/backend/config.h b/src/backend/config.h index 0b50c7da2..4e3acd9a9 100644 --- a/src/backend/config.h +++ b/src/backend/config.h @@ -217,7 +217,6 @@ lumiera_config_setdefault (const char* line); LUMIERA_CONFIG_TYPES #undef LUMIERA_CONFIG_TYPE - /** * Wordlists * Wordlists are lists of single words delimited by any of " \t,;". diff --git a/src/backend/config_wordlist.c b/src/backend/config_wordlist.c index 548a4d824..6cd0389a7 100644 --- a/src/backend/config_wordlist.c +++ b/src/backend/config_wordlist.c @@ -33,6 +33,9 @@ extern LumieraConfig lumiera_global_config; //TODO: System includes// +/** + * return nth word of a wordlist + */ const char* lumiera_config_wordlist_get_nth (const char* key, unsigned nth) { @@ -196,12 +199,11 @@ lumiera_config_wordlist_append (const char* key, const char** value, unsigned nt { } + LumieraConfigitem lumiera_config_wordlist_preprend (const char* key, const char** value, unsigned nth) { } - - #endif diff --git a/tests/22config_highlevel.tests b/tests/22config_highlevel.tests index 3d131da3e..c43baaefe 100644 --- a/tests/22config_highlevel.tests +++ b/tests/22config_highlevel.tests @@ -222,3 +222,25 @@ TEST "wordlist add to empty list, same" wordlist_add 'foo.bar' '' same same << E 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 + diff --git a/tests/backend/test-config.c b/tests/backend/test-config.c index deffa7c00..506801454 100644 --- a/tests/backend/test-config.c +++ b/tests/backend/test-config.c @@ -409,5 +409,4 @@ TEST ("wordlist_add") } - TESTS_END