summaryrefslogtreecommitdiff
path: root/test/libapt
diff options
context:
space:
mode:
authorMichael Vogt <egon@debian-devbox>2012-06-11 14:56:11 +0200
committerMichael Vogt <egon@debian-devbox>2012-06-11 14:56:11 +0200
commitcb6a5776bfb5f74d94f32db55f2de148c27a5d10 (patch)
tree3c8f8bcaeefb9e51bff8476b262de18b4b39b11b /test/libapt
parent563fd891d80feedefd812aad83844e2189870e2c (diff)
parent249a02f55a2b311fc130efe3b3a99995b6a71360 (diff)
merged from donkult
Diffstat (limited to 'test/libapt')
-rw-r--r--test/libapt/commandline_test.cc32
-rw-r--r--test/libapt/getlanguages_test.cc6
-rw-r--r--test/libapt/makefile6
3 files changed, 42 insertions, 2 deletions
diff --git a/test/libapt/commandline_test.cc b/test/libapt/commandline_test.cc
new file mode 100644
index 000000000..de8a30bd6
--- /dev/null
+++ b/test/libapt/commandline_test.cc
@@ -0,0 +1,32 @@
+#include <apt-pkg/cmndline.h>
+
+#include "assert.h"
+
+int main()
+{
+ CommandLine::Args Args[] = {
+ { 't', 0, "Test::Worked", 0 },
+ { 'z', "zero", "Test::Zero", 0 },
+ {0,0,0,0}
+ };
+ CommandLine CmdL(Args,_config);
+
+ char const * argv[] = { "test", "--zero", "-t" };
+ CmdL.Parse(3 , argv);
+ equals(true, _config->FindB("Test::Worked", false));
+ equals(true, _config->FindB("Test::Zero", false));
+
+ _config->Clear("Test");
+ equals(false, _config->FindB("Test::Worked", false));
+ equals(false, _config->FindB("Test::Zero", false));
+
+ _config->Set("Test::Zero", true);
+ equals(true, _config->FindB("Test::Zero", false));
+
+ char const * argv2[] = { "test", "--no-zero", "-t" };
+ CmdL.Parse(3 , argv2);
+ equals(true, _config->FindB("Test::Worked", false));
+ equals(false, _config->FindB("Test::Zero", false));
+
+ return 0;
+}
diff --git a/test/libapt/getlanguages_test.cc b/test/libapt/getlanguages_test.cc
index 274cf4aa4..cef89bde6 100644
--- a/test/libapt/getlanguages_test.cc
+++ b/test/libapt/getlanguages_test.cc
@@ -144,7 +144,8 @@ int main(int argc,char *argv[])
_config->Set("Acquire::Languages", "none");
vec = APT::Configuration::getLanguages(true, false, env);
- equals(vec.size(), 0);
+ equals(vec.size(), 1);
+ equals(vec[0], "none");
_config->Set("Acquire::Languages", "");
_config->Set("Dir::State::lists", "/non-existing-dir");
@@ -168,7 +169,8 @@ int main(int argc,char *argv[])
_config->Set("Acquire::Languages", "none");
env[0] = "de_DE.UTF-8";
vec = APT::Configuration::getLanguages(true, false, env);
- equals(vec.size(), 0);
+ equals(vec.size(), 1);
+ equals(vec[0], "none");
_config->Set("Acquire::Languages", "");
//FIXME: Remove support for this deprecated setting
diff --git a/test/libapt/makefile b/test/libapt/makefile
index 1952051e2..b2e6db2dd 100644
--- a/test/libapt/makefile
+++ b/test/libapt/makefile
@@ -34,6 +34,12 @@ SOURCE = getlistoffilesindir_test.cc
include $(PROGRAM_H)
# Program for testing CommandLine reconstruction
+PROGRAM = Commandline${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = commandline_test.cc
+include $(PROGRAM_H)
+
+# Program for testing CommandLine reconstruction
PROGRAM = CommandlineAsString${BASENAME}
SLIBS = -lapt-pkg
SOURCE = commandlineasstring_test.cc