wibble
1.1
wibble
consumer.test.h
Go to the documentation of this file.
1
// -*- C++ -*- (c) 2006 Petr Rockai <me@mornfall.net>
2
3
#include <
wibble/consumer.h
>
4
#include <
wibble/operators.h
>
5
#include <list>
6
7
namespace
{
8
9
using namespace
wibble::operators
;
10
using namespace
wibble
;
11
12
struct
TestConsumer {
13
Test
stlInserterConsumer() {
14
std::list<int> a;
15
a.push_back( 10 );
16
a.push_back( 20 );
17
Range< int >
r =
range
( a.begin(), a.end() );
18
std::list<int> b;
19
assert
( a != b );
20
Consumer< int >
c =
consumer
( back_inserter( b ) );
21
std::copy( r.begin(), r.end(), c );
22
assert
( a == b );
23
}
24
25
Test
stlSetConsumer() {
26
std::set< int > s;
27
Consumer< int >
c =
consumer
( s );
28
c.
consume
( 1 );
29
assert
( *s.begin() == 1 );
30
assert
( s.begin() + 1 == s.end() );
31
}
32
33
Test
stlVectorConsumer() {
34
std::vector< int > v;
35
Consumer< int >
c =
consumer
( v );
36
c.
consume
( 2 );
37
c.
consume
( 1 );
38
assert
( *v.begin() == 2 );
39
assert
( *(v.begin() + 1) == 1 );
40
assert
( (v.begin() + 2) == v.end() );
41
}
42
43
};
44
45
}
wibble::Range
Definition:
range.h:20
wibble::consumer
Consumer< typename Out::container_type::value_type > consumer(Out out)
Definition:
consumer.h:108
wibble::Consumer
Definition:
consumer.h:17
wibble::Consumer::consume
void consume(const T &a)
Definition:
consumer.h:78
consumer.h
-*- C++ -*-
wibble
Definition:
amorph.h:17
wibble::operators
Definition:
operators.h:12
wibble::range
Range< typename In::value_type > range(In b, In e)
Definition:
range.h:264
Test
void Test
Definition:
test.h:178
operators.h
assert
#define assert(x)
Definition:
test.h:30
Generated by
1.8.17