Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
iter-stack-test.cpp
Go to the documentation of this file.
1/*
2 IterStack(Test) - verify stack-like iterator
3
4 Copyright (C)
5 2012, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
20#include "lib/test/run.hpp"
22#include "lib/util.hpp"
23
24#include "lib/iter-stack.hpp"
25
26
27
28namespace lib {
29namespace test{
30
31 using ::Test;
32 using util::isnil;
33 using LERR_(ITER_EXHAUST);
34
35
36
37
39
40
41
42
43 /*****************************************************************/
54 class IterStack_test : public Test
55 {
56
57 virtual void
58 run (Arg)
59 {
60 IStack stack;
61 CHECK (isnil (stack));
62
63 VERIFY_ERROR (ITER_EXHAUST, *stack );
64 VERIFY_ERROR (ITER_EXHAUST, ++stack );
65
66 stack.push (1);
67 stack.push (3);
68 stack.push (5);
69 stack.push (7);
70 stack.push (9);
71
72 CHECK (!isnil (stack));
73 CHECK (9 == *stack);
74
75 ++stack;
76 CHECK (7 == *stack);
77
78 CHECK (7 == stack.pop());
79 CHECK (5 == *stack);
80
81 ++++stack;
82 CHECK (1 == *stack);
83 CHECK (1 == stack.pop());
84
85 CHECK (isnil (stack));
86 VERIFY_ERROR (ITER_EXHAUST, *stack );
87 VERIFY_ERROR (ITER_EXHAUST, ++stack );
88 VERIFY_ERROR (ITER_EXHAUST, stack.pop() );
89
90
91 stack.push(23);
92 CHECK (23 == *stack);
93
94 int i = stack.pop();
95 CHECK (i == 23);
96 VERIFY_ERROR (ITER_EXHAUST, *stack );
97 CHECK (isnil (stack));
98 }
99
100 };
101
102
103 LAUNCHER (IterStack_test, "unit common");
104
105
106}} // namespace lib::test
#define LERR_(_NAME_)
Definition error.hpp:45
Conveniently iterable stack and queue containers.
IterStack< int > IStack
Implementation namespace for support and library code.
Test runner and basic definitions for tests.
bool isnil(lib::time::Duration const &dur)
Simplistic test class runner.
#define LAUNCHER(_TEST_CLASS_, _GROUPS_)
Definition run.hpp:116
A Stack which can be popped by iterating.
A collection of frequently used helper functions to support unit testing.
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT)
Macro to verify that a statement indeed raises an exception.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...