Lolly 1.4.27
Loading...
Searching...
No Matches
Functions | Variables
blackbox_test.cpp File Reference
#include "a_lolly_test.hpp"
#include "blackbox.hpp"
#include "string.hpp"
#include <climits>
Include dependency graph for blackbox_test.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("test for get_type() and open_box()")
 
 TEST_CASE ("test for equal(), operator== and operator!=")
 
 TEST_CASE ("Test fot display() and operator<<")
 

Variables

blackbox b0
 
blackbox b1 = close_box<SI> (-2147483648)
 
blackbox b2 = close_box<SN> (2147483647)
 
blackbox b3 = close_box<HI> (-32768)
 
blackbox b4 = close_box<HN> (32767)
 
blackbox b5 = close_box<QI> ('`')
 
blackbox b6 = close_box<QN> (255)
 
blackbox b7 = close_box<DI> (LLONG_MAX)
 
blackbox b8 = close_box<DN> (ULLONG_MAX)
 
blackbox b9 = close_box<pointer> (nullptr)
 
blackbox b10 = close_box<float> (3.14)
 
blackbox b11 = close_box<double> (3.14159265)
 
blackbox b12 = close_box<long double> (3.1415926535)
 
blackbox t0
 
blackbox t1 = close_box<SI> (1234)
 
blackbox t2 = close_box<SN> (5678)
 
blackbox t3 = close_box<HI> (123)
 
blackbox t4 = close_box<HN> (234)
 
blackbox t5 = close_box<QI> ('t')
 
blackbox t6 = close_box<QN> (23)
 
blackbox t7 = close_box<DI> (5678)
 
blackbox t8 = close_box<DN> (0)
 
blackbox t9 = close_box<pointer> (nullptr)
 
blackbox t10 = close_box<float> (0.0)
 
blackbox t11 = close_box<double> (8.567)
 
blackbox t12 = close_box<long double> (7.345)
 
blackbox t [13] = {t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12}
 
blackbox b [13] = {b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12}
 
string bout [13]
 
string tout [13]
 

Detailed Description

A unitest for blackbox.

Author
YuanYe
Date
2023

Definition in file blackbox_test.cpp.

Function Documentation

◆ TEST_CASE() [1/3]

TEST_CASE ( "test for get_type() and open_box()" )

Definition at line 69 of file blackbox_test.cpp.

69 {
70 CHECK (open_box<SI> (b1) == -2147483648);
71 CHECK (open_box<SN> (b2) == 2147483647);
72 CHECK (open_box<HI> (b3) == -32768);
73 CHECK (open_box<HN> (b4) == 32767);
74 CHECK (open_box<QI> (b5) == '`');
75 CHECK (open_box<QN> (b6) == 255);
78 CHECK (open_box<pointer> (b9) == nullptr);
79 CHECK (open_box<float> (b10) == (float) 3.14);
80 CHECK (open_box<double> (b11) == 3.14159265);
81 CHECK (open_box<long double> (b12) == 3.1415926535);
82
83 CHECK (open_box<SI> (t1) == 1234);
84 CHECK (open_box<SN> (t2) == 5678);
85 CHECK (open_box<HI> (t3) == 123);
86 CHECK (open_box<HN> (t4) == 234);
87 CHECK (open_box<QI> (t5) == 't');
88 CHECK (open_box<QN> (t6) == 23);
89 CHECK (open_box<DI> (t7) == 5678);
90 CHECK (open_box<DN> (t8) == 0);
91 CHECK (open_box<pointer> (t9) == nullptr);
92 CHECK (open_box<float> (t10) == 0.0);
93 CHECK (open_box<double> (t11) == 8.567);
94 CHECK (open_box<long double> (t12) == 7.345);
95 // If the incoming template type does not match, an exception will be thrown.
96}
blackbox b12
blackbox t1
blackbox t5
blackbox b1
blackbox t3
blackbox b4
blackbox t9
blackbox t8
blackbox b9
blackbox t7
blackbox t2
blackbox t11
blackbox b10
blackbox t6
blackbox t10
blackbox t12
blackbox b2
blackbox b5
blackbox t4
blackbox b3
blackbox b11
blackbox b8
blackbox b7
blackbox b6
The list class represents a linked list.
Definition list.hpp:48

◆ TEST_CASE() [2/3]

TEST_CASE ( "test for equal())

Definition at line 98 of file blackbox_test.cpp.

98 {
99 SUBCASE ("test for operator==") {
100 for (int i= 0; i < 13; i++) {
101 CHECK_EQ (t[i] == t[i], true);
102 }
103 }
104
105 SUBCASE ("test for operator!=") {
106 for (int i= 0; i < 13; i++) {
107 if (i != 0 && i != 9) CHECK_EQ (b[i] != t[i], true);
108 }
109 }
110}
blackbox b[13]
blackbox t[13]

◆ TEST_CASE() [3/3]

TEST_CASE ( "Test fot display() and operator<<" )

Definition at line 112 of file blackbox_test.cpp.

112 {
113 tm_ostream out;
114 string str;
115 for (int i= 0; i < 13; i++) {
116 out.buffer ();
117 out << b[i];
118 str= out.unbuffer ();
119 CHECK_EQ (str != tout[i], true);
120 if (i != 0) CHECK_EQ (str == bout[i], true);
121 else CHECK_EQ (str != bout[i], true);
122 }
123}
string bout[13]
string tout[13]
string unbuffer()
void buffer()

Variable Documentation

◆ b0

Definition at line 12 of file blackbox_test.cpp.

◆ b1

blackbox b1 = close_box<SI> (-2147483648)

Definition at line 13 of file blackbox_test.cpp.

◆ b2

blackbox b2 = close_box<SN> (2147483647)

Definition at line 14 of file blackbox_test.cpp.

◆ b3

blackbox b3 = close_box<HI> (-32768)

Definition at line 15 of file blackbox_test.cpp.

◆ b4

blackbox b4 = close_box<HN> (32767)

Definition at line 16 of file blackbox_test.cpp.

◆ b5

blackbox b5 = close_box<QI> ('`')

Definition at line 17 of file blackbox_test.cpp.

◆ b6

blackbox b6 = close_box<QN> (255)

Definition at line 18 of file blackbox_test.cpp.

◆ b7

Definition at line 19 of file blackbox_test.cpp.

◆ b8

Definition at line 20 of file blackbox_test.cpp.

◆ b9

Definition at line 21 of file blackbox_test.cpp.

◆ b10

blackbox b10 = close_box<float> (3.14)

Definition at line 22 of file blackbox_test.cpp.

◆ b11

blackbox b11 = close_box<double> (3.14159265)

Definition at line 23 of file blackbox_test.cpp.

◆ b12

blackbox b12 = close_box<long double> (3.1415926535)

Definition at line 24 of file blackbox_test.cpp.

◆ t0

Definition at line 26 of file blackbox_test.cpp.

◆ t1

blackbox t1 = close_box<SI> (1234)

Definition at line 27 of file blackbox_test.cpp.

◆ t2

blackbox t2 = close_box<SN> (5678)

Definition at line 28 of file blackbox_test.cpp.

◆ t3

blackbox t3 = close_box<HI> (123)

Definition at line 29 of file blackbox_test.cpp.

◆ t4

blackbox t4 = close_box<HN> (234)

Definition at line 30 of file blackbox_test.cpp.

◆ t5

blackbox t5 = close_box<QI> ('t')

Definition at line 31 of file blackbox_test.cpp.

◆ t6

blackbox t6 = close_box<QN> (23)

Definition at line 32 of file blackbox_test.cpp.

◆ t7

blackbox t7 = close_box<DI> (5678)

Definition at line 33 of file blackbox_test.cpp.

◆ t8

blackbox t8 = close_box<DN> (0)

Definition at line 34 of file blackbox_test.cpp.

◆ t9

Definition at line 35 of file blackbox_test.cpp.

◆ t10

blackbox t10 = close_box<float> (0.0)

Definition at line 36 of file blackbox_test.cpp.

◆ t11

blackbox t11 = close_box<double> (8.567)

Definition at line 37 of file blackbox_test.cpp.

◆ t12

blackbox t12 = close_box<long double> (7.345)

Definition at line 38 of file blackbox_test.cpp.

◆ t

blackbox t[13] = {t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12}

Definition at line 40 of file blackbox_test.cpp.

40{t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12};
blackbox t0

◆ b

blackbox b[13] = {b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12}

Definition at line 41 of file blackbox_test.cpp.

41{b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12};
blackbox b0

◆ bout

string bout[13]
Initial value:
= {"",
"-2147483648\0",
"2147483647",
"-32768\0",
"32767",
"`",
"255",
"9223372036854775807",
"18446744073709551615",
"false",
"3.14",
"3.14159",
"3.14159"}

Definition at line 42 of file blackbox_test.cpp.

42 {"",
43 "-2147483648\0",
44 "2147483647",
45 "-32768\0",
46 "32767",
47 "`",
48 "255",
49 "9223372036854775807",
50 "18446744073709551615",
51 "false",
52 "3.14",
53 "3.14159",
54 "3.14159"};

◆ tout

string tout[13]
Initial value:
= {"",
"-2147483648\n",
"2147483647\t",
"-327680",
"32767 ",
"`\n",
"0",
"9223372036854775807\n",
"18446744073709551615 ",
"0",
"3.1415926",
"3.14159265",
"3.1415926535"}

Definition at line 55 of file blackbox_test.cpp.

55 {"",
56 "-2147483648\n",
57 "2147483647\t",
58 "-327680",
59 "32767 ",
60 "`\n",
61 "0",
62 "9223372036854775807\n",
63 "18446744073709551615 ",
64 "0",
65 "3.1415926",
66 "3.14159265",
67 "3.1415926535"};