| 10 | #include <vector> |
| 11 | |
| 12 | int main() { |
| 13 | using boost::ut::operator""_test; |
| 14 | using namespace boost::ut::literals; |
| 15 | using boost::ut::fatal; |
| 16 | |
| 17 | "fatal"_test = [] { |
| 18 | using namespace boost::ut::operators; |
| 19 | using boost::ut::expect; |
| 20 | |
| 21 | std::optional<int> o{42}; |
| 22 | expect(fatal(o.has_value())) << "fatal assertion"; |
| 23 | expect(*o == 42_i); |
| 24 | }; |
| 25 | |
| 26 | "fatal logging"_test = [] { |
| 27 | using namespace boost::ut::operators; |
| 28 | using boost::ut::expect; |
| 29 | |
| 30 | std::optional<int> o{42}; |
| 31 | expect(fatal(o.has_value())) << "fatal assertion"; |
| 32 | expect(*o == 42_i); |
| 33 | }; |
| 34 | |
| 35 | "fatal matcher"_test = [] { |
| 36 | using namespace boost::ut::operators; |
| 37 | using boost::ut::expect; |
| 38 | using boost::ut::that; |
| 39 | |
| 40 | std::optional<int> o{42}; |
| 41 | expect(fatal(that % o.has_value()) and that % *o == 42) |
| 42 | << "fatal assertion"; |
| 43 | }; |
| 44 | |
| 45 | "fatal terse"_test = [] { |
| 46 | using namespace boost::ut::operators::terse; |
| 47 | |
| 48 | std::optional<int> o{42}; |
| 49 | (o.has_value() >> fatal and *o == 42_i) << "fatal assertion"; |
| 50 | }; |
| 51 | |
| 52 | using namespace boost::ut::operators; |
| 53 | using boost::ut::expect; |
| 54 | |
| 55 | std::vector v{1u}; |
| 56 | expect(fatal(std::size(v) == 1_ul)) << "fatal assertion"; |
| 57 | expect(v[0] == 1_u); |
| 58 | } |