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

Function main

example/matcher.cpp:51–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49};
50
51int main() {
52 using namespace boost::ut;
53 using namespace std::literals::string_view_literals;
54
55 "matcher"_test = [] {
56 constexpr auto is_between = [](auto lhs, auto rhs) {
57 return [=](auto value) {
58 return that % value >= lhs and that % value <= rhs;
59 };
60 };
61
62 constexpr auto ends_with = [](const auto& arg, const auto& ext) {
63 std::stringstream str{};
64 str << '(' << arg << " ends with " << ext << ')';
65 if (ext.size() > arg.size()) {
66 return matcher{{}, str.str()};
67 }
68 return matcher{std::equal(ext.rbegin(), ext.rend(), arg.rbegin()),
69 str.str()};
70 };
71
72 auto value = 42;
73 auto str = "example.test"sv;
74
75 expect(is_between(1, 100)(value) and not is_between(1, 100)(0));
76 expect(ends_with(str, ".test"sv));
77 expect(any_of{1, 2, 3} == 2 or any_of{42, 43} == 44);
78 };
79}

Callers

nothing calls this directly

Calls 3

expectFunction · 0.85
sizeMethod · 0.80
strMethod · 0.80

Tested by

no test coverage detected