Fix: Use test from suite

This commit is contained in:
Leon De Andrade 2021-09-07 21:41:45 +02:00
parent 343bbfc838
commit 263db3dd7e
4 changed files with 88 additions and 23 deletions

View File

@ -51,6 +51,16 @@ set(JSON_VALIDATOR_INSTALL ON)
# here we decice how nlohmann::json is found and used to build this project # here we decice how nlohmann::json is found and used to build this project
include(FetchContent)
FetchContent_Declare(json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.9.1
)
set(JSON_BuildTests OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(json)
# first, check whether a nlohmann_json::nlohmann_json target exists already # first, check whether a nlohmann_json::nlohmann_json target exists already
# -> we are used as a sub-directory from within another project # -> we are used as a sub-directory from within another project
if(TARGET nlohmann_json::nlohmann_json) if(TARGET nlohmann_json::nlohmann_json)
@ -60,8 +70,8 @@ if(TARGET nlohmann_json::nlohmann_json)
PUBLIC nlohmann_json::nlohmann_json) PUBLIC nlohmann_json::nlohmann_json)
set(JSON_VALIDATOR_INSTALL OFF) set(JSON_VALIDATOR_INSTALL OFF)
set(BUILD_TESTS OFF) # set(BUILD_TESTS OFF)
set(BUILD_EXAMPLES OFF) # set(BUILD_EXAMPLES OFF)
elseif(TARGET nlohmann_json) # or nlohmann_json, we are used a sub-project next to nlohmann-json's git repo elseif(TARGET nlohmann_json) # or nlohmann_json, we are used a sub-project next to nlohmann-json's git repo
message(STATUS "Found nlohmann_json-target - linking with it") message(STATUS "Found nlohmann_json-target - linking with it")
@ -168,6 +178,7 @@ if (BUILD_EXAMPLES)
endif() endif()
if (BUILD_TESTS) if (BUILD_TESTS)
message("Tests!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
# test-zone # test-zone
enable_testing() enable_testing()
add_subdirectory(test) add_subdirectory(test)

View File

@ -64,7 +64,6 @@ if(JSON_SCHEMA_TEST_SUITE_PATH)
JSON-Suite::Optional::Format::uri-reference JSON-Suite::Optional::Format::uri-reference
JSON-Suite::Optional::Format::uri-template JSON-Suite::Optional::Format::uri-template
JSON-Suite::Optional::Format::uri JSON-Suite::Optional::Format::uri
JSON-Suite::Optional::Format::uuid
PROPERTIES PROPERTIES
WILL_FAIL ON) WILL_FAIL ON)

View File

@ -1,28 +1,83 @@
[ [
{ {
"description": "validation of uuids", "description": "uuid format",
"schema": { "schema": {
"format": "uuid" "format": "uuid"
}, },
"tests": [ "tests": [
{ {
"description": "a valid uuid", "description": "all upper-case",
"data": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "data": "2EB8AA08-AA98-11EA-B4AA-73B441D16380",
"valid": true "valid": true
}, },
{ {
"description": "an invalid uuid with shorter length", "description": "all lower-case",
"data": "3fa85f64-5717-4562-b3fc-2c963", "data": "2eb8aa08-aa98-11ea-b4aa-73b441d16380",
"valid": true
},
{
"description": "mixed case",
"data": "2eb8aa08-AA98-11ea-B4Aa-73B441D16380",
"valid": true
},
{
"description": "all zeroes is valid",
"data": "00000000-0000-0000-0000-000000000000",
"valid": true
},
{
"description": "wrong length",
"data": "2eb8aa08-aa98-11ea-b4aa-73b441d1638",
"valid": false "valid": false
}, },
{ {
"description": "an invalid uuid with missing hyphens", "description": "missing section",
"data": "3fa85f6457174562b3fc2c963f66afa6", "data": "2eb8aa08-aa98-11ea-73b441d16380",
"valid": false
},
{
"description": "bad characters (not hex)",
"data": "2eb8aa08-aa98-11ea-b4ga-73b441d16380",
"valid": false
},
{
"description": "no dashes",
"data": "2eb8aa08aa9811eab4aa73b441d16380",
"valid": false
},
{
"description": "too few dashes",
"data": "2eb8aa08aa98-11ea-b4aa73b441d16380",
"valid": false
},
{
"description": "too many dashes",
"data": "2eb8-aa08-aa98-11ea-b4aa73b44-1d16380",
"valid": false
},
{
"description": "dashes in the wrong spot",
"data": "2eb8aa08aa9811eab4aa73b441d16380----",
"valid": false
},
{
"description": "valid version 4",
"data": "98d80576-482e-427f-8434-7f86890ab222",
"valid": true "valid": true
}, },
{ {
"description": "an invalid uuid with hyphens at wrong position", "description": "valid version 5",
"data": "3fa85f645-717-4562b-3fc2c9-63f66afa6", "data": "99c17cbb-656f-564a-940f-1a4568f03487",
"valid": true
},
{
"description": "hypothetical version 6",
"data": "99c17cbb-656f-664a-940f-1a4568f03487",
"valid": true
},
{
"description": "hypothetical version 15",
"data": "99c17cbb-656f-f64a-940f-1a4568f03487",
"valid": true "valid": true
} }
] ]

View File

@ -1,15 +1,15 @@
# Configure install script # Configure install script
configure_file(test.sh.in # configure_file(test.sh.in
${CMAKE_CURRENT_BINARY_DIR}/test.sh @ONLY) # ${CMAKE_CURRENT_BINARY_DIR}/test.sh @ONLY)
get_filename_component(TEST_NAME # get_filename_component(TEST_NAME
${CMAKE_CURRENT_SOURCE_DIR} # ${CMAKE_CURRENT_SOURCE_DIR}
NAME) # NAME)
# this build test only works, if nlohmann-json was found via a cmake-package # # this build test only works, if nlohmann-json was found via a cmake-package
if(TARGET nlohmann_json::nlohmann_json) # if(TARGET nlohmann_json::nlohmann_json)
add_test(NAME Build::${TEST_NAME} # add_test(NAME Build::${TEST_NAME}
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test.sh # COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif() # endif()