]> git.saurik.com Git - apt.git/blobdiff - test/libapt/configuration_test.cc
add default and override handling for Cnf::FindVector
[apt.git] / test / libapt / configuration_test.cc
index 5b23d17fbefafd8a28010c3cad59539ffb5c4747..957e905d5eb66159921a58ceca4e845da9472a92 100644 (file)
@@ -71,6 +71,65 @@ int main(int argc,const char *argv[]) {
        equals(Cnf.Find("APT2::Version", "33"), "33");
        equals(Cnf.FindI("APT2::Version", 33), 33);
 
        equals(Cnf.Find("APT2::Version", "33"), "33");
        equals(Cnf.FindI("APT2::Version", 33), 33);
 
+       equals(Cnf.FindFile("Dir::State"), "");
+       equals(Cnf.FindFile("Dir::Aptitude::State"), "");
+       Cnf.Set("Dir", "/srv/sid");
+       equals(Cnf.FindFile("Dir::State"), "");
+       Cnf.Set("Dir::State", "var/lib/apt");
+       Cnf.Set("Dir::Aptitude::State", "var/lib/aptitude");
+       equals(Cnf.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
+       equals(Cnf.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
+
+       Cnf.Set("RootDir", "/");
+       equals(Cnf.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
+       equals(Cnf.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
+       Cnf.Set("RootDir", "//./////.////");
+       equals(Cnf.FindFile("Dir::State"), "/srv/sid/var/lib/apt");
+       equals(Cnf.FindFile("Dir::Aptitude::State"), "/srv/sid/var/lib/aptitude");
+       Cnf.Set("RootDir", "/rootdir");
+       equals(Cnf.FindFile("Dir::State"), "/rootdir/srv/sid/var/lib/apt");
+       equals(Cnf.FindFile("Dir::Aptitude::State"), "/rootdir/srv/sid/var/lib/aptitude");
+       Cnf.Set("RootDir", "/rootdir/");
+       equals(Cnf.FindFile("Dir::State"), "/rootdir/srv/sid/var/lib/apt");
+       equals(Cnf.FindFile("Dir::Aptitude::State"), "/rootdir/srv/sid/var/lib/aptitude");
+
+       Cnf.Set("Dir::State", "/dev/null");
+       Cnf.Set("Dir::State::lists", "lists/");
+       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"), "");
+
+       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
 
        //FIXME: Test for configuration file parsing;
        // currently only integration/ tests test them implicitly