|
5 | 5 |
|
6 | 6 |
|
7 | 7 | describe bool_spec("Some Tests", $ {
|
8 |
| - context("true is", _ { |
9 |
| - it("true", _ { |
10 |
| - expect(static_cast<bool>(1)).to_equal(true); |
11 |
| - }); |
12 |
| - |
13 |
| - it("true", _ { |
14 |
| - expect(true).to_equal(true); |
15 |
| - }); |
16 |
| - |
17 |
| - }); |
18 |
| - |
19 |
| - int i = 4; |
20 |
| - explain("4", _ { |
21 |
| - it("equals 4", _ { |
22 |
| - expect(i).to_equal(4); |
23 |
| - }); |
24 |
| - it("does not equal 5", _ { |
25 |
| - expect(i).not_().to_equal(5); |
26 |
| - }); |
27 |
| - |
28 |
| - it("plus 1 equals 5", _ { |
29 |
| - expect(i+1).to_equal(5); |
30 |
| - }); |
31 |
| - }); |
32 |
| - |
33 |
| - explain("0 is", _ { |
34 |
| - it("between -1 and 1 (exclusive)", _ { |
35 |
| - expect(0).to_be_between(-1, 1).exclusive(); |
36 |
| - }); |
37 |
| - it("between -0 and 0 (inclusive)", _ { |
38 |
| - expect(0).to_be_between(-0,0).inclusive(); |
39 |
| - }); |
40 |
| - it("not between -0 and 0 (exclusive)", _ { |
41 |
| - expect(0).not_().to_be_between(-0,0).exclusive(); |
42 |
| - }); |
43 |
| - it("not between 1 and -1 (inclusive)", _ { |
44 |
| - expect(0).not_().to_be_between(1,-1).inclusive(); |
45 |
| - }); |
46 |
| - it("between -1.0 and 1.0 (exclusive)", _ { |
47 |
| - expect(0).to_be_between(-1.0, 1.0).exclusive(); |
48 |
| - }); |
49 |
| - }); |
50 |
| - |
51 |
| - |
52 |
| - explain("{1,2,3}", _ { |
53 |
| - it("includes 1", _ { |
54 |
| - expect({1,2,3}).to_include({1}); |
55 |
| - }); |
56 |
| - it("includes [1,2,3]", _ { |
57 |
| - expect({1,2,3}).to_include({1,2,3}); |
58 |
| - }); |
59 |
| - it("does not include 4", _ { |
60 |
| - expect({1,2,3}).not_().to_include({4}); |
61 |
| - }); |
62 |
| - |
63 |
| - it("does not include [4,5,6]", _ { |
64 |
| - expect({1,2,3}).not_().to_include({4,5,6}); |
65 |
| - }); |
66 |
| - }); |
67 |
| - |
68 |
| - |
69 |
| - explain <std::list<int>> ({1,2,3}, _ { |
70 |
| - it(_ { is_expected().to_include(1); }); |
71 |
| - |
72 |
| - it("includes [1,2,3]", _ { |
73 |
| - expect<std::list<int>>({1,2,3}).to_include({1,2,3}); |
74 |
| - }); |
75 |
| - |
76 |
| - it( _ { is_expected().not_().to_include(4); }); |
77 |
| - |
78 |
| - it("does not include [4,5,6]", _ { |
79 |
| - is_expected().not_().to_include({4,5,6}); |
80 |
| - }); |
81 |
| - }); |
82 |
| - |
83 |
| - |
84 |
| - // context("std::map {{1,2},{3,4},{5,6}}", _ { |
85 |
| - // it("includes 1", _ { |
86 |
| - // std::map<int,int> m = {{1,2},{3,4},{5,6}}; |
87 |
| - // expect(m).to_include({1}); |
88 |
| - // }); |
89 |
| - // it("includes [1,2,3]", _ { |
90 |
| - // std::map<int,int> m = {{1,2},{3,4},{5,6}}; |
91 |
| - // expect(m).to_include({1,2,3}); |
92 |
| - // }); |
93 |
| - // it("does not include 4", _ { |
94 |
| - // std::map<int,int> m = {{1,2},{3,4},{5,6}}; |
95 |
| - // expect(m).not_().to_include({4}); |
96 |
| - // }); |
97 |
| - // it("does not include 4,5,6", _ { |
98 |
| - // std::map<int,int> m = {{1,2},{3,4},{5,6}}; |
99 |
| - // expect({1,2,3}).not_().to_include({4,5,6}); |
100 |
| - // }); |
101 |
| - // }); |
| 8 | + context("true is", _ { |
| 9 | + it("true", _ { |
| 10 | + expect(static_cast<bool>(1)).to_equal(true); |
| 11 | + }); |
| 12 | + |
| 13 | + it("true", _ { |
| 14 | + expect(true).to_equal(true); |
| 15 | + }); |
| 16 | + |
| 17 | + }); |
| 18 | + |
| 19 | + int i = 4; |
| 20 | + explain("4", _ { |
| 21 | + it("equals 4", _ { |
| 22 | + expect(i).to_equal(4); |
| 23 | + }); |
| 24 | + it("does not equal 5", _ { |
| 25 | + expect(i).not_().to_equal(5); |
| 26 | + }); |
| 27 | + |
| 28 | + it("plus 1 equals 5", _ { |
| 29 | + expect(i+1).to_equal(5); |
| 30 | + }); |
| 31 | + }); |
| 32 | + |
| 33 | + explain("0 is", _ { |
| 34 | + using namespace Matchers; |
| 35 | + it("between -1 and 1 (exclusive)", _ { |
| 36 | + expect(0).to_be_between(-1, 1, RangeMode::exclusive); |
| 37 | + }); |
| 38 | + it("between -0 and 0 (inclusive)", _ { |
| 39 | + expect(0).to_be_between(-0,0, RangeMode::inclusive); |
| 40 | + }); |
| 41 | + it("not between -0 and 0 (exclusive)", _ { |
| 42 | + expect(0).not_().to_be_between(-0,0, RangeMode::exclusive); |
| 43 | + }); |
| 44 | + it("not between 1 and -1", _ { |
| 45 | + expect(0).not_().to_be_between(1,-1); |
| 46 | + }); |
| 47 | + it("between -1.0 and 1.0 (exclusive)", _ { |
| 48 | + expect(0).to_be_between(-1.0, 1.0, RangeMode::exclusive); |
| 49 | + }); |
| 50 | + }); |
| 51 | + |
| 52 | + |
| 53 | + explain("{1,2,3}", _ { |
| 54 | + it("includes 1", _ { |
| 55 | + expect({1,2,3}).to_include({1}); |
| 56 | + }); |
| 57 | + it("includes [1,2,3]", _ { |
| 58 | + expect({1,2,3}).to_include({1,2,3}); |
| 59 | + }); |
| 60 | + it("does not include 4", _ { |
| 61 | + expect({1,2,3}).not_().to_include({4}); |
| 62 | + }); |
| 63 | + |
| 64 | + it("does not include [4,5,6]", _ { |
| 65 | + expect({1,2,3}).not_().to_include({4,5,6}); |
| 66 | + }); |
| 67 | + }); |
| 68 | + |
| 69 | + |
| 70 | + explain <std::list<int>> ({1,2,3}, _ { |
| 71 | + it(_ { is_expected().to_include(1); }); |
| 72 | + |
| 73 | + it("includes [1,2,3]", _ { |
| 74 | + expect<std::list<int>>({1,2,3}).to_include({1,2,3}); |
| 75 | + }); |
| 76 | + |
| 77 | + it( _ { is_expected().not_().to_include(4); }); |
| 78 | + |
| 79 | + it("does not include [4,5,6]", _ { |
| 80 | + is_expected().not_().to_include({4,5,6}); |
| 81 | + }); |
102 | 82 | });
|
103 | 83 |
|
| 84 | + // context("std::map {{1,2},{3,4},{5,6}}", _ { |
| 85 | + // it("includes 1", _ { |
| 86 | + // std::map<int,int> m = {{1,2},{3,4},{5,6}}; |
| 87 | + // expect(m).to_include({1}); |
| 88 | + // }); |
| 89 | + // it("includes [1,2,3]", _ { |
| 90 | + // std::map<int,int> m = {{1,2},{3,4},{5,6}}; |
| 91 | + // expect(m).to_include({1,2,3}); |
| 92 | + // }); |
| 93 | + // it("does not include 4", _ { |
| 94 | + // std::map<int,int> m = {{1,2},{3,4},{5,6}}; |
| 95 | + // expect(m).not_().to_include({4}); |
| 96 | + // }); |
| 97 | + // it("does not include 4,5,6", _ { |
| 98 | + // std::map<int,int> m = {{1,2},{3,4},{5,6}}; |
| 99 | + // expect({1,2,3}).not_().to_include({4,5,6}); |
| 100 | + // }); |
| 101 | + // }); |
| 102 | +}); |
| 103 | + |
104 | 104 | describe abs_spec("abs", $ {
|
105 | 105 | // you can use the `explain` keyword to
|
106 | 106 | // group behavior and nest descriptions
|
@@ -184,10 +184,10 @@ describe let_spec("let", $ {
|
184 | 184 | // });
|
185 | 185 |
|
186 | 186 | describe list_spec("A list spec", $ {
|
187 |
| - explain <std::list<int>> ({1,2,3,4}, _ { |
188 |
| - it( _ { is_expected().to_include(6); }); |
189 |
| - }); |
| 187 | + explain <std::list<int>> ({1,2,3,4}, _ { |
| 188 | + it( _ { is_expected().to_include(6); }); |
190 | 189 | });
|
| 190 | +}); |
191 | 191 |
|
192 | 192 | /* Here is the declaration of fabs description defined in an other file (fabs_spec.c in this sample)*/
|
193 | 193 | int main(){
|
|
0 commit comments