Skip to content

Commit

Permalink
[feat] Add skip_test()
Browse files Browse the repository at this point in the history
  • Loading branch information
thoni56 committed Nov 7, 2024
1 parent 1f66941 commit 91ba387
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Required cmake version
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.10)

project(cgreen)

Expand Down Expand Up @@ -34,7 +33,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
# automatically updates that...
set(APPLICATION_VERSION_MAJOR "1")
set(APPLICATION_VERSION_MINOR "6")
set(APPLICATION_VERSION_PATCH "3")
set(APPLICATION_VERSION_PATCH "4")

set(APPLICATION_VERSION ${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}${APPLICATION_VERSION_STATUS})
add_definitions(-DVERSION="${APPLICATION_VERSION}")
Expand Down
5 changes: 5 additions & 0 deletions doc/cgreen-guide-en.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ assert_that(actual, <constraint>);

NOTE: Sometimes you just want to fail the test explicitly, and there is a function for that too, `fail_test(const char *message)`.
And there is a function to explicitly pass, `pass_test(void)`.
There is also a function to programmatically skip a test, `skip_test(void)` to complement the `xEnsure` notation (see <<xensure>>).

Assertions send messages to *Cgreen*, which in turn outputs the results.

Expand Down Expand Up @@ -2502,6 +2503,10 @@ With this method, it is a one character change to temporarily ignore, and un-ign
It is also easily found using text searches through a complete source tree.
*Cgreen* will also tally the skipped tests, so it is clearly visible that you have some skipped test when you run them.

NOTE: You can also programmatically decide to skip a test depending on some run-time information.
You do that simply by checking for the condition and calling `skip_test()` which will tally the test as skipped.

NOTE: `skip_test()` does *not* exit your test function so you need to take care that continuing after the call does not trigger any undecided behaviour.


[[changing_style]]
Expand Down
1 change: 1 addition & 0 deletions include/cgreen/assertions.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace cgreen {

#define pass_test() assert_true(true)
#define fail_test(...) assert_true_with_message(false, __VA_ARGS__)
#define skip_test() send_reporter_skipped_notification(get_test_reporter())


/* Utility: */
Expand Down
4 changes: 2 additions & 2 deletions include/cgreen/cgreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#include <cgreen/runner.h>
#include <cgreen/boxed_double.h>

#define CGREEN_VERSION "1.6.3"
#define CGREEN_VERSION "1.6.4"
#define CGREEN_VERSION_MAJOR 1
#define CGREEN_VERSION_MINOR 6
#define CGREEN_VERSION_PATCH 3
#define CGREEN_VERSION_PATCH 4

extern char *cgreen_library_version;
extern char *cgreen_library_revision;

0 comments on commit 91ba387

Please sign in to comment.