@@ -59,7 +59,7 @@ describe('.run', function() {
59
59
fixture : `#include <criterion/criterion.h>
60
60
int square(int);
61
61
62
- Test(test, square ) {
62
+ Test(basic_test, should_square_a_number ) {
63
63
cr_assert_eq(25,square(5));
64
64
}`
65
65
} , function ( buffer ) {
@@ -86,12 +86,11 @@ describe('.run', function() {
86
86
it ( 'should handle basic failures' , function ( done ) {
87
87
runner . run ( {
88
88
language : 'c' ,
89
- setup : `int square(int a) { return a * a ; }` ,
90
- code : ' ' ,
89
+ code : `int square(int a) { return a * a ; }` ,
91
90
fixture : `#include <criterion/criterion.h>
92
91
int square(int);
93
92
94
- Test(test, basic_failure ) {
93
+ Test(basic_failure, should_raise_a_failure ) {
95
94
cr_assert_eq(25,square(6));
96
95
}`
97
96
} , function ( buffer ) {
@@ -103,17 +102,65 @@ describe('.run', function() {
103
102
it ( 'should support multiple asserts' , function ( done ) {
104
103
runner . run ( {
105
104
language : 'c' ,
106
- setup : `int square(int a) { return a * a ; }` ,
107
- code : ' ' ,
105
+ code : `int square(int a) { return a * a ; }` ,
108
106
fixture : `#include <criterion/criterion.h>
109
107
int square(int);
110
108
111
- Test(test, support_multiple_assert ) {
109
+ Test(multiple_assert_test, should_support_multiple_asserts ) {
112
110
cr_assert_eq(36,square(6));
113
111
cr_assert_neq(36,square(5));
112
+ cr_assert_eq(36,square(5));
114
113
}`
115
114
} , function ( buffer ) {
116
115
expect ( buffer . stdout . match ( / < P A S S E D : : > / g) . length ) . to . equal ( 2 ) ;
116
+ expect ( buffer . stdout . match ( / < F A I L E D : : > / g) . length ) . to . equal ( 1 ) ;
117
+ done ( ) ;
118
+ } ) ;
119
+ } ) ;
120
+ it ( 'should support multiple tests on one suite' , function ( done ) {
121
+ runner . run ( {
122
+ language : 'c' ,
123
+ code : `int square(int a) { return a * a ; }` ,
124
+ fixture : `#include <criterion/criterion.h>
125
+ int square(int);
126
+
127
+ Test(square_test, should_square_a_number) {
128
+ cr_assert_eq(36,square(6));
129
+ cr_assert_neq(36,square(5));
130
+ }
131
+
132
+ Test(square_test, should_square_number_5) {
133
+ cr_assert_eq(25,square(5));
134
+ }
135
+ `
136
+ } , function ( buffer ) {
137
+ expect ( buffer . stdout . match ( / < D E S C R I B E : : > / g) . length ) . to . equal ( 1 ) ;
138
+ expect ( buffer . stdout . match ( / < I T : : > / g) . length ) . to . equal ( 2 ) ;
139
+ expect ( buffer . stdout . match ( / < P A S S E D : : > / g) . length ) . to . equal ( 3 ) ;
140
+ done ( ) ;
141
+ } ) ;
142
+ } ) ;
143
+ it ( 'should support multiple test suites' , function ( done ) {
144
+ runner . run ( {
145
+ language : 'c' ,
146
+ code : `int square(int a) { return a * a ; }` ,
147
+ fixture : `#include <criterion/criterion.h>
148
+ int square(int);
149
+
150
+ Test(basic_test, should_multiply) {
151
+ cr_assert_eq(36,6*6);
152
+ cr_assert_neq(36,5*5);
153
+ }
154
+
155
+ Test(square_test, should_square_a_number) {
156
+ cr_assert_eq(36,square(6));
157
+ cr_assert_eq(36,square(5));
158
+ }
159
+ `
160
+ } , function ( buffer ) {
161
+ expect ( buffer . stdout . match ( / < D E S C R I B E : : > / g) . length ) . to . equal ( 2 ) ;
162
+ expect ( buffer . stdout . match ( / < P A S S E D : : > / g) . length ) . to . equal ( 3 ) ;
163
+ expect ( buffer . stdout . match ( / < F A I L E D : : > / g) . length ) . to . equal ( 1 ) ;
117
164
done ( ) ;
118
165
} ) ;
119
166
} ) ;
0 commit comments