wibble 1.1
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
7namespace {
8
9using namespace wibble::operators;
10using namespace wibble;
11
12struct TestConsumer {
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 );
21 std::copy( r.begin(), r.end(), c );
22 assert( a == b );
23 }
24
26 std::set< int > s;
28 c.consume( 1 );
29 assert( *s.begin() == 1 );
30 assert( s.begin() + 1 == s.end() );
31 }
32
34 std::vector< int > 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}
-*- C++ -*-
Definition operators.h:12
Definition amorph.h:17
Range< typename In::value_type > range(In b, In e)
Definition range.h:264
Consumer< typename Out::container_type::value_type > consumer(Out out)
Definition consumer.h:108
Definition amorph.h:30
#define assert(x)
Definition test.h:30