wibble
1.1
Main Page
Namespaces
Classes
Files
File List
File Members
wibble
mixin.test.h
Go to the documentation of this file.
1
// -*- C++ -*- (c) 2007 Petr Rockai <me@mornfall.net>
2
3
#include <
wibble/test.h
>
4
#include <
wibble/mixin.h
>
5
#include <vector>
6
7
namespace
{
8
9
using namespace
std;
10
11
class
Integer :
public
wibble::mixin::Comparable
<Integer>
12
{
13
int
val;
14
public
:
15
Integer(
int
val) : val(val) {}
16
bool
operator<=
(
const
Integer& o )
const
{
return
val <= o.val; }
17
};
18
19
class
Discard :
public
wibble::mixin::OutputIterator
<Discard>
20
{
21
public
:
22
Discard& operator=(
const
int
&)
23
{
24
return
*
this
;
25
}
26
};
27
28
struct
TestMixin {
29
30
// Test Comparable mixin
31
Test
comparable() {
32
Integer i10(10);
33
Integer i10a(10);
34
Integer i20(20);
35
36
// Test the base method first
37
assert
(i10 <= i10a);
38
assert
(i10a <= i10);
39
assert
(i10 <= i20);
40
assert
(! (i20 <= i10));
41
42
// Test the other methods
43
assert
(i10 != i20);
44
assert
(!(i10 != i10a));
45
46
assert
(i10 == i10a);
47
assert
(!(i10 == i20));
48
49
assert
(i10 < i20);
50
assert
(!(i20 < i10));
51
assert
(!(i10 < i10a));
52
53
assert
(i20 > i10);
54
assert
(!(i10 > i20));
55
assert
(!(i10 > i10a));
56
57
assert
(i10 >= i10a);
58
assert
(i10a >= i10);
59
assert
(i20 >= i10);
60
assert
(! (i10 >= i20));
61
}
62
63
Test
output
() {
64
vector<int> data;
65
data.push_back(1);
66
data.push_back(2);
67
data.push_back(3);
68
69
std::copy(data.begin(), data.end(), Discard());
70
}
71
72
};
73
74
}
Generated on Wed Oct 23 2013 17:14:25 for wibble by
1.8.4