Skip to content

Commit 222e67d

Browse files
committed
CXX-1537 Upgrade Catch2 to 2.2.1
1 parent 41b9dcb commit 222e67d

File tree

3 files changed

+10010
-8652
lines changed

3 files changed

+10010
-8652
lines changed

src/bsoncxx/test_util/catch.hh

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,33 @@
1616

1717
#include <bsoncxx/document/value.hpp>
1818
#include <bsoncxx/json.hpp>
19+
#include <bsoncxx/stdx/optional.hpp>
20+
21+
#include "catch.hpp"
1922

2023
#include <bsoncxx/config/private/prelude.hh>
2124

22-
// In order to have catch pretty-print documents used in REQUIRE macros, we need to overload
23-
// Catch::toString for document::view. Due to how overload resolution works, this needs to be done
24-
// before the inclusion of catch.hpp. To that end, this file should be included in place of
25-
// catch.hpp.
2625
namespace Catch {
27-
inline std::string toString(bsoncxx::document::view document) {
28-
return bsoncxx::to_json(document);
29-
}
26+
using namespace bsoncxx;
27+
28+
// Catch2 must be able to stringify documents, optionals, etc. if they're used in Catch2 macros.
29+
template <>
30+
struct StringMaker<bsoncxx::document::view> {
31+
static std::string convert(const bsoncxx::document::view& value) {
32+
return bsoncxx::to_json(value, ExtendedJsonMode::k_relaxed);
33+
}
34+
};
35+
36+
template <typename T>
37+
struct StringMaker<stdx::optional<T>> {
38+
static std::string convert(const bsoncxx::stdx::optional<T>& value) {
39+
if (value) {
40+
return StringMaker::convert(value);
41+
}
42+
43+
return "{nullopt}";
44+
}
45+
};
3046
} // namespace Catch
3147

3248
#include <bsoncxx/config/private/postlude.hh>
33-
34-
#include "catch.hpp"

src/mongocxx/test/gridfs/bucket.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <fstream>
1919
#include <functional>
2020
#include <ios>
21-
#include <istream>
21+
#include <sstream>
2222
#include <vector>
2323

2424
#include <bsoncxx/builder/basic/document.hpp>

0 commit comments

Comments
 (0)