File: core.test.h

package info (click to toggle)
libwibble 0.1.19
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 832 kB
  • ctags: 1,940
  • sloc: cpp: 9,798; makefile: 163; perl: 84; sh: 11
file content (50 lines) | stat: -rw-r--r-- 1,426 bytes parent folder | download | duplicates (5)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* -*- C++ -*- (c) 2007 Petr Rockai <me@mornfall.net>
               (c) 2007 Enrico Zini <enrico@enricozini.org> */

#include <wibble/commandline/core.h>

#include <wibble/test.h>

using namespace wibble::commandline;

struct TestCommandlineCore {

    Test isSwitch() {
        assert_eq(ArgList::isSwitch("-a"), true);
        assert_eq(ArgList::isSwitch("-afdg"), true);
        assert_eq(ArgList::isSwitch("--antani"), true);
        assert_eq(ArgList::isSwitch("--antani-blinda"), true);
        assert_eq(ArgList::isSwitch("-"), false);
        assert_eq(ArgList::isSwitch("--"), false);
        assert_eq(ArgList::isSwitch("antani"), false);
        assert_eq(ArgList::isSwitch("a-ntani"), false);
        assert_eq(ArgList::isSwitch("a--ntani"), false);
    }

    Test eraseAndAdvance()
    {
        ArgList list;
        list.push_back("1");
        list.push_back("2");
        list.push_back("3");
     
        ArgList::iterator begin = list.begin();
        assert_eq(list.size(), 3u);
     
        list.eraseAndAdvance(begin);
        assert(begin == list.begin());
        assert_eq(list.size(), 2u);
     
        list.eraseAndAdvance(begin);
        assert(begin == list.begin());
        assert_eq(list.size(), 1u);
     
        list.eraseAndAdvance(begin);
        assert(begin == list.begin());
        assert_eq(list.size(), 0u);
        assert(begin == list.end());
    }

};

// vim:set ts=4 sw=4: