diff options
author | David Kalnischkies <david@kalnischkies.de> | 2014-02-24 23:10:25 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2014-03-13 13:57:34 +0100 |
commit | a5414e56403537678d5be87acf59c37a05f55719 (patch) | |
tree | e68d95ae7867e4723e4aa69f8a9ede1e36eb0df2 /test | |
parent | fa19cc9573aac19cfbf43364d4b5660c9ab645bc (diff) |
add default and override handling for Cnf::FindVector
Automatically handle the override of list options via its parent value
which can even be a comma-separated list of values. It also adds an easy
way of providing a default for the list.
Diffstat (limited to 'test')
-rw-r--r-- | test/libapt/configuration_test.cc | 34 | ||||
-rw-r--r-- | test/libapt/getlanguages_test.cc | 8 |
2 files changed, 39 insertions, 3 deletions
diff --git a/test/libapt/configuration_test.cc b/test/libapt/configuration_test.cc index 2c974ee0a..957e905d5 100644 --- a/test/libapt/configuration_test.cc +++ b/test/libapt/configuration_test.cc @@ -98,9 +98,37 @@ int main(int argc,const char *argv[]) { equals(Cnf.FindDir("Dir::State"), "/rootdir/dev/null"); equals(Cnf.FindDir("Dir::State::lists"), "/rootdir/dev/null"); - Cnf.Set("Moo::Bar", "1"); - Cnf.Clear(); - equals(Cnf.Find("Moo::Bar"), ""); + Cnf.Set("Moo::Bar", "1"); + Cnf.Clear(); + equals(Cnf.Find("Moo::Bar"), ""); + + std::vector<std::string> vec = Cnf.FindVector("Test::Vector", ""); + equals(vec.size(), 0); + vec = Cnf.FindVector("Test::Vector", "foo"); + equals(vec.size(), 1); + equals(vec[0], "foo"); + vec = Cnf.FindVector("Test::Vector", "foo,bar"); + equals(vec.size(), 2); + equals(vec[0], "foo"); + equals(vec[1], "bar"); + Cnf.Set("Test::Vector::", "baz"); + Cnf.Set("Test::Vector::", "bob"); + Cnf.Set("Test::Vector::", "dob"); + vec = Cnf.FindVector("Test::Vector"); + equals(vec.size(), 3); + equals(vec[0], "baz"); + equals(vec[1], "bob"); + equals(vec[2], "dob"); + vec = Cnf.FindVector("Test::Vector", "foo,bar"); + equals(vec.size(), 3); + equals(vec[0], "baz"); + equals(vec[1], "bob"); + equals(vec[2], "dob"); + Cnf.Set("Test::Vector", "abel,bravo"); + vec = Cnf.FindVector("Test::Vector", "foo,bar"); + equals(vec.size(), 2); + equals(vec[0], "abel"); + equals(vec[1], "bravo"); //FIXME: Test for configuration file parsing; // currently only integration/ tests test them implicitly diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc index cef89bde6..51cfecee3 100644 --- a/test/libapt/getlanguages_test.cc +++ b/test/libapt/getlanguages_test.cc @@ -105,6 +105,14 @@ int main(int argc,char *argv[]) vec = APT::Configuration::getLanguages(false, false, env); equals(vec.size(), 1); equals(vec[0], "fr"); + + _config->Set("Acquire::Languages", "environment,en"); + env[0] = "de_DE.UTF-8"; + vec = APT::Configuration::getLanguages(false, false, env); + equals(vec.size(), 3); + equals(vec[0], "de_DE"); + equals(vec[1], "de"); + equals(vec[2], "en"); _config->Set("Acquire::Languages", ""); _config->Set("Acquire::Languages::1", "environment"); |