-
-
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.
- Loading branch information
Showing
7 changed files
with
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
Include(FetchContent) | ||
|
||
|
||
# Done as a function so that updates to variables like | ||
# CMAKE_CXX_FLAGS don't propagate out to other | ||
# targets | ||
function(adobe_contract_checking_setup_dependencies) | ||
|
||
# For each dependency, see if it's | ||
# already been provided to us by a parent project | ||
|
||
if(BUILD_TESTING) | ||
FetchContent_Declare( | ||
googletest | ||
URL https://github.com/google/googletest/archive/ff233bdd4cac0a0bf6e5cd45bda3406814cb2796.zip | ||
) | ||
# For Windows: Prevent overriding the parent project's compiler/linker settings | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
FetchContent_MakeAvailable(googletest) | ||
|
||
endfunction() | ||
FetchContent_Declare( | ||
icm | ||
GIT_REPOSITORY https://github.com/iboB/icm.git | ||
GIT_TAG v1.5.1 | ||
) | ||
|
||
FetchContent_MakeAvailable(googletest icm) | ||
list(APPEND CMAKE_MODULE_PATH "${icm_SOURCE_DIR}") | ||
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
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,21 @@ | ||
#include "adobe/contract_checks.hpp" | ||
#include <gtest/gtest.h> | ||
|
||
struct F | ||
{ | ||
template<class T, class U, class V, class W> | ||
void operator()(const T & /*unused*/, | ||
const U & /*unused*/, | ||
const V & /*unused*/, | ||
const W & /*unused*/) const | ||
{} | ||
}; | ||
const F f; | ||
|
||
TEST(ArityChecking, TooManyArgumentsNotAlwaysDetected) | ||
{ | ||
// These don't fail, so our arity detection is weak. | ||
// https://github.com/stlab/adobe-contract-checks/issues/19 | ||
ADOBE_PRECONDITION(true, "message", f); | ||
ADOBE_INVARIANT(true, "message", f); | ||
} |
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,5 @@ | ||
#define ADOBE_CONTRACT_VIOLATION misconfigured | ||
// CI somehow escapes quotes in static assertion strings, so we can't check for those below. | ||
|
||
// build error: Unknown configuration ADOBE_CONTRACT_VIOLATION=misconfigured. Valid values are | ||
#include "adobe/contract_checks.hpp" |
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,6 @@ | ||
#include "adobe/contract_checks.hpp" | ||
int main() | ||
{ | ||
// build error:too_few_arguments_test.cpp | ||
ADOBE_PRECONDITION(); | ||
} |
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,11 @@ | ||
#include "adobe/contract_checks.hpp" | ||
|
||
int main() | ||
{ | ||
// It's hard to pass too many arguments without detection... | ||
|
||
// build error:too_many_arguments_test.cpp | ||
ADOBE_PRECONDITION(true, "message", 1); | ||
|
||
// ...but see inadequate_arity_checking_tests.cpp | ||
} |