project(cutelyst_tests)

find_package(Qt5Test 5.6.0 REQUIRED)

add_library(coverage_test STATIC coverageobject.cpp
  coverageobject.cpp
  ${_testresource_rcc_src}
)
target_compile_features(coverage_test
  PRIVATE
    cxx_auto_type
  PUBLIC
    cxx_nullptr
    cxx_override
)
target_link_libraries(coverage_test Qt5::Test CutelystQt5::Core Qt5::Network CutelystQt5::Utils::Validator)

macro(CUTELYST_TEMPLATES_UNIT_TESTS)
  foreach(_testname ${ARGN})
    add_executable(${_testname}_exec
                  ${_testname}.cpp
    )
    add_test(NAME ${_testname} COMMAND ${_testname}_exec)
    target_compile_features(${_testname}_exec
      PRIVATE
        cxx_auto_type
      PUBLIC
        cxx_nullptr
        cxx_override
    )
    target_link_libraries(${_testname}_exec CutelystQt5::Core coverage_test)
  endforeach(_testname)
endmacro(CUTELYST_TEMPLATES_UNIT_TESTS)

cutelyst_templates_unit_tests(
    testheaders
    testcontext
    testrequest
    testresponse
    testdispatcherpath
    testdispatcherchained
    testvalidator
)


project(cutelyst_tests)

find_package(Qt5Test 5.6.0 REQUIRED)

add_library(coverage_test STATIC coverageobject.cpp
  coverageobject.cpp
  ${_testresource_rcc_src}
)
target_compile_features(coverage_test
  PRIVATE
    cxx_auto_type
  PUBLIC
    cxx_nullptr
    cxx_override
)
target_link_libraries(coverage_test Qt5::Test CutelystQt5::Core Qt5::Network)

function(cute_test _testname _link)
    add_executable(${_testname}_exec ${_testname}.cpp)
    add_test(NAME ${_testname} COMMAND ${_testname}_exec)
    target_compile_features(${_testname}_exec
      PRIVATE
        cxx_auto_type
      PUBLIC
        cxx_nullptr
        cxx_override
    )
    target_link_libraries(${_testname}_exec ${_link} CutelystQt5::Core coverage_test)
endfunction()

macro(CUTELYST_TEMPLATES_UNIT_TESTS)
    foreach(_testname ${ARGN})
        cute_test(${_testname} "")
    endforeach(_testname)
endmacro(CUTELYST_TEMPLATES_UNIT_TESTS)

cutelyst_templates_unit_tests(
    testheaders
    testcontext
    testrequest
    testresponse
    testdispatcherpath
    testdispatcherchained
)

cute_test(testvalidator CutelystQt5::Utils::Validator)

Make only Validator test link to it's library
tests: Make only Validator test link to it's library
