File: test_commandline_core.cpp

package info (click to toggle)
libwibble 0.1.9
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 500 kB
  • ctags: 1,183
  • sloc: cpp: 5,760; sh: 113; makefile: 71
file content (58 lines) | stat: -rw-r--r-- 1,319 bytes parent folder | download
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
51
52
53
54
55
56
57
58
#include <wibble/config.h>
#include <wibble/commandline/core.h>

#include <wibble/tests/tut-wibble.h>

namespace tut {

struct commandline_core_shar {
};

TESTGRP( commandline_core );

using namespace wibble::commandline;

// Test isSwitch
template<> template<>
void to::test<1>()
{
	ensure_equals(ArgList::isSwitch("-a"), true);
	ensure_equals(ArgList::isSwitch("-afdg"), true);
	ensure_equals(ArgList::isSwitch("--antani"), true);
	ensure_equals(ArgList::isSwitch("--antani-blinda"), true);
	ensure_equals(ArgList::isSwitch("-"), false);
	ensure_equals(ArgList::isSwitch("--"), false);
	ensure_equals(ArgList::isSwitch("antani"), false);
	ensure_equals(ArgList::isSwitch("a-ntani"), false);
	ensure_equals(ArgList::isSwitch("a--ntani"), false);
}

// Test eraseAndAdvance
template<> template<>
void to::test<2>()
{
	ArgList list;
	list.push_back("1");
	list.push_back("2");
	list.push_back("3");

	ArgList::iterator begin = list.begin();
	ensure_equals(list.size(), 3u);

	list.eraseAndAdvance(begin);
	ensure(begin == list.begin());
	ensure_equals(list.size(), 2u);

	list.eraseAndAdvance(begin);
	ensure(begin == list.begin());
	ensure_equals(list.size(), 1u);

	list.eraseAndAdvance(begin);
	ensure(begin == list.begin());
	ensure_equals(list.size(), 0u);
	ensure(begin == list.end());
}

}

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