diff options
-rw-r--r-- | tests/CMakeLists.txt | 11 | ||||
-rw-r--r-- | tests/main.cpp | 9 | ||||
-rw-r--r-- | tests/test_connection.cpp | 9 | ||||
-rw-r--r-- | tests/test_html_unescape.cpp | 9 | ||||
-rw-r--r-- | tests/test_instance.cpp | 9 |
5 files changed, 36 insertions, 11 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3f7107b..dacc10d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,11 +3,16 @@ include(CTest) file(GLOB sources_tests test_*.cpp) find_package(Catch2 CONFIG) -if(Catch2_FOUND) # Catch 2.x +if(Catch2_FOUND) # Catch 2.x / 3.x include(Catch) add_executable(all_tests main.cpp ${sources_tests}) - target_link_libraries(all_tests - PRIVATE Catch2::Catch2 ${PROJECT_NAME}) + if(TARGET Catch2::Catch2WithMain) # Catch 3.x + target_link_libraries(all_tests + PRIVATE Catch2::Catch2WithMain ${PROJECT_NAME}) + else() # Catch 2.x + target_link_libraries(all_tests + PRIVATE Catch2::Catch2 ${PROJECT_NAME}) + endif() target_include_directories(all_tests PRIVATE "/usr/include/catch2") catch_discover_tests(all_tests EXTRA_ARGS "${EXTRA_TEST_ARGS}") else() # Catch 1.x diff --git a/tests/main.cpp b/tests/main.cpp index 162dfdf..c6d12ed 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -1,5 +1,5 @@ /* This file is part of mastodonpp. - * Copyright © 2020 tastytea <tastytea@tastytea.de> + * Copyright © 2020, 2022 tastytea <tastytea@tastytea.de> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -16,4 +16,9 @@ #define CATCH_CONFIG_MAIN -#include <catch.hpp> +// catch 3 does not have catch.hpp anymore +#if __has_include(<catch.hpp>) +# include <catch.hpp> +#else +# include <catch_all.hpp> +#endif diff --git a/tests/test_connection.cpp b/tests/test_connection.cpp index 05d7668..208e8de 100644 --- a/tests/test_connection.cpp +++ b/tests/test_connection.cpp @@ -1,5 +1,5 @@ /* This file is part of mastodonpp. - * Copyright © 2020 tastytea <tastytea@tastytea.de> + * Copyright © 2020, 2022 tastytea <tastytea@tastytea.de> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,7 +17,12 @@ #include "connection.hpp" #include "instance.hpp" -#include <catch.hpp> +// catch 3 does not have catch.hpp anymore +#if __has_include(<catch.hpp>) +# include <catch.hpp> +#else +# include <catch_all.hpp> +#endif #include <exception> diff --git a/tests/test_html_unescape.cpp b/tests/test_html_unescape.cpp index d141921..1c75dd8 100644 --- a/tests/test_html_unescape.cpp +++ b/tests/test_html_unescape.cpp @@ -1,5 +1,5 @@ /* This file is part of mastodonpp. - * Copyright © 2020 tastytea <tastytea@tastytea.de> + * Copyright © 2020, 2022 tastytea <tastytea@tastytea.de> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -16,7 +16,12 @@ #include "helpers.hpp" -#include <catch.hpp> +// catch 3 does not have catch.hpp anymore +#if __has_include(<catch.hpp>) +# include <catch.hpp> +#else +# include <catch_all.hpp> +#endif #include <exception> #include <string> diff --git a/tests/test_instance.cpp b/tests/test_instance.cpp index 768cc2a..ebc2c0c 100644 --- a/tests/test_instance.cpp +++ b/tests/test_instance.cpp @@ -1,5 +1,5 @@ /* This file is part of mastodonpp. - * Copyright © 2020 tastytea <tastytea@tastytea.de> + * Copyright © 2020, 2022 tastytea <tastytea@tastytea.de> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -16,7 +16,12 @@ #include "instance.hpp" -#include <catch.hpp> +// catch 3 does not have catch.hpp anymore +#if __has_include(<catch.hpp>) +# include <catch.hpp> +#else +# include <catch_all.hpp> +#endif #include <exception> #include <string> |