-
Notifications
You must be signed in to change notification settings - Fork 16
/
sample.cc
58 lines (46 loc) · 1.32 KB
/
sample.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
#include <string>
#include "dessert.hpp"
desserts() {
int a = 1, b = 2;
dessert( a < b );
dessert( a > b );
std::string hello = "hello";
std::string hell0 = "hell0";
dessert( "hello" == hello );
dessert( hello == "hello" );
dessert( hello == hello );
dessert( "hello" == "hello" );
dessert( "hello" != hell0 );
dessert( hello != "hell0" );
dessert( hello != hell0 );
dessert( "hello" != "hell0" );
dessert( "hell0" != "hell0" ) << "this shall fail";
}
desserts() {
dessert( 1 < 2 ) << "test shall pass; comment built on " << __TIME__ << " " << __DATE__;
dessert( 1 > 2 ) << "test shall fail; phone Aristotle (+30 " << 23760 << ") if this test fails";
}
desserts() {
auto once = []{ static int num = 0; return 0 == num++; };
dessert( once() );
dessert( once() ) << "test shall fail";
}
desserts( "Tests before main()" ) {
if( dessert( 1 < 2 ) ) {
// ok
} else {
// handle error here
}
}
desserts( "Tests after main()" ) {
dessert( throws(
std::string hello = "world";
hello.at(10) = 'c';
) ) << "test shall pass, exception thrown";
dessert( throws(
std::string hello = "world";
hello += hello;
) ) << "test shall fail, no exception thrown";
}
int main()
{}