summaryrefslogtreecommitdiff
path: root/test/libapt/commandline_test.cc
blob: d8c5bc5bd6b3b081e91c06cd63cd06a30fb88d29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <config.h>

#include <apt-pkg/cmndline.h>
#include <apt-pkg/configuration.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;
}