| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- enable_testing()
- # MUST do this before including IDNA
- # because it will otherwise poison GTest with BUILD_GMOCK=OFF
- find_package(GTest CONFIG REQUIRED COMPONENTS gtest gmock)
- find_package(jsoncpp REQUIRED)
- find_package(CURL REQUIRED)
- # ICU Components Reference:
- # https://cmake.org/cmake/help/latest/module/FindICU.html
- # ICU components = data, i18n, io, le, lx, test, tu and uc.
- find_package(ICU 77.1 COMPONENTS uc i18n)
- FetchContent_Declare(
- IDNA
- GIT_REPOSITORY https://github.com/ada-url/idna.git
- GIT_TAG 0.5.0
- )
- FetchContent_MakeAvailable(IDNA)
- FetchContent_Declare(
- json_schema_test_suite
- GIT_REPOSITORY https://github.com/json-schema-org/JSON-Schema-Test-Suite.git
- GIT_TAG Test-JSON-Schema-Acceptance-1.037
- )
- FetchContent_MakeAvailable(json_schema_test_suite)
- include(GoogleTest)
- add_executable(annotation_test annotation_test.cxx)
- target_link_libraries(annotation_test GTest::gtest GTest::gmock jsoncpp_lib)
- gtest_discover_tests(annotation_test)
- add_executable(extension_test extension_test.cxx)
- target_link_libraries(extension_test GTest::gtest GTest::gmock jsoncpp_lib)
- gtest_discover_tests(extension_test)
- add_executable(selfvalidate_test selfvalidate_test.cxx)
- target_compile_definitions(selfvalidate_test PUBLIC JVALIDATE_USE_EXCEPTIONS)
- if (${json_schema_test_suite_POPULATED})
- target_compile_definitions(selfvalidate_test
- PUBLIC
- JVALIDATE_JSON_SCHEMA_TEST_SUITE_DIR="${json_schema_test_suite_SOURCE_DIR}"
- )
- endif()
- target_link_libraries(selfvalidate_test GTest::gtest GTest::gmock jsoncpp_lib CURL::libcurl)
- string(
- JOIN ":"
- SelfValidateTest_Unsupported
- "*optional_content"
- "*optional_*ecmascript_regex"
- "*optional_zeroTerminatedFloats"
- )
- set(SelfValidateTest_Unsupported_Suites "")
- set(SelfValidateTest_Unsupported_Cases "*leap second")
- if (ICU_FOUND)
- target_compile_definitions(selfvalidate_test PUBLIC JVALIDATE_HAS_ICU=1)
- target_link_libraries(annotation_test ICU::uc ICU::i18n)
- target_link_libraries(extension_test ICU::uc ICU::i18n)
- target_link_libraries(selfvalidate_test ICU::uc ICU::i18n)
- else()
- target_compile_definitions(selfvalidate_test PUBLIC JVALIDATE_HAS_ICU=0)
- string(
- APPEND SelfValidateTest_Unsupported
- ":*optional_non_bmp_regex"
- )
- endif()
- if (idna_POPULATED)
- target_compile_definitions(selfvalidate_test PUBLIC JVALIDATE_HAS_IDNA=1)
- target_link_libraries(annotation_test ada-idna)
- target_link_libraries(extension_test ada-idna)
- target_link_libraries(selfvalidate_test ada-idna)
- else()
- target_compile_definitions(selfvalidate_test PUBLIC JVALIDATE_HAS_IDNA=0)
- string(
- APPEND SelfValidateTest_Unsupported
- ":*optional_*iri*"
- ":*optional_*idn*"
- ":*optional_*uri_template*"
- )
- string(
- APPEND SelfValidateTest_Unsupported_Suites
- ":*punycode*"
- ":*puny-code"
- )
- string(
- APPEND SelfValidateTest_Unsupported_Cases
- ":*punycode*"
- ":*puny-code"
- )
- endif()
- gtest_discover_tests(selfvalidate_test
- EXTRA_ARGS --json_suite_filter=-${SelfValidateTest_Unsupported_Suites}
- --json_case_filter=-${SelfValidateTest_Unsupported_Cases}
- TEST_FILTER -${SelfValidateTest_Unsupported})
|