-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
t/unit-tests: convert ctype tests to use clar
Convert the ctype tests to use the new clar unit testing framework. Introduce a new function `cl_failf()` that allows us to print a formatted error message, which we can use to point out which of the characters was classified incorrectly. This results in output like this on failure: # start of suite 1: ctype ok 1 - ctype::isspace not ok 2 - ctype::isdigit --- reason: | Test failed. 0x61 is classified incorrectly at: file: 't/unit-tests/ctype.c' line: 38 function: 'test_ctype__isdigit' --- ok 3 - ctype::isalpha ok 4 - ctype::isalnum ok 5 - ctype::is_glob_special ok 6 - ctype::is_regex_special ok 7 - ctype::is_pathspec_magic ok 8 - ctype::isascii ok 9 - ctype::islower ok 10 - ctype::isupper ok 11 - ctype::iscntrl ok 12 - ctype::ispunct ok 13 - ctype::isxdigit ok 14 - ctype::isprint Signed-off-by: Patrick Steinhardt <[email protected]>
- Loading branch information
Showing
3 changed files
with
67 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
#include "git-compat-util.h" | ||
#include "clar/clar.h" | ||
#include "clar-decls.h" | ||
#include "strbuf.h" | ||
|
||
#define cl_failf(fmt, ...) do { \ | ||
char *desc = xstrfmt(fmt, __VA_ARGS__); \ | ||
clar__fail(__FILE__, __func__, __LINE__, "Test failed.", desc, 1); \ | ||
free(desc); \ | ||
} while (0) |