Lolly
1.4.28
Loading...
Searching...
No Matches
tests
Kernel
Containers
ntuple_test.cpp
Go to the documentation of this file.
1
#include "
a_lolly_test.hpp
"
2
#include "
ntuple.hpp
"
3
#include "
string.hpp
"
4
#include "
tm_ostream.hpp
"
5
6
bool
7
test_same
(
tm_ostream
& a,
string
b
) {
8
string
sa
= a.
unbuffer
();
9
return
sa
==
b
;
10
}
11
12
TEST_CASE
(
"test pair"
) {
13
pair<int, int>
p1
(1, 2);
14
pair<int, int>
p2
(1, 2);
15
CHECK
(
p1
==
p2
);
16
CHECK
(
p1
.x1 == 1);
17
CHECK
(
p1
.x2 == 2);
18
CHECK
(
p1
!=
pair<int, int>
(1, 3));
19
CHECK
(
p1
!=
pair<int, int>
(2, 2));
20
CHECK
(
hash
(
p1
) ==
hash
(
p2
));
21
tm_ostream
out1
;
22
out1
.buffer ();
23
out1
<<
p1
;
24
CHECK
(
test_same
(
out1
,
"[ 1, 2 ]"
));
25
}
26
27
TEST_CASE
(
"test triple"
) {
28
triple<int, int, int>
t1
(1, 2, 3);
29
triple<int, int, int>
t2
(1, 2, 3);
30
CHECK
(
t1
==
t2
);
31
CHECK
(
t1
.x1 == 1);
32
CHECK
(
t1
.x2 == 2);
33
CHECK
(
t1
.x3 == 3);
34
CHECK
(
t1
!=
triple<int, int, int>
(1, 2, 4));
35
CHECK
(
t1
!=
triple<int, int, int>
(1, 3, 3));
36
CHECK
(
t1
!=
triple<int, int, int>
(2, 3, 4));
37
CHECK
(
hash
(
t1
) ==
hash
(
t2
));
38
tm_ostream
out1
;
39
out1
.buffer ();
40
out1
<<
t1
;
41
CHECK
(
test_same
(
out1
,
"[ 1, 2, 3 ]"
));
42
}
43
44
TEST_CASE
(
"test quadruple"
) {
45
quartet<int, int, int, int>
q1
(1, 2, 3, 4);
46
quartet<int, int, int, int>
q2
(1, 2, 3, 4);
47
CHECK
(
q1
==
q2
);
48
CHECK
(
q1
.x1 == 1);
49
CHECK
(
q1
.x2 == 2);
50
CHECK
(
q1
.x3 == 3);
51
CHECK
(
q1
.x4 == 4);
52
CHECK
(
q1
!=
quartet<int, int, int, int>
(1, 2, 3, 5));
53
CHECK
(
q1
!=
quartet<int, int, int, int>
(1, 2, 4, 4));
54
CHECK
(
q1
!=
quartet<int, int, int, int>
(2, 3, 4, 5));
55
CHECK
(
hash
(
q1
) ==
hash
(
q2
));
56
tm_ostream
out1
;
57
out1
.buffer ();
58
out1
<<
q1
;
59
CHECK
(
test_same
(
out1
,
"[ 1, 2, 3, 4 ]"
));
60
}
61
62
TEST_CASE
(
"test quintuple"
) {
63
quintuple<int, int, int, int, int>
q1
(1, 2, 3, 4, 5);
64
quintuple<int, int, int, int, int>
q2
(1, 2, 3, 4, 5);
65
CHECK
(
q1
==
q2
);
66
CHECK
(
q1
.x1 == 1);
67
CHECK
(
q1
.x2 == 2);
68
CHECK
(
q1
.x3 == 3);
69
CHECK
(
q1
.x4 == 4);
70
CHECK
(
q1
.x5 == 5);
71
CHECK
(
q1
!=
quintuple<int, int, int, int, int>
(1, 2, 3, 4, 6));
72
CHECK
(
q1
!=
quintuple<int, int, int, int, int>
(1, 2, 3, 5, 5));
73
CHECK
(
q1
!=
quintuple<int, int, int, int, int>
(2, 3, 4, 5, 6));
74
CHECK
(
hash
(
q1
) ==
hash
(
q2
));
75
tm_ostream
out1
;
76
out1
.buffer ();
77
out1
<<
q1
;
78
CHECK
(
test_same
(
out1
,
"[ 1, 2, 3, 4, 5 ]"
));
79
}
80
81
TEST_CASE
(
"test sextuple"
) {
82
sextuple<int, int, int, int, int, int>
s1
(1, 2, 3, 4, 5, 6);
83
sextuple<int, int, int, int, int, int>
s2
(1, 2, 3, 4, 5, 6);
84
CHECK
(
s1
==
s2
);
85
CHECK
(
s1
.x1 == 1);
86
CHECK
(
s1
.x2 == 2);
87
CHECK
(
s1
.x3 == 3);
88
CHECK
(
s1
.x4 == 4);
89
CHECK
(
s1
.x5 == 5);
90
CHECK
(
s1
.x6 == 6);
91
CHECK
(
s1
!=
sextuple<int, int, int, int, int, int>
(1, 2, 3, 4, 5, 7));
92
CHECK
(
s1
!=
sextuple<int, int, int, int, int, int>
(1, 2, 3, 4, 6, 6));
93
CHECK
(
s1
!=
sextuple<int, int, int, int, int, int>
(2, 3, 4, 5, 6, 7));
94
CHECK
(
hash
(
s1
) ==
hash
(
s2
));
95
tm_ostream
out1
;
96
out1
.buffer ();
97
out1
<<
s1
;
98
CHECK
(
test_same
(
out1
,
"[ 1, 2, 3, 4, 5, 6 ]"
));
99
}
a_lolly_test.hpp
hash
int hash(pointer ptr)
Computes a hash value for a pointer.
Definition
basic.cpp:17
t1
blackbox t1
Definition
blackbox_test.cpp:27
t2
blackbox t2
Definition
blackbox_test.cpp:28
b
blackbox b[13]
Definition
blackbox_test.cpp:41
list
The list class represents a linked list.
Definition
list.hpp:48
tm_ostream
Definition
tm_ostream.hpp:36
tm_ostream::unbuffer
string unbuffer()
Definition
tm_ostream.cpp:198
ntuple.hpp
test_same
bool test_same(tm_ostream &a, string b)
Definition
ntuple_test.cpp:7
TEST_CASE
TEST_CASE("test for operator+= and advance()")
Definition
parse_string_test.cpp:85
string.hpp
tm_ostream.hpp
Generated by
1.10.0