aboutsummaryrefslogtreecommitdiff
path: root/src/unit/list.unit
blob: 9da03428da6ce664c60726d09c095afd45d6e289 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// vim: syntax=cpp
/*
 * Copyright (C) 2007-2008 Xagasoft, All rights reserved.
 *
 * This file is part of the libbu++ library and is released under the
 * terms of the license contained in the file LICENSE.
 */

#include "bu/fstring.h"
#include "bu/list.h"

typedef Bu::List<int> IntList;

{=Init}

{%append}
{
	IntList lst;
	for( int j = 0; j < 50; j++ )
	{
		lst.append( j );
	}
	int j = 0;
	for( IntList::iterator i = lst.begin(); i; i++, j++ )
	{
		unitTest( *i == j );
	}
}

{%prepend}
{
	IntList lst;
	for( int j = 0; j < 50; j++ )
	{
		lst.prepend( j );
	}
	int j = 49;
	for( IntList::iterator i = lst.begin(); i; i++, j-- )
	{
		unitTest( *i == j );
	}
}

{%copy}
{
	IntList lst;
	int j;
	for( j = 0; j < 50; j++ )
	{
		lst.append( j );
	}
	IntList lst2 = lst;

	j = 0;
	for( IntList::iterator i = lst2.begin(); i; i++, j++ )
	{
		unitTest( *i == j );
	}
	lst2.clear();
	lst2 = lst;

	j = 0;
	for( IntList::iterator i = lst2.begin(); i; i++, j++ )
	{
		unitTest( *i == j );
	}
}