MCPcopy Create free account
hub / github.com/boost-ext/ut / main

Function main

example/log.cpp:15–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#endif
14
15int main() {
16 using namespace boost::ut;
17
18 "log"_test = [] {
19 boost::ut::log << "pre:" << 42;
20 expect(42_i == 42) << "message on failure";
21 boost::ut::log << "post";
22 };
23
24#if defined(__cpp_lib_expected)
25 "lazy log"_test = [] {
26 // It's not possible to write a test like:
27 // expect(e.has_value()) << e.error() << fatal;
28 // This would evaluate e.error() when there is no error, instead lazy
29 // evaluation is needed.
30 std::expected<bool, std::string> e = true;
31 expect(e.has_value()) << [&] { return e.error(); } << fatal;
32 expect(e.value() == true);
33 };
34#endif
35
36#if defined(BOOST_UT_HAS_FORMAT)
37 "log format"_test = [] {
38 boost::ut::log("\npre: {}\n", 42);
39 expect(42_i == 42) << "message on failure";
40 boost::ut::log("\npost\n");
41 };
42#endif
43}

Callers

nothing calls this directly

Calls 3

expectFunction · 0.85
logClass · 0.85
valueMethod · 0.45

Tested by

no test coverage detected