comparison ext/UnitTest++/src/tests/TestCheckMacros.cpp @ 37:0d325e9d5953

added unittest++ files into ext. Not hooked into build scripts yet
author jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 12 Jul 2008 12:00:57 +0000
parents
children
comparison
equal deleted inserted replaced
36:6f1227f4932b 37:0d325e9d5953
1 #include "../UnitTest++.h"
2 #include "RecordingReporter.h"
3
4
5 namespace {
6
7 TEST(CheckSucceedsOnTrue)
8 {
9 bool failure = true;
10 {
11 RecordingReporter reporter;
12 UnitTest::TestResults testResults_(&reporter);
13 CHECK (true);
14 failure = (testResults_.GetFailureCount() > 0);
15 }
16
17 CHECK (!failure);
18 }
19
20 TEST(CheckFailsOnFalse)
21 {
22 bool failure = false;
23 {
24 RecordingReporter reporter;
25 UnitTest::TestResults testResults_(&reporter);
26 CHECK (false);
27 failure = (testResults_.GetFailureCount() > 0);
28 }
29
30 CHECK (failure);
31 }
32
33 TEST(FailureReportsCorrectTestName)
34 {
35 RecordingReporter reporter;
36 {
37 UnitTest::TestResults testResults_(&reporter);
38 CHECK (false);
39 }
40
41 CHECK_EQUAL (m_details.testName, reporter.lastFailedTest);
42 }
43
44 TEST(CheckFailureIncludesCheckContents)
45 {
46 RecordingReporter reporter;
47 {
48 UnitTest::TestResults testResults_(&reporter);
49 const bool yaddayadda = false;
50 CHECK (yaddayadda);
51 }
52
53 CHECK (std::strstr(reporter.lastFailedMessage, "yaddayadda"));
54 }
55
56 int ThrowingFunction()
57 {
58 throw "Doh";
59 }
60
61 TEST(CheckFailsOnException)
62 {
63 bool failure = false;
64 {
65 RecordingReporter reporter;
66 UnitTest::TestResults testResults_(&reporter);
67 CHECK (ThrowingFunction() == 1);
68 failure = (testResults_.GetFailureCount() > 0);
69 }
70
71 CHECK (failure);
72 }
73
74 TEST(CheckFailureBecauseOfExceptionIncludesCheckContents)
75 {
76 RecordingReporter reporter;
77 {
78 UnitTest::TestResults testResults_(&reporter);
79 CHECK (ThrowingFunction() == 1);
80 }
81
82 CHECK (std::strstr(reporter.lastFailedMessage, "ThrowingFunction() == 1"));
83 }
84
85 TEST(CheckEqualSucceedsOnEqual)
86 {
87 bool failure = true;
88 {
89 RecordingReporter reporter;
90 UnitTest::TestResults testResults_(&reporter);
91 CHECK_EQUAL (1, 1);
92 failure = (testResults_.GetFailureCount() > 0);
93 }
94
95 CHECK (!failure);
96 }
97
98 TEST(CheckEqualFailsOnNotEqual)
99 {
100 bool failure = false;
101 {
102 RecordingReporter reporter;
103 UnitTest::TestResults testResults_(&reporter);
104 CHECK_EQUAL (1, 2);
105 failure = (testResults_.GetFailureCount() > 0);
106 }
107
108 CHECK (failure);
109 }
110
111 TEST(CheckEqualFailsOnException)
112 {
113 bool failure = false;
114 {
115 RecordingReporter reporter;
116 UnitTest::TestResults testResults_(&reporter);
117 CHECK_EQUAL (ThrowingFunction(), 1);
118 failure = (testResults_.GetFailureCount() > 0);
119 }
120
121 CHECK (failure);
122 }
123
124 TEST(CheckEqualFailureContainsCorrectDetails)
125 {
126 int line = 0;
127 RecordingReporter reporter;
128 {
129 UnitTest::TestResults testResults_(&reporter);
130 UnitTest::TestDetails const m_details("testName", "suiteName", "filename", -1);
131 CHECK_EQUAL (1, 123); line = __LINE__;
132 }
133
134 CHECK_EQUAL("testName", reporter.lastFailedTest);
135 CHECK_EQUAL("suiteName", reporter.lastFailedSuite);
136 CHECK_EQUAL ("filename", reporter.lastFailedFile);
137 CHECK_EQUAL (line, reporter.lastFailedLine);
138 }
139
140 TEST(CheckEqualFailureBecauseOfExceptionContainsCorrectDetails)
141 {
142 int line = 0;
143 RecordingReporter reporter;
144 {
145 UnitTest::TestResults testResults_(&reporter);
146 UnitTest::TestDetails const m_details("testName", "suiteName", "filename", -1);
147 CHECK_EQUAL (ThrowingFunction(), 123); line = __LINE__;
148 }
149
150 CHECK_EQUAL("testName", reporter.lastFailedTest);
151 CHECK_EQUAL("suiteName", reporter.lastFailedSuite);
152 CHECK_EQUAL ("filename", reporter.lastFailedFile);
153 CHECK_EQUAL (line, reporter.lastFailedLine);
154 }
155
156 TEST(CheckEqualFailureBecauseOfExceptionIncludesCheckContents)
157 {
158 RecordingReporter reporter;
159 {
160 UnitTest::TestResults testResults_(&reporter);
161 CHECK_EQUAL (ThrowingFunction(), 123);
162 }
163
164 CHECK (std::strstr(reporter.lastFailedMessage, "ThrowingFunction()"));
165 CHECK (std::strstr(reporter.lastFailedMessage, "123"));
166 }
167
168 int g_sideEffect = 0;
169 int FunctionWithSideEffects()
170 {
171 ++g_sideEffect;
172 return 1;
173 }
174
175 TEST(CheckEqualDoesNotHaveSideEffectsWhenPassing)
176 {
177 g_sideEffect = 0;
178 {
179 UnitTest::TestResults testResults_;
180 CHECK_EQUAL (1, FunctionWithSideEffects());
181 }
182 CHECK_EQUAL (1, g_sideEffect);
183 }
184
185 TEST(CheckEqualDoesNotHaveSideEffectsWhenFailing)
186 {
187 g_sideEffect = 0;
188 {
189 UnitTest::TestResults testResults_;
190 CHECK_EQUAL (2, FunctionWithSideEffects());
191 }
192 CHECK_EQUAL (1, g_sideEffect);
193 }
194
195
196 TEST(CheckCloseSucceedsOnEqual)
197 {
198 bool failure = true;
199 {
200 RecordingReporter reporter;
201 UnitTest::TestResults testResults_(&reporter);
202 CHECK_CLOSE (1.0f, 1.001f, 0.01f);
203 failure = (testResults_.GetFailureCount() > 0);
204 }
205
206 CHECK (!failure);
207 }
208
209 TEST(CheckCloseFailsOnNotEqual)
210 {
211 bool failure = false;
212 {
213 RecordingReporter reporter;
214 UnitTest::TestResults testResults_(&reporter);
215 CHECK_CLOSE (1.0f, 1.1f, 0.01f);
216 failure = (testResults_.GetFailureCount() > 0);
217 }
218
219 CHECK (failure);
220 }
221
222 TEST(CheckCloseFailsOnException)
223 {
224 bool failure = false;
225 {
226 RecordingReporter reporter;
227 UnitTest::TestResults testResults_(&reporter);
228 CHECK_CLOSE ((float)ThrowingFunction(), 1.0001f, 0.1f);
229 failure = (testResults_.GetFailureCount() > 0);
230 }
231
232 CHECK (failure);
233 }
234
235 TEST(CheckCloseFailureContainsCorrectDetails)
236 {
237 int line = 0;
238 RecordingReporter reporter;
239 {
240 UnitTest::TestResults testResults_(&reporter);
241 UnitTest::TestDetails m_details("test", "suite", "filename", -1);
242 CHECK_CLOSE (1.0f, 1.1f, 0.01f); line = __LINE__;
243 }
244
245 CHECK_EQUAL("test", reporter.lastFailedTest);
246 CHECK_EQUAL("suite", reporter.lastFailedSuite);
247 CHECK_EQUAL ("filename", reporter.lastFailedFile);
248 CHECK_EQUAL (line, reporter.lastFailedLine);
249 }
250
251 TEST(CheckCloseFailureBecauseOfExceptionContainsCorrectDetails)
252 {
253 int line = 0;
254 RecordingReporter reporter;
255 {
256 UnitTest::TestResults testResults_(&reporter);
257 UnitTest::TestDetails m_details("closeTest", "closeSuite", "filename", -1);
258 CHECK_CLOSE ((float)ThrowingFunction(), 1.0001f, 0.1f); line = __LINE__;
259 }
260
261 CHECK_EQUAL("closeTest", reporter.lastFailedTest);
262 CHECK_EQUAL("closeSuite", reporter.lastFailedSuite);
263 CHECK_EQUAL ("filename", reporter.lastFailedFile);
264 CHECK_EQUAL (line, reporter.lastFailedLine);
265 }
266
267 TEST(CheckCloseFailureBecauseOfExceptionIncludesCheckContents)
268 {
269 RecordingReporter reporter;
270 {
271 UnitTest::TestResults testResults_(&reporter);
272 CHECK_CLOSE ((float)ThrowingFunction(), 1.0001f, 0.1f);
273 }
274
275 CHECK (std::strstr(reporter.lastFailedMessage, "(float)ThrowingFunction()"));
276 CHECK (std::strstr(reporter.lastFailedMessage, "1.0001f"));
277 }
278
279 TEST(CheckCloseDoesNotHaveSideEffectsWhenPassing)
280 {
281 g_sideEffect = 0;
282 {
283 UnitTest::TestResults testResults_;
284 CHECK_CLOSE (1, FunctionWithSideEffects(), 0.1f);
285 }
286 CHECK_EQUAL (1, g_sideEffect);
287 }
288
289 TEST(CheckCloseDoesNotHaveSideEffectsWhenFailing)
290 {
291 g_sideEffect = 0;
292 {
293 UnitTest::TestResults testResults_;
294 CHECK_CLOSE (2, FunctionWithSideEffects(), 0.1f);
295 }
296 CHECK_EQUAL (1, g_sideEffect);
297 }
298
299
300 class ThrowingObject
301 {
302 public:
303 float operator[](int) const
304 {
305 throw "Test throw";
306 }
307 };
308
309
310 TEST(CheckArrayCloseSucceedsOnEqual)
311 {
312 bool failure = true;
313 {
314 RecordingReporter reporter;
315 UnitTest::TestResults testResults_(&reporter);
316 const float data[4] = { 0, 1, 2, 3 };
317 CHECK_ARRAY_CLOSE (data, data, 4, 0.01f);
318 failure = (testResults_.GetFailureCount() > 0);
319 }
320
321 CHECK (!failure);
322 }
323
324 TEST(CheckArrayCloseFailsOnNotEqual)
325 {
326 bool failure = false;
327 {
328 RecordingReporter reporter;
329 UnitTest::TestResults testResults_(&reporter);
330 int const data1[4] = { 0, 1, 2, 3 };
331 int const data2[4] = { 0, 1, 3, 3 };
332 CHECK_ARRAY_CLOSE (data1, data2, 4, 0.01f);
333 failure = (testResults_.GetFailureCount() > 0);
334 }
335
336 CHECK (failure);
337 }
338
339 TEST(CheckArrayCloseFailureIncludesCheckExpectedAndActual)
340 {
341 RecordingReporter reporter;
342 {
343 UnitTest::TestResults testResults_(&reporter);
344 int const data1[4] = { 0, 1, 2, 3 };
345 int const data2[4] = { 0, 1, 3, 3 };
346 CHECK_ARRAY_CLOSE (data1, data2, 4, 0.01f);
347 }
348
349 CHECK (std::strstr(reporter.lastFailedMessage, "xpected [ 0 1 2 3 ]"));
350 CHECK (std::strstr(reporter.lastFailedMessage, "was [ 0 1 3 3 ]"));
351 }
352
353 TEST(CheckArrayCloseFailureContainsCorrectDetails)
354 {
355 int line = 0;
356 RecordingReporter reporter;
357 {
358 UnitTest::TestResults testResults_(&reporter);
359 UnitTest::TestDetails m_details("arrayCloseTest", "arrayCloseSuite", "filename", -1);
360 int const data1[4] = { 0, 1, 2, 3 };
361 int const data2[4] = { 0, 1, 3, 3 };
362 CHECK_ARRAY_CLOSE (data1, data2, 4, 0.01f); line = __LINE__;
363 }
364
365 CHECK_EQUAL("arrayCloseTest", reporter.lastFailedTest);
366 CHECK_EQUAL("arrayCloseSuite", reporter.lastFailedSuite);
367 CHECK_EQUAL ("filename", reporter.lastFailedFile);
368 CHECK_EQUAL (line, reporter.lastFailedLine);
369 }
370
371 TEST(CheckArrayCloseFailureBecauseOfExceptionContainsCorrectDetails)
372 {
373 int line = 0;
374 RecordingReporter reporter;
375 {
376 UnitTest::TestResults testResults_(&reporter);
377 UnitTest::TestDetails m_details("arrayCloseTest", "arrayCloseSuite", "filename", -1);
378 int const data[4] = { 0, 1, 2, 3 };
379 CHECK_ARRAY_CLOSE (data, ThrowingObject(), 4, 0.01f); line = __LINE__;
380 }
381
382 CHECK_EQUAL("arrayCloseTest", reporter.lastFailedTest);
383 CHECK_EQUAL("arrayCloseSuite", reporter.lastFailedSuite);
384 CHECK_EQUAL ("filename", reporter.lastFailedFile);
385 CHECK_EQUAL (line, reporter.lastFailedLine);
386 }
387
388 TEST(CheckArrayCloseFailureIncludesTolerance)
389 {
390 RecordingReporter reporter;
391 {
392 UnitTest::TestResults testResults_(&reporter);
393 float const data1[4] = { 0, 1, 2, 3 };
394 float const data2[4] = { 0, 1, 3, 3 };
395 CHECK_ARRAY_CLOSE (data1, data2, 4, 0.01f);
396 }
397
398 CHECK (std::strstr(reporter.lastFailedMessage, "0.01"));
399 }
400
401
402 TEST(CheckArrayCloseFailsOnException)
403 {
404 bool failure = false;
405 {
406 RecordingReporter reporter;
407 UnitTest::TestResults testResults_(&reporter);
408 const float data[4] = { 0, 1, 2, 3 };
409 ThrowingObject obj;
410 CHECK_ARRAY_CLOSE (data, obj, 3, 0.01f);
411 failure = (testResults_.GetFailureCount() > 0);
412 }
413
414 CHECK (failure);
415 }
416
417 TEST(CheckArrayCloseFailureOnExceptionIncludesCheckContents)
418 {
419 RecordingReporter reporter;
420 {
421 UnitTest::TestResults testResults_(&reporter);
422 const float data[4] = { 0, 1, 2, 3 };
423 ThrowingObject obj;
424 CHECK_ARRAY_CLOSE (data, obj, 3, 0.01f);
425 }
426
427 CHECK (std::strstr(reporter.lastFailedMessage, "data"));
428 CHECK (std::strstr(reporter.lastFailedMessage, "obj"));
429 }
430
431
432 TEST(CheckArrayEqualSuceedsOnEqual)
433 {
434 bool failure = true;
435 {
436 RecordingReporter reporter;
437 UnitTest::TestResults testResults_(&reporter);
438 const float data[4] = { 0, 1, 2, 3 };
439 CHECK_ARRAY_EQUAL (data, data, 4);
440 failure = (testResults_.GetFailureCount() > 0);
441 }
442
443 CHECK (!failure);
444 }
445
446 TEST(CheckArrayEqualFailsOnNotEqual)
447 {
448 bool failure = false;
449 {
450 RecordingReporter reporter;
451 UnitTest::TestResults testResults_(&reporter);
452 int const data1[4] = { 0, 1, 2, 3 };
453 int const data2[4] = { 0, 1, 3, 3 };
454 CHECK_ARRAY_EQUAL (data1, data2, 4);
455 failure = (testResults_.GetFailureCount() > 0);
456 }
457
458 CHECK (failure);
459 }
460
461 TEST(CheckArrayEqualFailureIncludesCheckExpectedAndActual)
462 {
463 RecordingReporter reporter;
464 {
465 UnitTest::TestResults testResults_(&reporter);
466 int const data1[4] = { 0, 1, 2, 3 };
467 int const data2[4] = { 0, 1, 3, 3 };
468 CHECK_ARRAY_EQUAL (data1, data2, 4);
469 }
470
471 CHECK (std::strstr(reporter.lastFailedMessage, "xpected [ 0 1 2 3 ]"));
472 CHECK (std::strstr(reporter.lastFailedMessage, "was [ 0 1 3 3 ]"));
473 }
474
475 TEST(CheckArrayEqualFailureContainsCorrectInfo)
476 {
477 int line = 0;
478 RecordingReporter reporter;
479 {
480 UnitTest::TestResults testResults_(&reporter);
481 int const data1[4] = { 0, 1, 2, 3 };
482 int const data2[4] = { 0, 1, 3, 3 };
483 CHECK_ARRAY_EQUAL (data1, data2, 4); line = __LINE__;
484 }
485
486 CHECK_EQUAL ("CheckArrayEqualFailureContainsCorrectInfo", reporter.lastFailedTest);
487 CHECK_EQUAL (__FILE__, reporter.lastFailedFile);
488 CHECK_EQUAL (line, reporter.lastFailedLine);
489 }
490
491 TEST(CheckArrayEqualFailsOnException)
492 {
493 bool failure = false;
494 {
495 RecordingReporter reporter;
496 UnitTest::TestResults testResults_(&reporter);
497 const float data[4] = { 0, 1, 2, 3 };
498 ThrowingObject obj;
499 CHECK_ARRAY_EQUAL (data, obj, 3);
500 failure = (testResults_.GetFailureCount() > 0);
501 }
502
503 CHECK (failure);
504 }
505
506 TEST(CheckArrayEqualFailureOnExceptionIncludesCheckContents)
507 {
508 RecordingReporter reporter;
509 {
510 UnitTest::TestResults testResults_(&reporter);
511 const float data[4] = { 0, 1, 2, 3 };
512 ThrowingObject obj;
513 CHECK_ARRAY_EQUAL (data, obj, 3);
514 }
515
516 CHECK (std::strstr(reporter.lastFailedMessage, "data"));
517 CHECK (std::strstr(reporter.lastFailedMessage, "obj"));
518 }
519
520 float const* FunctionWithSideEffects2()
521 {
522 ++g_sideEffect;
523 static float const data[] = {1,2,3,4};
524 return data;
525 }
526
527 TEST(CheckArrayCloseDoesNotHaveSideEffectsWhenPassing)
528 {
529 g_sideEffect = 0;
530 {
531 UnitTest::TestResults testResults_;
532 const float data[] = { 0, 1, 2, 3 };
533 CHECK_ARRAY_CLOSE (data, FunctionWithSideEffects2(), 4, 0.01f);
534 }
535 CHECK_EQUAL (1, g_sideEffect);
536 }
537
538 TEST(CheckArrayCloseDoesNotHaveSideEffectsWhenFailing)
539 {
540 g_sideEffect = 0;
541 {
542 UnitTest::TestResults testResults_;
543 const float data[] = { 0, 1, 3, 3 };
544 CHECK_ARRAY_CLOSE (data, FunctionWithSideEffects2(), 4, 0.01f);
545 }
546 CHECK_EQUAL (1, g_sideEffect);
547 }
548
549 class ThrowingObject2D
550 {
551 public:
552 float* operator[](int) const
553 {
554 throw "Test throw";
555 }
556 };
557
558
559 TEST(CheckArray2DCloseSucceedsOnEqual)
560 {
561 bool failure = true;
562 {
563 RecordingReporter reporter;
564 UnitTest::TestResults testResults_(&reporter);
565 const float data[2][2] = { {0, 1}, {2, 3} };
566 CHECK_ARRAY2D_CLOSE (data, data, 2, 2, 0.01f);
567 failure = (testResults_.GetFailureCount() > 0);
568 }
569
570 CHECK (!failure);
571 }
572
573 TEST(CheckArray2DCloseFailsOnNotEqual)
574 {
575 bool failure = false;
576 {
577 RecordingReporter reporter;
578 UnitTest::TestResults testResults_(&reporter);
579 int const data1[2][2] = { {0, 1}, {2, 3} };
580 int const data2[2][2] = { {0, 1}, {3, 3} };
581 CHECK_ARRAY2D_CLOSE (data1, data2, 2, 2, 0.01f);
582 failure = (testResults_.GetFailureCount() > 0);
583 }
584
585 CHECK (failure);
586 }
587
588 TEST(CheckArray2DCloseFailureIncludesCheckExpectedAndActual)
589 {
590 RecordingReporter reporter;
591 {
592 UnitTest::TestResults testResults_(&reporter);
593 int const data1[2][2] = { {0, 1}, {2, 3} };
594 int const data2[2][2] = { {0, 1}, {3, 3} };
595 CHECK_ARRAY2D_CLOSE (data1, data2, 2, 2, 0.01f);
596 }
597
598 CHECK (std::strstr(reporter.lastFailedMessage, "xpected [ [ 0 1 ] [ 2 3 ] ]"));
599 CHECK (std::strstr(reporter.lastFailedMessage, "was [ [ 0 1 ] [ 3 3 ] ]"));
600 }
601
602 TEST(CheckArray2DCloseFailureContainsCorrectDetails)
603 {
604 int line = 0;
605 RecordingReporter reporter;
606 {
607 UnitTest::TestResults testResults_(&reporter);
608 UnitTest::TestDetails m_details("array2DCloseTest", "array2DCloseSuite", "filename", -1);
609 int const data1[2][2] = { {0, 1}, {2, 3} };
610 int const data2[2][2] = { {0, 1}, {3, 3} };
611 CHECK_ARRAY2D_CLOSE (data1, data2, 2, 2, 0.01f); line = __LINE__;
612 }
613
614 CHECK_EQUAL("array2DCloseTest", reporter.lastFailedTest);
615 CHECK_EQUAL("array2DCloseSuite", reporter.lastFailedSuite);
616 CHECK_EQUAL ("filename", reporter.lastFailedFile);
617 CHECK_EQUAL (line, reporter.lastFailedLine);
618 }
619
620 TEST(CheckArray2DCloseFailureBecauseOfExceptionContainsCorrectDetails)
621 {
622 int line = 0;
623 RecordingReporter reporter;
624 {
625 UnitTest::TestResults testResults_(&reporter);
626 UnitTest::TestDetails m_details("array2DCloseTest", "array2DCloseSuite", "filename", -1);
627 const float data[2][2] = { {0, 1}, {2, 3} };
628 CHECK_ARRAY2D_CLOSE (data, ThrowingObject2D(), 2, 2, 0.01f); line = __LINE__;
629 }
630
631 CHECK_EQUAL("array2DCloseTest", reporter.lastFailedTest);
632 CHECK_EQUAL("array2DCloseSuite", reporter.lastFailedSuite);
633 CHECK_EQUAL ("filename", reporter.lastFailedFile);
634 CHECK_EQUAL (line, reporter.lastFailedLine);
635 }
636
637 TEST(CheckArray2DCloseFailureIncludesTolerance)
638 {
639 RecordingReporter reporter;
640 {
641 UnitTest::TestResults testResults_(&reporter);
642 float const data1[2][2] = { {0, 1}, {2, 3} };
643 float const data2[2][2] = { {0, 1}, {3, 3} };
644 CHECK_ARRAY2D_CLOSE (data1, data2, 2, 2, 0.01f);
645 }
646
647 CHECK (std::strstr(reporter.lastFailedMessage, "0.01"));
648 }
649
650 TEST(CheckArray2DCloseFailsOnException)
651 {
652 bool failure = false;
653 {
654 RecordingReporter reporter;
655 UnitTest::TestResults testResults_(&reporter);
656 const float data[2][2] = { {0, 1}, {2, 3} };
657 ThrowingObject2D obj;
658 CHECK_ARRAY2D_CLOSE (data, obj, 2, 2, 0.01f);
659 failure = (testResults_.GetFailureCount() > 0);
660 }
661
662 CHECK (failure);
663 }
664
665 TEST(CheckArray2DCloseFailureOnExceptionIncludesCheckContents)
666 {
667 RecordingReporter reporter;
668 {
669 UnitTest::TestResults testResults_(&reporter);
670 const float data[2][2] = { {0, 1}, {2, 3} };
671 ThrowingObject2D obj;
672 CHECK_ARRAY2D_CLOSE (data, obj, 2, 2, 0.01f);
673 }
674
675 CHECK (std::strstr(reporter.lastFailedMessage, "data"));
676 CHECK (std::strstr(reporter.lastFailedMessage, "obj"));
677 }
678
679 float const* const* FunctionWithSideEffects3()
680 {
681 ++g_sideEffect;
682 static float const data1[] = {0,1};
683 static float const data2[] = {2,3};
684 static const float* const data[] = {data1, data2};
685 return data;
686 }
687
688 TEST(CheckArray2DCloseDoesNotHaveSideEffectsWhenPassing)
689 {
690 g_sideEffect = 0;
691 {
692 UnitTest::TestResults testResults_;
693 const float data[2][2] = { {0, 1}, {2, 3} };
694 CHECK_ARRAY2D_CLOSE (data, FunctionWithSideEffects3(), 2, 2, 0.01f);
695 }
696 CHECK_EQUAL (1, g_sideEffect);
697 }
698
699 TEST(CheckArray2DCloseDoesNotHaveSideEffectsWhenFailing)
700 {
701 g_sideEffect = 0;
702 {
703 UnitTest::TestResults testResults_;
704 const float data[2][2] = { {0, 1}, {3, 3} };
705 CHECK_ARRAY2D_CLOSE (data, FunctionWithSideEffects3(), 2, 2, 0.01f);
706 }
707 CHECK_EQUAL (1, g_sideEffect);
708 }
709
710 }