-
Notifications
You must be signed in to change notification settings - Fork 126
/
Copy pathsection.cpp
56 lines (45 loc) · 1.26 KB
/
section.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// Copyright (c) 2019-2020 Kris Jusiak (kris at jusiak dot net)
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/ut.hpp>
#include <sstream>
#include <string_view>
#include <vector>
int main() {
using namespace boost::ut;
"[vector]"_test = [] {
std::vector<int> v(5);
expect((5_ul == std::size(v)) >> fatal);
should("resize bigger") = [v] { // or "resize bigger"_test
mut(v).resize(10);
expect(10_ul == std::size(v));
};
expect((5_ul == std::size(v)) >> fatal);
should("resize smaller") = [=]() mutable { // or "resize smaller"_test
v.resize(0);
expect(0_ul == std::size(v));
};
};
using namespace std::literals;
{
std::stringstream str{};
"[str1]"_test = [str{std::move(str)}] {
mut(str) << '1';
expect(str.str() == "1"sv);
};
}
// FIXME: [clang-analyzer-cplusplus.Move,-warnings-as-errors]
// Note: Object 'str' of type 'std::__1::basic_stringstream' is left in a
// valid but unspecified state after move
{
std::stringstream str{};
"[str2]"_test = [str{std::move(str)}] {
mut(str) << '2';
expect(str.str() == "2"sv);
};
}
}