summaryrefslogtreecommitdiff
path: root/test/libapt/commandline_test.cc
diff options
context:
space:
mode:
authorSteve Langasek <steve.langasek@canonical.com>2012-06-11 15:13:24 -0700
committerSteve Langasek <steve.langasek@canonical.com>2012-06-11 15:13:24 -0700
commit825098c2740b2d5ebea0c16c43685f55da201315 (patch)
treeb3a43f792cca021a79f541a9454e0223e4dca9cb /test/libapt/commandline_test.cc
parent310ed3c13d5cfd2a3c46741539f652d69bda5d30 (diff)
parente08c5854bb9b5f352b0856533f95c12e858728ca (diff)
Merge version 0.9.6 from Debian
Diffstat (limited to 'test/libapt/commandline_test.cc')
-rw-r--r--test/libapt/commandline_test.cc32
1 files changed, 32 insertions, 0 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;
+}