core.test.h
Go to the documentation of this file.
/* -*- 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:
wibble::iterator
Iterator< typename I::value_type > iterator(I i)
Definition: iterator.h:123
wibble::commandline::ArgList::isSwitch
static bool isSwitch(const char *str)
Definition: core.cpp:36
wibble::commandline
Definition: core.cpp:6
Test
void Test
Definition: test.h:178
test.h
core.h
wibble::list::begin
ListIterator< List > begin(List l)
Definition: list.h:420
assert_eq
#define assert_eq(x, y)
Definition: test.h:33
assert
#define assert(x)
Definition: test.h:30
TestCommandlineCore::eraseAndAdvance
Test eraseAndAdvance()
Definition: core.test.h:24
wibble::commandline::ArgList
Definition: core.h:29
TestCommandlineCore::isSwitch
Test isSwitch()
Definition: core.test.h:12
wibble::commandline::ArgList::eraseAndAdvance
iterator & eraseAndAdvance(iterator &i)
Definition: core.h:34
TestCommandlineCore
Definition: core.test.h:10