Start of a 'wordlist' type for the config subsystem
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.
This commit is contained in:
parent
0cf7dec793
commit
f7fa5769ca
4 changed files with 26 additions and 4 deletions
|
|
@ -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,;".
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -409,5 +409,4 @@ TEST ("wordlist_add")
|
|||
}
|
||||
|
||||
|
||||
|
||||
TESTS_END
|
||||
|
|
|
|||
Loading…
Reference in a new issue