forked from DCMTK/dcmtk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.cc
69 lines (57 loc) · 1.21 KB
/
list.cc
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
69
/*
* Copyright (C) 2017, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
*
* OFFIS e.V.
* R&D Division Health
* Escherweg 2
* D-26121 Oldenburg, Germany
*
*
* Module: config
*
* Author: Thorben Hasenpusch
*
* Purpose: Rudimentary tests for a working <list> implementation.
*/
#include <list>
int main()
{
std::list<int> l;
if (!l.empty()) {
return -1;
}
l.push_back(18);
l.push_back(22);
l.push_front(2);
if (*l.begin() != 2) {
return -1;
}
l.reverse();
if (*l.begin() != 22) {
return -1;
}
int sum = 0;
for (std::list<int>::iterator it = l.begin(); it != l.end(); ++it) {
sum += *it;
}
if (sum != 42) {
return -1;
}
// ensure iterators are NOT invalidated by swap()
std::list<int>::iterator it = l.begin();
std::list<int> m;
m.push_back(23);
l.swap(m);
if (it != m.begin()) {
return -1;
}
// test whether we can compare const and mutable iterators
std::list<int>::const_iterator cit = m.begin();
if (it != cit) {
return -1;
}
return 0;
}