forked from boost-ext/ut
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsection.cpp
47 lines (37 loc) · 1 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
//
// 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));
should("resize bigger") = [v] { // or "resize bigger"_test
mut(v).resize(10);
expect(10_ul == std::size(v));
};
!expect(5_ul == std::size(v));
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);
};
"[str2]"_test = [str{std::move(str)}] {
mut(str) << '2';
expect(str.str() == "2"sv);
};
}