| 1 | #include <cgreen/cgreen.h> |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | #include <stdlib.h> |
| 5 | #include <unistd.h> |
| 6 | |
| 7 | #ifdef __cplusplus |
| 8 | using namespace cgreen; |
| 9 | #endif |
| 10 | |
| 11 | Describe(FailureMessage); |
| 12 | BeforeEach(FailureMessage) {} |
| 13 | AfterEach(FailureMessage) {} |
| 14 | |
| 15 | Ensure(FailureMessage, for_time_out_in_only_one_second) { |
| 16 | die_in(1); |
| 17 | sleep(10); |
| 18 | } |
| 19 | |
| 20 | Ensure(FailureMessage, for_CGREEN_PER_TEST_TIMEOUT) { |
| 21 | // Setting the environment variable here does not work |
| 22 | // It needs to be set before the runner forks |
| 23 | // setenv("CGREEN_PER_TEST_TIMEOUT", "2", true); |
| 24 | // so we leave that to the test environment... |
| 25 | |
| 26 | // And fail if there is no environment variable set |
| 27 | assert_that(getenv("CGREEN_PER_TEST_TIMEOUT"), is_not_equal_to(NULL)); |
| 28 | sleep(3); |
| 29 | fail_test("This test should have been aborted within CGREEN_PER_TEST_TIMEOUT seconds and not get here. When running this test you need to define CGREEN_PER_TEST_TIMEOUT=2."); |
| 30 | } |
| 31 | |
| 32 | #ifdef __cplusplus |
| 33 | Ensure(FailureMessage, increments_exception_count_when_throwing) { |
| 34 | throw; |
| 35 | } |
| 36 | #endif |
| 37 |