-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👷 gucc: use doctest instead of raw C asserts
- Loading branch information
1 parent
deaf0e8
commit b3929ef
Showing
21 changed files
with
530 additions
and
378 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef DOCTEST_COMPATIBILITY_H | ||
Check notice on line 1 in gucc/tests/doctest_compatibility.h GitHub Actions / cpp-linterRun clang-format on gucc/tests/doctest_compatibility.h
|
||
#define DOCTEST_COMPATIBILITY_H | ||
|
||
#define DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS | ||
#define DOCTEST_THREAD_LOCAL // enable single-threaded builds on XCode 6/7 - https://github.com/onqtam/doctest/issues/172 | ||
#include <doctest/doctest.h> | ||
|
||
// Catch doesn't require a semicolon after CAPTURE but doctest does | ||
#undef CAPTURE | ||
#define CAPTURE(x) DOCTEST_CAPTURE(x); | ||
|
||
// Sections from Catch are called Subcases in doctest and don't work with std::string by default | ||
#undef SUBCASE | ||
#define SECTION(x) DOCTEST_SUBCASE(x) | ||
|
||
// convenience macro around INFO since it doesn't support temporaries (it is optimized to avoid allocations for runtime speed) | ||
#define INFO_WITH_TEMP_IMPL(x, var_name) const auto var_name = x; INFO(var_name) // lvalue! | ||
#define INFO_WITH_TEMP(x) INFO_WITH_TEMP_IMPL(x, DOCTEST_ANONYMOUS(DOCTEST_STD_STRING_)) | ||
|
||
// doctest doesn't support THROWS_WITH for std::string out of the box (has to include <string>...) | ||
#define CHECK_THROWS_WITH_STD_STR_IMPL(expr, str, var_name) \ | ||
do { \ | ||
std::string var_name = str; \ | ||
CHECK_THROWS_WITH(expr, var_name.c_str()); \ | ||
} while (false) | ||
#define CHECK_THROWS_WITH_STD_STR(expr, str) \ | ||
CHECK_THROWS_WITH_STD_STR_IMPL(expr, str, DOCTEST_ANONYMOUS(DOCTEST_STD_STRING_)) | ||
|
||
// Catch does this by default | ||
using doctest::Approx; | ||
|
||
#endif |
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,103 +1,111 @@ | ||
doctest_main_lib = static_library('doctest_main', | ||
sources : [ | ||
'unit.cpp', | ||
], | ||
include_directories : [include_directories('.')], | ||
dependencies: doctest | ||
) | ||
|
||
executable( | ||
'test-initcpio', | ||
files('unit-initcpio.cpp'), | ||
dependencies: deps, | ||
link_with: [gucc_lib], | ||
dependencies: [deps, doctest], | ||
link_with: [gucc_lib, doctest_main_lib], | ||
include_directories: [include_directories('../include')], | ||
install: false) | ||
|
||
executable( | ||
'test-pacmanconf', | ||
files('unit-pacmanconf.cpp'), | ||
dependencies: deps, | ||
link_with: [gucc_lib], | ||
dependencies: [deps, doctest], | ||
link_with: [gucc_lib, doctest_main_lib], | ||
include_directories: [include_directories('../include')], | ||
install: false) | ||
|
||
executable( | ||
'test-fstab_gen', | ||
files('unit-fstab_gen.cpp'), | ||
dependencies: deps, | ||
link_with: [gucc_lib], | ||
dependencies: [deps, doctest], | ||
link_with: [gucc_lib, doctest_main_lib], | ||
include_directories: [include_directories('../include')], | ||
install: false) | ||
|
||
executable( | ||
'test-crypttab_gen', | ||
files('unit-crypttab_gen.cpp'), | ||
dependencies: deps, | ||
link_with: [gucc_lib], | ||
dependencies: [deps, doctest], | ||
link_with: [gucc_lib, doctest_main_lib], | ||
include_directories: [include_directories('../include')], | ||
install: false) | ||
|
||
executable( | ||
'test-grub_config_gen', | ||
files('unit-grub_config_gen.cpp'), | ||
dependencies: deps, | ||
link_with: [gucc_lib], | ||
dependencies: [deps, doctest], | ||
link_with: [gucc_lib, doctest_main_lib], | ||
include_directories: [include_directories('../include')], | ||
install: false) | ||
|
||
executable( | ||
'test-mtab', | ||
files('unit-mtab.cpp'), | ||
dependencies: deps, | ||
link_with: [gucc_lib], | ||
dependencies: [deps, doctest], | ||
link_with: [gucc_lib, doctest_main_lib], | ||
include_directories: [include_directories('../include')], | ||
install: false) | ||
|
||
executable( | ||
'test-locale', | ||
files('unit-locale.cpp'), | ||
dependencies: deps, | ||
link_with: [gucc_lib], | ||
dependencies: [deps, doctest], | ||
link_with: [gucc_lib, doctest_main_lib], | ||
include_directories: [include_directories('../include')], | ||
install: false) | ||
|
||
executable( | ||
'test-package_profiles', | ||
files('unit-package_profiles.cpp'), | ||
dependencies: deps, | ||
link_with: [gucc_lib], | ||
dependencies: [deps, doctest], | ||
link_with: [gucc_lib, doctest_main_lib], | ||
include_directories: [include_directories('../include')], | ||
install: false) | ||
|
||
executable( | ||
'test-fetch_file', | ||
files('unit-fetch_file.cpp'), | ||
dependencies: deps, | ||
link_with: [gucc_lib], | ||
dependencies: [deps, doctest], | ||
link_with: [gucc_lib, doctest_main_lib], | ||
include_directories: [include_directories('../include')], | ||
install: false) | ||
|
||
executable( | ||
'test-kernel_params', | ||
files('unit-kernel_params.cpp'), | ||
dependencies: deps, | ||
link_with: [gucc_lib], | ||
dependencies: [deps, doctest], | ||
link_with: [gucc_lib, doctest_main_lib], | ||
include_directories: [include_directories('../include')], | ||
install: false) | ||
|
||
executable( | ||
'test-btrfs', | ||
files('unit-btrfs.cpp'), | ||
dependencies: deps, | ||
link_with: [gucc_lib], | ||
dependencies: [deps, doctest], | ||
link_with: [gucc_lib, doctest_main_lib], | ||
include_directories: [include_directories('../include')], | ||
install: false) | ||
|
||
executable( | ||
'test-refind_config_gen', | ||
files('unit-refind_config_gen.cpp'), | ||
dependencies: deps, | ||
link_with: [gucc_lib], | ||
dependencies: [deps, doctest], | ||
link_with: [gucc_lib, doctest_main_lib], | ||
include_directories: [include_directories('../include')], | ||
install: false) | ||
|
||
executable( | ||
'test-refind_extra_kern_strings', | ||
files('unit-refind_extra_kern_strings.cpp'), | ||
dependencies: deps, | ||
link_with: [gucc_lib], | ||
dependencies: [deps, doctest], | ||
link_with: [gucc_lib, doctest_main_lib], | ||
include_directories: [include_directories('../include')], | ||
install: false) |
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
Oops, something went wrong.