Lolly 1.4.28
Loading...
Searching...
No Matches
promise_test.cpp
Go to the documentation of this file.
1/** \file promise_test.cpp
2 * \copyright GPLv3
3 * \details A unitest for promise.
4 * \author Paradisuman
5 * \date 2023
6 */
7
8#include "a_lolly_test.hpp"
9#include "promise.hpp"
10#include "string.hpp"
11
12class promise_rep_int_add : public promise_rep<int> {
13 int x;
14 int y;
15
16public:
17 promise_rep_int_add (int a, int b) : x (a), y (b){};
18 virtual int eval () override { return x + y; }
19};
20
21bool
23 string sa= a.unbuffer ();
24 string sb= b.unbuffer ();
25
26 return sa == sb;
27}
28
29TEST_CASE ("function eval") {
34
35 CHECK (t1 () == 3);
36 CHECK (t2 () == 1);
37}
38
39TEST_CASE ("function print") {
43 _ostream1.buffer ();
44
45 SUBCASE ("if tm_ostream empty") {
47 _ostream2.buffer ();
48 _ostream2 << "promise";
49 t->print (_ostream1);
50
52 }
53
54 SUBCASE ("if tm_ostream not empty") {
56 _ostream2.buffer ();
57 _ostream2 << "testpromise";
58 _ostream1 << "test";
59
60 t->print (_ostream1);
61
63 }
64}
65
66TEST_CASE ("operator <<") {
68
69 SUBCASE ("if promise null") {
72 _ostream1.buffer ();
73 _ostream2.buffer ();
74 _ostream2 << "(null)";
75 _ostream1 << t;
76
78 }
79
80 SUBCASE ("if promise not null") {
84 _ostream1.buffer ();
85 _ostream2.buffer ();
86 _ostream2 << "promise";
87 _ostream1 << t;
88
90 }
91}
blackbox t1
blackbox t2
blackbox b[13]
blackbox t[13]
blackbox_rep * rep
Definition blackbox.hpp:27
The list class represents a linked list.
Definition list.hpp:48
promise_rep_int_add(int a, int b)
virtual int eval() override
string unbuffer()
TEST_CASE("test for operator+= and advance()")
bool test_same(tm_ostream &a, tm_ostream &b)