| 1 | #define SDL_MAIN_HANDLED |
| 2 | #include <cbehave/cbehave.h> |
| 3 | |
| 4 | #include <animated_counter.h> |
| 5 | |
| 6 | |
| 7 | FEATURE(AnimatedCounterUpdate, "Update animated counter") |
| 8 | SCENARIO("Normal update") |
| 9 | GIVEN("an animated counter") |
| 10 | const int max = 100; |
| 11 | AnimatedCounter c = AnimatedCounterNew("foo", max); |
| 12 | |
| 13 | WHEN("I update it") |
| 14 | AnimatedCounterUpdate(&c, 1); |
| 15 | |
| 16 | THEN("the current counter should be greater than 0") |
| 17 | SHOULD_INT_GT(c.current, 0); |
| 18 | AND("less than the max") |
| 19 | SHOULD_INT_LT(c.current, max); |
| 20 | SCENARIO_END |
| 21 | |
| 22 | SCENARIO("Negative max") |
| 23 | GIVEN("an animated counter with negative max") |
| 24 | const int max = -100; |
| 25 | AnimatedCounter c = AnimatedCounterNew("foo", max); |
| 26 | |
| 27 | WHEN("I update it") |
| 28 | AnimatedCounterUpdate(&c, 1); |
| 29 | |
| 30 | THEN("the current counter should be less than 0") |
| 31 | SHOULD_INT_LT(c.current, 0); |
| 32 | AND("greater than than the max") |
| 33 | SHOULD_INT_GT(c.current, max); |
| 34 | SCENARIO_END |
| 35 | FEATURE_END |
| 36 | |
| 37 | CBEHAVE_RUN( |
| 38 | "Animated counter features are:", |
| 39 | TEST_FEATURE(AnimatedCounterUpdate) |
| 40 | ) |