Skip to content

Commit 1dad4fc

Browse files
committed
test: update Catch2 to use version 2.11.0
1 parent 7af16d3 commit 1dad4fc

File tree

5 files changed

+15
-28
lines changed

5 files changed

+15
-28
lines changed

tests/CMakeLists.txt

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ if(BUILD_TESTING)
33

44
FetchContent_Declare(
55
libcatch2
6-
URL https://github.com/catchorg/Catch2/archive/v2.13.6.tar.gz
7-
# GIT_REPOSITORY https://github.com/catchorg/Catch2.git
8-
# GIT_TAG 15cf3ca
6+
URL https://github.com/catchorg/Catch2/archive/v3.11.0.tar.gz
7+
URL_HASH SHA1=5f5a932acf6990764c33ed80ee04f1c696f4d5bc
8+
DOWNLOAD_EXTRACT_TIMESTAMP true
99
)
1010

1111
FetchContent_MakeAvailable(libcatch2)
@@ -22,7 +22,7 @@ if(BUILD_TESTING)
2222
URL ${PROJECT_BINARY_DIR}/metadata_test_images.tar.gz
2323
)
2424
FetchContent_MakeAvailable(test_images)
25-
add_executable(tester test-main.cpp test-basic.cpp test_exceptions.cpp)
25+
add_executable(tester test-basic.cpp test_exceptions.cpp)
2626
target_include_directories(tester PRIVATE ${PROJECT_SOURCE_DIR}/uiucprescon/imagevalidate)
2727

2828
target_compile_definitions(tester PRIVATE TEST_IMAGE_PATH="${test_images_SOURCE_DIR}")
@@ -31,35 +31,22 @@ if(BUILD_TESTING)
3131
CXX_CPPCHECK ${CMAKE_CXX_CPPCHECK};--suppress=*:${libcatch2_SOURCE_DIR}/single_include/catch2/catch.hpp
3232
)
3333
endif()
34-
set_target_properties(tester PROPERTIES
35-
CXX_STANDARD 11
36-
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
37-
)
3834

39-
target_link_libraries(tester PRIVATE Catch2 imagevalidate::glue)
35+
target_link_libraries(tester PRIVATE Catch2::Catch2WithMain imagevalidate::glue)
4036
catch_discover_tests(tester
4137
TEST_PREFIX imagevalidate.
4238
)
4339

4440
#############
4541

46-
add_executable(tester-internal test-main.cpp tester-internal.cpp)
47-
if(CMAKE_CXX_CPPCHECK)
48-
set_property(TARGET tester-internal PROPERTY
49-
CXX_CPPCHECK ${CMAKE_CXX_CPPCHECK};--suppress=*:${libcatch2_SOURCE_DIR}/single_include/catch2/catch.hpp
50-
)
51-
endif()
42+
add_executable(tester-internal tester-internal.cpp)
5243
target_compile_definitions(tester-internal
5344
PRIVATE TEST_IMAGE_PATH="${test_images_SOURCE_DIR}")
5445

55-
set_target_properties(tester-internal PROPERTIES
56-
CXX_STANDARD 11
57-
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
58-
)
5946

6047
target_link_libraries(tester-internal
6148
PRIVATE
62-
Catch2
49+
Catch2::Catch2WithMain
6350
glue
6451
)
6552
catch_discover_tests(tester-internal

tests/test-basic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "glue.h"
22
#include "exceptions.h"
3-
#include <catch2/catch.hpp>
3+
#include <catch2/catch_test_macros.hpp>
44

55

66
TEST_CASE("utils"){

tests/test-main.cpp

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/test_exceptions.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
// Created by Borchers, Henry Samuel on 5/25/21.
33
//
44

5-
#include "catch2/catch.hpp"
65
#include "exceptions.h"
76

7+
#include <catch2/catch_test_macros.hpp>
8+
#include <catch2/matchers/catch_matchers_string.hpp>
9+
#include <catch2/matchers/catch_matchers_exception.hpp>
10+
811
TEST_CASE("InvalidFileException filename only"){
9-
REQUIRE_THROWS_WITH(throw InvalidFileException("myfile.txt"), Catch::Equals( "myfile.txt" ));
12+
REQUIRE_THROWS_WITH(throw InvalidFileException("myfile.txt"), Catch::Matchers::Equals( "myfile.txt" ));
1013
}
1114
TEST_CASE("InvalidFileException filename with message"){
12-
REQUIRE_THROWS_WITH(throw InvalidFileException("myfile.txt", "did something stupid"), Catch::Equals( "myfile.txt: did something stupid" ));
15+
REQUIRE_THROWS_WITH(throw InvalidFileException("myfile.txt", "did something stupid"), Catch::Matchers::Equals( "myfile.txt: did something stupid" ));
1316
}

tests/tester-internal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Created by Borchers, Henry Samuel on 9/13/18.
33
//
44

5-
#include "catch2/catch.hpp"
5+
#include "catch2/catch_test_macros.hpp"
66
#include "opj_colorspace_checker.h"
77

88

0 commit comments

Comments
 (0)