Skip to content

Commit d551e25

Browse files
committed
migrate to Catch2 v3
1 parent 289e66a commit d551e25

File tree

7 files changed

+22
-23
lines changed

7 files changed

+22
-23
lines changed

.appveyor.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ for:
9898
# https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/
9999
- sudo curl -k https://curl.se/ca/cacert.pem -o /etc/ssl/cert.pem
100100
101-
# backport vcpkg bugfixes
101+
# update to Catch2 v3
102102
git -C ~/vcpkg fetch
103-
git -C ~/vcpkg restore -s 38d6712d5644ede4ff597e889549f5d540dcf8ff ports/catch2
103+
git -C ~/vcpkg restore -s 50fe35a3c3ca43ffe3b436380cf563100406459a ports/catch2
104104
fi
105105
artifacts:
106106
- path: build/reaper_reapack*.dylib

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Install the following libraries (and development headers if your system provides
2626
them separately):
2727

2828
- [Boost](https://www.boost.org/) (1.56 or later)
29-
- [Catch2](https://github.com/catchorg/Catch2)
29+
- [Catch2](https://github.com/catchorg/Catch2) (3.0 or later)
3030
- [libcurl](https://curl.haxx.se/libcurl/)
3131
- [libxml2](http://www.xmlsoft.org/)
3232
- [OpenSSL](https://www.openssl.org/) or compatible

test/CMakeLists.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ add_executable(tests EXCLUDE_FROM_ALL
1313
helper.hpp
1414
index.cpp
1515
index_v1.cpp
16-
main.cpp
1716
metadata.cpp
1817
package.cpp
1918
path.cpp
@@ -36,4 +35,4 @@ target_include_directories(tests PRIVATE
3635
${CMAKE_SOURCE_DIR}/src
3736
${CMAKE_SOURCE_DIR}/vendor ${CMAKE_SOURCE_DIR}/vendor/reaper-sdk/sdk
3837
)
39-
target_link_libraries(tests Catch2::Catch2 reapack)
38+
target_link_libraries(tests Catch2::Catch2WithMain reapack)

test/helper.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ class Time;
77
std::ostream &operator<<(std::ostream &, const std::set<Path> &);
88

99
// include Catch only after having declared our ostream overloads
10-
#include <catch2/catch.hpp>
10+
#include <catch2/catch_test_macros.hpp>
11+
#include <catch2/matchers/catch_matchers_contains.hpp>
12+
#include <catch2/matchers/catch_matchers_string.hpp>

test/main.cpp

-2
This file was deleted.

test/receipt.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <index.hpp>
66

7-
using Catch::Matchers::Contains;
7+
using Catch::Matchers::ContainsSubstring;
88
using Catch::Matchers::EndsWith;
99

1010
static const char *M = "[receipt]";
@@ -166,41 +166,41 @@ TEST_CASE("format install ticket", M) {
166166

167167
SECTION("contains fullname") {
168168
stream << InstallTicket{v3, {}};
169-
REQUIRE_THAT(stream.str(), Contains(pkg.fullName()));
169+
REQUIRE_THAT(stream.str(), ContainsSubstring(pkg.fullName()));
170170
}
171171

172172
SECTION("prepend newline if stream nonempty") {
173173
stream << "something";
174174
stream << InstallTicket{v3, {}};
175-
REQUIRE_THAT(stream.str(), Contains("something\r\n"));
175+
REQUIRE_THAT(stream.str(), ContainsSubstring("something\r\n"));
176176
}
177177

178178
SECTION("installed from scratch") {
179179
stream << InstallTicket{v2, {}};
180-
REQUIRE_THAT(stream.str(), Contains("[new]") &&
181-
!Contains("v1.0\r\n") && Contains("v2.0\r\n") && !Contains("v3.0\r\n"));
180+
REQUIRE_THAT(stream.str(), ContainsSubstring("[new]") &&
181+
!ContainsSubstring("v1.0\r\n") && ContainsSubstring("v2.0\r\n") && !ContainsSubstring("v3.0\r\n"));
182182
}
183183

184184
SECTION("reinstalled") {
185185
entry.version = VersionName("2.0");
186186
stream << InstallTicket{v2, entry};
187-
REQUIRE_THAT(stream.str(), Contains("[reinstalled]") &&
188-
!Contains("v1.0\r\n") && Contains("v2.0\r\n") && !Contains("v3.0\r\n"));
187+
REQUIRE_THAT(stream.str(), ContainsSubstring("[reinstalled]") &&
188+
!ContainsSubstring("v1.0\r\n") && ContainsSubstring("v2.0\r\n") && !ContainsSubstring("v3.0\r\n"));
189189
}
190190

191191
SECTION("update") {
192192
entry.version = VersionName("1.0");
193193
stream << InstallTicket{v3, entry};
194-
REQUIRE_THAT(stream.str(), Contains("[v1.0 -> v3.0]") &&
195-
!Contains("v1.0\r\n") && Contains("\r\nv3.0\r\n No changelog\r\nv2.0"));
194+
REQUIRE_THAT(stream.str(), ContainsSubstring("[v1.0 -> v3.0]") &&
195+
!ContainsSubstring("v1.0\r\n") && ContainsSubstring("\r\nv3.0\r\n No changelog\r\nv2.0"));
196196
REQUIRE_THAT(stream.str(), !EndsWith("\r\n"));
197197
}
198198

199199
SECTION("downgrade") {
200200
entry.version = VersionName("3.0");
201201
stream << InstallTicket{v1, entry};
202-
REQUIRE_THAT(stream.str(), Contains("[v3.0 -> v1.0]") &&
203-
Contains("v1.0\r\n") && !Contains("v2.0\r\n") && !Contains("v3.0\r\n"));
202+
REQUIRE_THAT(stream.str(), ContainsSubstring("[v3.0 -> v1.0]") &&
203+
ContainsSubstring("v1.0\r\n") && !ContainsSubstring("v2.0\r\n") && !ContainsSubstring("v3.0\r\n"));
204204
}
205205
}
206206

test/remote.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,17 @@ TEST_CASE("protect remote", M) {
171171

172172
TEST_CASE("autoinstall remote", M) {
173173
Remote remote;
174-
REQUIRE_FALSE(remote.autoInstall());
174+
REQUIRE_FALSE(bool{remote.autoInstall()});
175175
REQUIRE(remote.autoInstall(true));
176176
REQUIRE_FALSE(remote.autoInstall(false));
177177

178178
remote.setAutoInstall(true);
179-
REQUIRE(remote.autoInstall());
179+
REQUIRE(bool{remote.autoInstall()});
180180
REQUIRE(remote.autoInstall(true));
181181
REQUIRE(remote.autoInstall(false));
182182

183183
remote.setAutoInstall(false);
184-
REQUIRE_FALSE(remote.autoInstall());
184+
REQUIRE_FALSE(bool{remote.autoInstall()});
185185
REQUIRE_FALSE(remote.autoInstall(true));
186186
REQUIRE_FALSE(remote.autoInstall(false));
187187
}
@@ -260,7 +260,7 @@ TEST_CASE("unserialize remote", M) {
260260

261261
SECTION("auto-install enabled") {
262262
Remote remote = Remote::fromString("name|url|1|1");
263-
REQUIRE(remote.autoInstall());
263+
REQUIRE(bool{remote.autoInstall()});
264264
}
265265

266266
SECTION("auto-install enabled") {

0 commit comments

Comments
 (0)