File tree Expand file tree Collapse file tree 3 files changed +10010
-8652
lines changed
third_party/catch/include Expand file tree Collapse file tree 3 files changed +10010
-8652
lines changed Original file line number Diff line number Diff line change 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.
2625namespace 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"
Original file line number Diff line number Diff line change 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>
You can’t perform that action at this time.
0 commit comments