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

Function main

example/section.cpp:13–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include <vector>
12
13int main() {
14 using namespace boost::ut;
15
16 "[vector]"_test = [] {
17 std::vector<int> v(5);
18
19 expect((5_ul == std::size(v)) >> fatal);
20
21 should("resize bigger") = [v] { // or "resize bigger"_test
22 mut(v).resize(10);
23 expect(10_ul == std::size(v));
24 };
25
26 expect((5_ul == std::size(v)) >> fatal);
27
28 should("resize smaller") = [=]() mutable { // or "resize smaller"_test
29 v.resize(0);
30 expect(0_ul == std::size(v));
31 };
32 };
33
34 using namespace std::literals;
35
36 {
37 std::stringstream str{};
38
39 "[str1]"_test = [str{std::move(str)}] {
40 mut(str) << '1';
41 expect(str.str() == "1"sv);
42 };
43 }
44
45 // FIXME: [clang-analyzer-cplusplus.Move,-warnings-as-errors]
46 // Note: Object 'str' of type 'std::__1::basic_stringstream' is left in a
47 // valid but unspecified state after move
48 {
49 std::stringstream str{};
50
51 "[str2]"_test = [str{std::move(str)}] {
52 mut(str) << '2';
53 expect(str.str() == "2"sv);
54 };
55 }
56}

Callers

nothing calls this directly

Calls 3

expectFunction · 0.85
mutFunction · 0.85
strMethod · 0.80

Tested by

no test coverage detected