Lolly 1.4.28
Loading...
Searching...
No Matches
Functions
ntuple_test.cpp File Reference
#include "a_lolly_test.hpp"
#include "ntuple.hpp"
#include "string.hpp"
#include "tm_ostream.hpp"
Include dependency graph for ntuple_test.cpp:

Go to the source code of this file.

Functions

bool test_same (tm_ostream &a, string b)
 
 TEST_CASE ("test pair")
 
 TEST_CASE ("test triple")
 
 TEST_CASE ("test quadruple")
 
 TEST_CASE ("test quintuple")
 
 TEST_CASE ("test sextuple")
 

Function Documentation

◆ test_same()

bool test_same ( tm_ostream & a,
string b )

Definition at line 7 of file ntuple_test.cpp.

7 {
8 string sa= a.unbuffer ();
9 return sa == b;
10}
blackbox b[13]
The list class represents a linked list.
Definition list.hpp:48
string unbuffer()

◆ TEST_CASE() [1/5]

TEST_CASE ( "test pair" )

Definition at line 12 of file ntuple_test.cpp.

12 {
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));
22 out1.buffer ();
23 out1 << p1;
24 CHECK (test_same (out1, "[ 1, 2 ]"));
25}
int hash(pointer ptr)
Computes a hash value for a pointer.
Definition basic.cpp:17
bool test_same(tm_ostream &a, string b)

◆ TEST_CASE() [2/5]

TEST_CASE ( "test triple" )

Definition at line 27 of file ntuple_test.cpp.

27 {
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));
39 out1.buffer ();
40 out1 << t1;
41 CHECK (test_same (out1, "[ 1, 2, 3 ]"));
42}
blackbox t1
blackbox t2

◆ TEST_CASE() [3/5]

TEST_CASE ( "test quadruple" )

Definition at line 44 of file ntuple_test.cpp.

44 {
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));
57 out1.buffer ();
58 out1 << q1;
59 CHECK (test_same (out1, "[ 1, 2, 3, 4 ]"));
60}

◆ TEST_CASE() [4/5]

TEST_CASE ( "test quintuple" )

Definition at line 62 of file ntuple_test.cpp.

62 {
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));
76 out1.buffer ();
77 out1 << q1;
78 CHECK (test_same (out1, "[ 1, 2, 3, 4, 5 ]"));
79}

◆ TEST_CASE() [5/5]

TEST_CASE ( "test sextuple" )

Definition at line 81 of file ntuple_test.cpp.

81 {
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));
96 out1.buffer ();
97 out1 << s1;
98 CHECK (test_same (out1, "[ 1, 2, 3, 4, 5, 6 ]"));
99}