Sfoglia il codice sorgente

Greatest has colors. Documented TombRaider1.h

Thomas Buck 10 anni fa
parent
commit
213c0f8e7d
3 ha cambiato i file con 183 aggiunte e 68 eliminazioni
  1. 1
    1
      include/System.h
  2. 124
    41
      include/TombRaider1.h
  3. 58
    26
      test/greatest.h

+ 1
- 1
include/System.h Vedi File

@@ -66,7 +66,7 @@ public:
66 66
     virtual ~System();
67 67
 
68 68
     /*!
69
-     * \brief Generates a buufered string for the printf call
69
+     * \brief Generates a buffered string for the printf call
70 70
      * \param string Format string like for printf
71 71
      * \returns string in a buffer
72 72
      */

+ 124
- 41
include/TombRaider1.h Vedi File

@@ -16,7 +16,9 @@
16 16
 class TombRaider1 {
17 17
 public:
18 18
 
19
-    // Associated with Item 7
19
+    /*!
20
+     * \brief States of a Wolf (Item 7)
21
+     */
20 22
     enum WolfStates {
21 23
         WolfState_Walking       = 1,
22 24
         WolfState_Running       = 2,
@@ -31,7 +33,9 @@ public:
31 33
         WolfState_Biting        = 12
32 34
     };
33 35
 
34
-    // Associated with Item 8
36
+    /*!
37
+     * \brief States of a Bear (Item 8)
38
+     */
35 39
     enum BearStates {
36 40
         BearState_Walking       = 0, //!< Walking on all fours
37 41
         BearState_Getting       = 1, //!< Getting back to all fours
@@ -45,7 +49,9 @@ public:
45 49
         BearState_Dying         = 9
46 50
     };
47 51
 
48
-    // Associated with Item 9
52
+    /*!
53
+     * \brief States of a Bat (Item 9)
54
+     */
49 55
     enum BatStates {
50 56
         BatState_Starting = 1, //!< Starting to fly
51 57
         BatState_Flying   = 2, //!< Flying straight
@@ -54,7 +60,9 @@ public:
54 60
         BatState_Dying    = 5
55 61
     };
56 62
 
57
-    // Associated with Item 10
63
+    /*!
64
+     * \brief States of a Crocodile on land (Item 10)
65
+     */
58 66
     enum CrocodileLandStates {
59 67
         CrocodileLandState_Stationary = 1,
60 68
         CrocodileLandState_Walking1   = 2,
@@ -64,14 +72,18 @@ public:
64 72
         CrocodileLandState_Dying      = 7
65 73
     };
66 74
 
67
-    // Associated with Item 11
75
+    /*!
76
+     * \brief States of a Crocodile in water (Item 11)
77
+     */
68 78
     enum CrocodileWaterStates {
69 79
         CrocodileWaterState_Swimming = 1,
70 80
         CrocodileWaterState_Biting   = 2,
71 81
         CrocodileWaterState_Dying    = 3
72 82
     };
73 83
 
74
-    // Associated with Items 12, 13 and 14
84
+    /*!
85
+     * \brief States of a Lion (Male & Female) and a Panther (Items 12, 13, 14)
86
+     */
75 87
     enum LionStates {
76 88
         LionState_Standing = 1,
77 89
         LionState_Walking  = 2,
@@ -82,7 +94,9 @@ public:
82 94
         LionState_Biting2  = 7
83 95
     };
84 96
 
85
-    // Associated with Item 15
97
+    /*!
98
+     * \brief States of a Gorilla (Item 15)
99
+     */
86 100
     enum GorillaStates {
87 101
         GorillaState_Standing = 1,  //!< Standing on all fours
88 102
         GorillaState_Running  = 3,  //!< Running on all fours
@@ -96,7 +110,9 @@ public:
96 110
         GorillaState_Climbing = 11
97 111
     };
98 112
 
99
-    // Associated with Item 16
113
+    /*!
114
+     * \brief States of a Giant Rat on land (Item 16)
115
+     */
100 116
     enum GiantRatLandStates {
101 117
         GiantRatLandState_Standing  = 1,
102 118
         GiantRatLandState_JumpBite  = 2,
@@ -106,14 +122,18 @@ public:
106 122
         GiantRatLandState_RearingUp = 6
107 123
     };
108 124
 
109
-    // Associated with Item 17
125
+    /*!
126
+     * \brief States of a Giant Rat in the water (Item 17)
127
+     */
110 128
     enum GiantRatWaterStates {
111 129
         GiantRatWaterState_Swimming = 1,
112 130
         GiantRatWaterState_Biting   = 2,
113 131
         GiantRatWaterState_Dying    = 3
114 132
     };
115 133
 
116
-    // Associated with Item 18
134
+    /*!
135
+     * \brief States of a Tyrannosaur (Item 18)
136
+     */
117 137
     enum TyrannosaurStates {
118 138
         TyrannosaurState_Standing  = 1,
119 139
         TyrannosaurState_Walking   = 2,
@@ -124,7 +144,9 @@ public:
124 144
         TyrannosaurState_Shaking   = 8  //!< Shaking Head and Spitting Out
125 145
     };
126 146
 
127
-    // Associated with Item 19
147
+    /*!
148
+     * \brief States of a Raptor (Item 19)
149
+     */
128 150
     enum RaptorStates {
129 151
         RaptorState_Dying     = 0,
130 152
         RaptorState_Standing  = 1,
@@ -136,7 +158,9 @@ public:
136 158
         RaptorState_Biting    = 8,
137 159
     };
138 160
 
139
-    // Associated with Item 20
161
+    /*!
162
+     * \brief States of a Winged Mutant (Item 20)
163
+     */
140 164
     enum WingedMutantStates {
141 165
         WingedMutantState_Crouching = 1,
142 166
         WingedMutantState_Walking   = 2,
@@ -145,14 +169,16 @@ public:
145 169
         WingedMutantState_Looking   = 6,
146 170
         WingedMutantState_Jumping   = 7,
147 171
         WingedMutantState_Clawing   = 8,
148
-        WingedMutantState_Aiming    = 9, //!< Aiming Right-Hand Gun
172
+        WingedMutantState_Aiming    = 9,  //!< Aiming Right-Hand Gun
149 173
         WingedMutantState_AimFire   = 10, //!< Aiming and Firing Left-Hand Gun
150 174
         WingedMutantState_Firing    = 11, //!< Firing Right-Hand Gun
151 175
         WingedMutantState_Standing  = 12,
152 176
         WingedMutantState_Flying    = 13
153 177
     };
154 178
 
155
-    // Associated with Item 23
179
+    /*!
180
+     * \brief States of a Centaur Mutant (Item 23)
181
+     */
156 182
     enum CentaurMutantStates {
157 183
         CentaurMutantState_Standing  = 1,
158 184
         CentaurMutantState_Firing    = 2,
@@ -162,13 +188,17 @@ public:
162 188
         CentaurMutantState_Rearing   = 6  //!<  Rearing up
163 189
     };
164 190
 
165
-    // Associated with Item 24
191
+    /*!
192
+     * \brief States of a Mummy (Item 24)
193
+     */
166 194
     enum MummyStates {
167 195
         MummyState_Standing = 1,
168 196
         MummyState_Falling  = 2  //!< Falling forward
169 197
     };
170 198
 
171
-    // Associated with Item 27
199
+    /*!
200
+     * \brief States of Larson (Item 27)
201
+     */
172 202
     enum LarsonStates {
173 203
         LarsonState_Walking1    = 0,
174 204
         LarsonState_StandingGun = 1,
@@ -180,7 +210,9 @@ public:
180 210
         LarsonState_Firing      = 7
181 211
     };
182 212
 
183
-    // Associated with Item 28
213
+    /*!
214
+     * \brief States of Pierre (Item 28)
215
+     */
184 216
     enum PierreStates {
185 217
         PierreState_Standing   = 1,
186 218
         PierreState_Walking    = 2,
@@ -191,7 +223,9 @@ public:
191 223
         PierreState_Firing     = 7
192 224
     };
193 225
 
194
-    // Associated with Item 29
226
+    /*!
227
+     * \brief States of the Skateboard (Item 29)
228
+     */
195 229
     enum SkateboardStates {
196 230
         SkateboardState_BeingTurned = 0,
197 231
         SkateboardState_Stationary1 = 1,
@@ -200,7 +234,9 @@ public:
200 234
         SkateboardState_Stationary4 = 4
201 235
     };
202 236
 
203
-    // Associated with Item 30
237
+    /*!
238
+     * \brief States of the Skateboard Kid (Item 30)
239
+     */
204 240
     enum SkateboardKidStates {
205 241
         SkateboardKidState_Turning = 0, //!< Turning and Aiming?
206 242
         SkateboardKidState_Firing1 = 1,
@@ -210,7 +246,9 @@ public:
210 246
         SkateboardKidState_Dying   = 5
211 247
     };
212 248
 
213
-    // Associated with Item 31
249
+    /*!
250
+     * \brief States of the Cowboy (Item 31)
251
+     */
214 252
     enum CowboyStates {
215 253
         CowboyState_Aiming1 = 1,
216 254
         CowboyState_Walking = 2,
@@ -220,7 +258,9 @@ public:
220 258
         CowboyState_Firing  = 6
221 259
     };
222 260
 
223
-    // Associated with Item 32
261
+    /*!
262
+     * \brief States of Mr. T (Item 32)
263
+     */
224 264
     enum MrTStates {
225 265
         MrTState_Dying    = 0,
226 266
         MrTState_Standing = 1,
@@ -230,7 +270,9 @@ public:
230 270
         MrTState_Firing   = 6
231 271
     };
232 272
 
233
-    // Associated with Item 33
273
+    /*!
274
+     * \brief States of Winged Natla (Item 33)
275
+     */
234 276
     enum WingedNatlaStates {
235 277
         WingedNatlaState_Standing1 = 1,
236 278
         WingedNatlaState_Flying    = 2,
@@ -242,7 +284,9 @@ public:
242 284
         WingedNatlaState_Dying2    = 9, //!< Dying for real
243 285
     };
244 286
 
245
-    // Associated with Item 34
287
+    /*!
288
+     * \brief States of the Giant Mutant (Item 34)
289
+     */
246 290
     enum GiantMutantStates {
247 291
         GiantMutantState_Dying         = 0,
248 292
         GiantMutantState_Sitting       = 1, //!< Sitting on floor
@@ -255,7 +299,9 @@ public:
255 299
         GiantMutantState_Shaking       = 11 //!< Shaking victim with right hand
256 300
     };
257 301
 
258
-    // Associated with Item 35
302
+    /*!
303
+     * \brief States of a piece of Collapsible Floor (Item 35)
304
+     */
259 305
     enum CollapsibleFloorStates {
260 306
         CollapsibleFloorState_Stationary = 0,
261 307
         CollapsibleFloorState_Shaking    = 1,
@@ -263,37 +309,49 @@ public:
263 309
         CollapsibleFloorState_Settling   = 3  //!< Settling down
264 310
     };
265 311
 
266
-    // Associated with Item 36
312
+    /*!
313
+     * \brief States of a Swinging Blade (Item 36)
314
+     */
267 315
     enum SwingingBladeStates {
268 316
         SwingingBladeState_Stationary = 0,
269 317
         SwingingBladeState_Swinging   = 2
270 318
     };
271 319
 
272
-    // Associated with Item 38
320
+    /*!
321
+     * \brief States of a Boulder (Item 38)
322
+     */
273 323
     enum BoulderStates {
274 324
         BoulderState_Stationary = 0,
275 325
         BoulderState_Rolling    = 1
276 326
     };
277 327
 
278
-    // Associated with Item 40
328
+    /*!
329
+     * \brief States of a Dart Gun (Item 40)
330
+     */
279 331
     enum DartGunStates {
280 332
         DartGunState_Idle   = 0, //!< ?
281 333
         DartGunState_Firing = 1  //!< ?
282 334
     };
283 335
 
284
-    // Associated with Item 41
336
+    /*!
337
+     * \brief States of a Door opening upwards (Item 41)
338
+     */
285 339
     enum DoorUpwardStates {
286 340
         DoorUpwardState_Upward = 0,
287 341
         DoorUpwardState_OnSide = 1
288 342
     };
289 343
 
290
-    // Associated with Item 42
344
+    /*!
345
+     * \brief States of a Slamming Door (Item 42)
346
+     */
291 347
     enum SlammingDoorStates {
292 348
         SlammingDoorState_Open   = 0,
293 349
         SlammingDoorState_Closed = 1
294 350
     };
295 351
 
296
-    // Associated with Item 44
352
+    /*!
353
+     * \brief States of the Handle of Thors Hammer (Item 44)
354
+     */
297 355
     enum ThorHammerHandleStates {
298 356
         ThorHammerHandleState_Stationary = 0, //!< Stationary in up position
299 357
         ThorHammerHandleState_Moving1    = 1, //!< Moving down a little and returning
@@ -301,59 +359,77 @@ public:
301 359
         ThorHammerHandleState_Stopped    = 3  //!< Stopped at down position
302 360
     };
303 361
 
304
-    // Associated with Item 45
362
+    /*!
363
+     * \brief States of the Block of Thors Hammer (Item 45)
364
+     */
305 365
     enum ThorHammerBlockStates {
306 366
         ThorHammerBlockState_Stationary = 0,
307 367
         ThorHammerBlockState_Moving1    = 1, //!< Moving down a little and returning
308 368
         ThorHammerBlockState_Moving2    = 2  //!< Moving down all the way
309 369
     };
310 370
 
311
-    // Associated with Item 47
371
+    /*!
372
+     * \brief States of a Metal Rod (Item 47)
373
+     */
312 374
     enum MetalRodStates {
313 375
         MetalRodState_Stationary = 0,
314 376
         MetalRodState_Moving     = 1
315 377
     };
316 378
 
317
-    // Associated with Items 48 - 51
379
+    /*!
380
+     * \brief States of a Pushable Cubical (Item 48 - 51)
381
+     */
318 382
     enum PushableStates {
319 383
         PushableState_Stationary = 0,
320 384
         PushableState_Pulled     = 1, //!< ?
321 385
         PushableState_Pushed     = 2  //!< ?
322 386
     };
323 387
 
324
-    // Associated with Item 52
388
+    /*!
389
+     * \brief States of a Movable Tall Block (Item 52)
390
+     */
325 391
     enum MovableTallBlockStates {
326 392
         MovableTallBlockState_Stationary     = 0,
327 393
         MovableTallBlockState_MovingForward  = 1, //!< ?
328 394
         MovableTallBlockState_MovingBackward = 2  //!< ?
329 395
     };
330 396
 
331
-    // Associated with Item 53
397
+    /*!
398
+     * \brief States of Falling Pieces (Item 53)
399
+     */
332 400
     enum FallingPiecesStates {
333 401
         FallingPiecesState_Stationary = 0,
334 402
         FallingPiecesState_Falling    = 1,
335 403
         FallingPiecesState_Settling   = 2  //!< Settling down
336 404
     };
337 405
 
338
-    // Associated with Items 55, 56
406
+    /*!
407
+     * \brief States of a Switch (Item 55, 56)
408
+     */
339 409
     enum SwitchStates {
340 410
         SwitchState_Off = 0,
341 411
         SwitchState_On  = 1  //!< States may be reversed
342 412
     };
343 413
 
344
-    // Associated with Items 57 - 66
414
+    /*!
415
+     * \brief States of a Door (Item 57 - 66)
416
+     */
345 417
     enum DoorStates {
346 418
         DoorState_Closed = 0,
347 419
         DoorState_Open   = 1
348 420
     };
349 421
 
350
-    // Associated with Items 74 - 76
422
+    /*!
423
+     * \brief States of a Cog (Item 74 - 76)
424
+     */
351 425
     enum CogStates {
352 426
         CogState_Stationary = 0,
353 427
         CogState_Turning    = 1
354 428
     };
355 429
 
356
-    // Associated with Item 162
430
+    /*!
431
+     * \brief States of a Shack (Item 162)
432
+     */
357 433
     enum ShackStates {
358 434
         ShackState_StartingPosition = 0,
359 435
         ShackState_DroppingFirst    = 1, //!< Dropping after first fuse
@@ -362,19 +438,26 @@ public:
362 438
         ShackState_OnGround         = 4
363 439
     };
364 440
 
365
-    // Associated with Items 163 and 181
441
+    /*!
442
+     * \brief States of a Mutant Egg & Holder (Item 163 & 181)
443
+     */
366 444
     enum MutantEggStates {
367 445
         MutantEggState_Starting = 0,
368 446
         MutantEggState_Hatching = 1  //!< Is the fragmenting hardcoded?
369 447
     };
370 448
 
371
-    // Associated with Item 182
449
+    /*!
450
+     * \brief States of a Motorboat (Item 182)
451
+     */
372 452
     enum MotorboatStates {
373 453
         MotorboatState_StationaryInitial = 1,
374 454
         MotorboatState_Moving            = 2,
375 455
         MotorboatState_StationaryFinal   = 3,
376 456
     };
377 457
 
458
+    /*!
459
+     * \brief Items & IDs in Tomb Raider 1
460
+     */
378 461
     enum Items {
379 462
         Lara             = 0,
380 463
         PistolAnimation  = 1,

+ 58
- 26
test/greatest.h Vedi File

@@ -3,6 +3,8 @@
3 3
  *
4 4
  * Modified 2014 by Thomas Buck <xythobuz@xythobuz.de>
5 5
  * --> C++ support
6
+ * --> Included janoskk color output patch
7
+ * --> Modified it so a tty output is detected at runtime (now unix only)
6 8
  *
7 9
  * Permission to use, copy, modify, and/or distribute this software for any
8 10
  * purpose with or without fee is hereby granted, provided that the above
@@ -21,7 +23,6 @@
21 23
 #define GREATEST_H
22 24
 
23 25
 #ifdef __cplusplus
24
-#define __STDC_VERSION__ 19901L // C++11 compilers support var args
25 26
 extern "C"
26 27
 {
27 28
 #endif
@@ -81,6 +82,7 @@ int main(int argc, char **argv) {
81 82
 #include <stdio.h>
82 83
 #include <string.h>
83 84
 #include <time.h>
85
+#include <unistd.h>
84 86
 
85 87
 
86 88
 /***********
@@ -102,6 +104,15 @@ int main(int argc, char **argv) {
102 104
 #define GREATEST_USE_ABBREVS 1
103 105
 #endif
104 106
 
107
+/* Colorize the passed/failed results */
108
+#ifndef COLOR_FAIL
109
+#define COLOR_FAIL  "\033[22;31;1m"
110
+#endif
111
+#ifndef COLOR_PASS
112
+#define COLOR_PASS  "\033[22;32m"
113
+#endif
114
+#define COLOR_RESET "\033[22;0m"
115
+
105 116
 
106 117
 /*********
107 118
  * Types *
@@ -229,7 +240,7 @@ void GREATEST_SET_TEARDOWN_CB(greatest_teardown_cb *cb, void *udata);
229 240
 
230 241
 /* If __VA_ARGS__ (C99) is supported, allow parametric testing
231 242
  * without needing to manually manage the argument struct. */
232
-#if __STDC_VERSION__ >= 19901L
243
+#if defined __cplusplus || (__STDC_VERSION__ >= 19901L)
233 244
 #define GREATEST_RUN_TESTp(TEST, ...)                                   \
234 245
     do {                                                                \
235 246
         if (greatest_pre_test(#TEST) == 1) {                            \
@@ -421,10 +432,18 @@ static void greatest_run_suite(greatest_suite_cb *suite_cb,             \
421 432
     GREATEST_SET_TIME(greatest_info.suite.post_suite);                  \
422 433
     if (greatest_info.suite.tests_run > 0) {                            \
423 434
         fprintf(GREATEST_STDOUT,                                        \
424
-            "\n%u tests - %u pass, %u fail, %u skipped",                \
435
+            "\n%u tests - %u %spass%s, %u %sfail%s, %u skipped",        \
425 436
             greatest_info.suite.tests_run,                              \
426 437
             greatest_info.suite.passed,                                 \
438
+            (isatty(fileno(GREATEST_STDOUT))) ? (                       \
439
+            (!greatest_info.suite.failed) ? COLOR_PASS : COLOR_RESET    \
440
+            ) : "",                                                     \
441
+            (isatty(fileno(GREATEST_STDOUT))) ? COLOR_RESET : "",       \
427 442
             greatest_info.suite.failed,                                 \
443
+            (isatty(fileno(GREATEST_STDOUT))) ? (                       \
444
+            (greatest_info.suite.failed) ? COLOR_FAIL : COLOR_RESET     \
445
+            ) : "",                                                     \
446
+            (isatty(fileno(GREATEST_STDOUT))) ? COLOR_RESET : "",       \
428 447
             greatest_info.suite.skipped);                               \
429 448
         GREATEST_CLOCK_DIFF(greatest_info.suite.pre_suite,              \
430 449
             greatest_info.suite.post_suite);                            \
@@ -442,8 +461,11 @@ static void greatest_run_suite(greatest_suite_cb *suite_cb,             \
442 461
                                                                         \
443 462
 void greatest_do_pass(const char *name) {                               \
444 463
     if (GREATEST_IS_VERBOSE()) {                                        \
445
-        fprintf(GREATEST_STDOUT, "PASS %s: %s",                         \
446
-            name, greatest_info.msg ? greatest_info.msg : "");          \
464
+        fprintf(GREATEST_STDOUT,                                        \
465
+                (isatty(fileno(GREATEST_STDOUT))) ?                     \
466
+                COLOR_PASS "PASS" COLOR_RESET " %s: %s" :               \
467
+                "PASS %s: %s",                                          \
468
+                name, greatest_info.msg ? greatest_info.msg : "");      \
447 469
     } else {                                                            \
448 470
         fprintf(GREATEST_STDOUT, ".");                                  \
449 471
     }                                                                   \
@@ -453,6 +475,8 @@ void greatest_do_pass(const char *name) {                               \
453 475
 void greatest_do_fail(const char *name) {                               \
454 476
     if (GREATEST_IS_VERBOSE()) {                                        \
455 477
         fprintf(GREATEST_STDOUT,                                        \
478
+            (isatty(fileno(GREATEST_STDOUT))) ?                         \
479
+            COLOR_FAIL "FAIL" COLOR_RESET " %s: %s (%s:%u)" :           \
456 480
             "FAIL %s: %s (%s:%u)",                                      \
457 481
             name, greatest_info.msg ? greatest_info.msg : "",           \
458 482
             greatest_info.fail_file, greatest_info.fail_line);          \
@@ -462,7 +486,10 @@ void greatest_do_fail(const char *name) {                               \
462 486
         if (greatest_info.col % greatest_info.width != 0)               \
463 487
             fprintf(GREATEST_STDOUT, "\n");                             \
464 488
         greatest_info.col = 0;                                          \
465
-        fprintf(GREATEST_STDOUT, "FAIL %s: %s (%s:%u)\n",               \
489
+        fprintf(GREATEST_STDOUT,                                        \
490
+            (isatty(fileno(GREATEST_STDOUT))) ?                         \
491
+            COLOR_FAIL "FAIL" COLOR_RESET " %s: %s (%s:%u)\n" :         \
492
+            "FAIL %s: %s (%s:%u)\n",                                    \
466 493
             name,                                                       \
467 494
             greatest_info.msg ? greatest_info.msg : "",                 \
468 495
             greatest_info.fail_file, greatest_info.fail_line);          \
@@ -510,38 +537,38 @@ greatest_run_info greatest_info
510 537
 /* Handle command-line arguments, etc. */
511 538
 #define GREATEST_MAIN_BEGIN()                                           \
512 539
     do {                                                                \
513
-        int _i = 0;                                                      \
540
+        int _i = 0;                                                     \
514 541
         memset(&greatest_info, 0, sizeof(greatest_info));               \
515 542
         if (greatest_info.width == 0) {                                 \
516 543
             greatest_info.width = GREATEST_DEFAULT_WIDTH;               \
517 544
         }                                                               \
518
-        for (_i = 1; _i < argc; _i++) {                                    \
519
-            if (0 == strcmp("-t", argv[_i])) {                           \
520
-                if (argc <= _i + 1) {                                    \
545
+        for (_i = 1; _i < argc; _i++) {                                 \
546
+            if (0 == strcmp("-t", argv[_i])) {                          \
547
+                if (argc <= _i + 1) {                                   \
521 548
                     greatest_usage(argv[0]);                            \
522 549
                     exit(EXIT_FAILURE);                                 \
523 550
                 }                                                       \
524
-                greatest_info.test_filter = argv[_i+1];                  \
525
-                _i++;                                                    \
526
-            } else if (0 == strcmp("-s", argv[_i])) {                    \
527
-                if (argc <= _i + 1) {                                    \
551
+                greatest_info.test_filter = argv[_i+1];                 \
552
+                _i++;                                                   \
553
+            } else if (0 == strcmp("-s", argv[_i])) {                   \
554
+                if (argc <= _i + 1) {                                   \
528 555
                     greatest_usage(argv[0]);                            \
529 556
                     exit(EXIT_FAILURE);                                 \
530 557
                 }                                                       \
531
-                greatest_info.suite_filter = argv[_i+1];                 \
532
-                _i++;                                                    \
533
-            } else if (0 == strcmp("-f", argv[_i])) {                    \
558
+                greatest_info.suite_filter = argv[_i+1];                \
559
+                _i++;                                                   \
560
+            } else if (0 == strcmp("-f", argv[_i])) {                   \
534 561
                 greatest_info.flags |= GREATEST_FLAG_FIRST_FAIL;        \
535
-            } else if (0 == strcmp("-v", argv[_i])) {                    \
562
+            } else if (0 == strcmp("-v", argv[_i])) {                   \
536 563
                 greatest_info.flags |= GREATEST_FLAG_VERBOSE;           \
537
-            } else if (0 == strcmp("-l", argv[_i])) {                    \
564
+            } else if (0 == strcmp("-l", argv[_i])) {                   \
538 565
                 greatest_info.flags |= GREATEST_FLAG_LIST_ONLY;         \
539
-            } else if (0 == strcmp("-h", argv[_i])) {                    \
566
+            } else if (0 == strcmp("-h", argv[_i])) {                   \
540 567
                 greatest_usage(argv[0]);                                \
541 568
                 exit(EXIT_SUCCESS);                                     \
542 569
             } else {                                                    \
543 570
                 fprintf(GREATEST_STDOUT,                                \
544
-                    "Unknown argument '%s'\n", argv[_i]);                \
571
+                    "Unknown argument '%s'\n", argv[_i]);               \
545 572
                 greatest_usage(argv[0]);                                \
546 573
                 exit(EXIT_FAILURE);                                     \
547 574
             }                                                           \
@@ -559,9 +586,14 @@ greatest_run_info greatest_info
559 586
                 greatest_info.end);                                     \
560 587
             fprintf(GREATEST_STDOUT, "\n");                             \
561 588
             fprintf(GREATEST_STDOUT,                                    \
562
-                "Pass: %u, fail: %u, skip: %u.\n",                      \
563
-                greatest_info.passed,                                   \
564
-                greatest_info.failed, greatest_info.skipped);           \
589
+                "%sPass: %u, fail: %u, "                                \
590
+                "skip: %u.%s\n",                                        \
591
+                (isatty(fileno(GREATEST_STDOUT))) ?                     \
592
+                ((greatest_info.failed) ? COLOR_FAIL : COLOR_PASS) :    \
593
+                "", greatest_info.passed,                               \
594
+                greatest_info.failed,                                   \
595
+                greatest_info.skipped,                                  \
596
+                (isatty(fileno(GREATEST_STDOUT))) ? COLOR_RESET : "");  \
565 597
         }                                                               \
566 598
         return (greatest_info.failed > 0                                \
567 599
             ? EXIT_FAILURE : EXIT_SUCCESS);                             \
@@ -592,9 +624,9 @@ greatest_run_info greatest_info
592 624
 #define SET_SETUP      GREATEST_SET_SETUP_CB
593 625
 #define SET_TEARDOWN   GREATEST_SET_TEARDOWN_CB
594 626
 
595
-#if __STDC_VERSION__ >= 19901L
596
-#endif /* C99 */
627
+#if defined __cplusplus || (__STDC_VERSION__ >= 19901L)
597 628
 #define RUN_TESTp      GREATEST_RUN_TESTp
629
+#endif
598 630
 #endif /* USE_ABBREVS */
599 631
 
600 632
 #ifdef __cplusplus

Loading…
Annulla
Salva