preCICE
v3.2.0
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Variables
_
a
b
c
d
e
f
h
i
m
n
p
r
s
t
Typedefs
b
d
e
g
l
m
p
r
s
t
u
v
Enumerations
Enumerator
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
~
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
~
Variables
_
a
b
c
d
e
f
g
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Typedefs
a
b
c
d
e
f
i
k
m
n
o
p
r
s
t
v
w
Enumerations
Enumerator
c
d
e
i
l
m
n
o
r
s
u
v
w
Related Symbols
Files
File List
File Members
All
_
a
b
c
d
e
g
i
j
m
n
o
p
r
s
t
v
Functions
a
b
c
g
m
p
r
s
t
v
Variables
Typedefs
Macros
b
d
m
n
p
t
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Loading...
Searching...
No Matches
src
precice
tests
SpanTests.cpp
Go to the documentation of this file.
1
#include <
array
>
2
#include <
string
>
3
#include <
string_view
>
4
#include <
vector
>
5
6
#include "
precice/span.hpp
"
7
#include "
testing/Testing.hpp
"
8
9
BOOST_AUTO_TEST_SUITE
(PreciceTests)
10
BOOST_AUTO_TEST_SUITE
(Span)
11
12
using
precice::span
;
13
14
PRECICE_TEST_SETUP
(1_rank)
15
BOOST_AUTO_TEST_CASE
(FromDoubleVector)
16
{
17
PRECICE_TEST
();
18
std::vector<double>
v{1.0, 2.0, 3.0, 4.0};
19
span<const double>
const_span{v};
20
BOOST_TEST(v == const_span, boost::test_tools::per_element());
21
span<double>
mut_span{v};
22
BOOST_TEST(v == mut_span, boost::test_tools::per_element());
23
}
15
BOOST_AUTO_TEST_CASE
(FromDoubleVector) {
…
}
24
25
PRECICE_TEST_SETUP
(1_rank)
26
BOOST_AUTO_TEST_CASE
(FromIntVector)
27
{
28
PRECICE_TEST
();
29
std::vector<int>
v{1, 2, 3, 4};
30
span<const int>
const_span{v};
31
BOOST_TEST(v == const_span, boost::test_tools::per_element());
32
span<int>
mut_span{v};
33
BOOST_TEST(v == mut_span, boost::test_tools::per_element());
34
}
26
BOOST_AUTO_TEST_CASE
(FromIntVector) {
…
}
35
36
PRECICE_TEST_SETUP
(1_rank)
37
BOOST_AUTO_TEST_CASE
(FromString)
38
{
39
PRECICE_TEST
();
40
std::string
s =
"hello there"
;
41
span<const char>
const_span{s};
42
BOOST_TEST(s ==
std::string
(const_span.data(), const_span.size()));
43
}
37
BOOST_AUTO_TEST_CASE
(FromString) {
…
}
44
45
PRECICE_TEST_SETUP
(1_rank)
46
BOOST_AUTO_TEST_CASE
(FromCharVec)
47
{
48
PRECICE_TEST
();
49
std::vector<char>
s{
'h'
,
'e'
,
'l'
,
'l'
,
'o'
,
' '
,
't'
,
'h'
,
'e'
,
'r'
,
'e'
};
50
span<const char>
const_span{s};
51
BOOST_CHECK_EQUAL_COLLECTIONS(
52
s.begin(), s.end(),
53
const_span.begin(), const_span.end());
54
}
46
BOOST_AUTO_TEST_CASE
(FromCharVec) {
…
}
55
56
PRECICE_TEST_SETUP
(1_rank)
57
BOOST_AUTO_TEST_CASE
(FromLiteral)
58
{
59
PRECICE_TEST
();
60
std::string
s =
"hello there"
;
61
span<const char>
const_span{
"hello there"
};
// Includes the NULL byte
62
63
BOOST_CHECK_EQUAL_COLLECTIONS(s.
begin
(), ++s.
end
(),
64
const_span.begin(), const_span.end());
65
}
57
BOOST_AUTO_TEST_CASE
(FromLiteral) {
…
}
66
67
PRECICE_TEST_SETUP
(1_rank)
68
BOOST_AUTO_TEST_CASE
(FromStdArray)
69
{
70
PRECICE_TEST
();
71
std::array<char, 11>
s{
'h'
,
'e'
,
'l'
,
'l'
,
'o'
,
' '
,
't'
,
'h'
,
'e'
,
'r'
,
'e'
};
72
span<const char>
const_span{s};
73
74
BOOST_CHECK_EQUAL_COLLECTIONS(
75
s.begin(), s.end(),
76
const_span.begin(), const_span.end());
77
}
68
BOOST_AUTO_TEST_CASE
(FromStdArray) {
…
}
78
79
PRECICE_TEST_SETUP
(1_rank)
80
BOOST_AUTO_TEST_CASE
(FromCArray)
81
{
82
PRECICE_TEST
();
83
char
s[] =
"hello there"
;
84
span<const char>
const_span{s};
// Includes the NULL byte
85
86
BOOST_CHECK_EQUAL_COLLECTIONS(
87
s, s + 12,
88
const_span.begin(), const_span.end());
89
}
80
BOOST_AUTO_TEST_CASE
(FromCArray) {
…
}
90
91
PRECICE_TEST_SETUP
(1_rank)
92
BOOST_AUTO_TEST_CASE
(FromStringRef)
93
{
94
PRECICE_TEST
();
95
std::string
s =
"hello there"
;
96
std::string
&sr = s;
97
span<const char>
const_span{sr};
98
BOOST_TEST(s ==
std::string
(const_span.data(), const_span.size()));
99
}
92
BOOST_AUTO_TEST_CASE
(FromStringRef) {
…
}
100
101
PRECICE_TEST_SETUP
(1_rank)
102
BOOST_AUTO_TEST_CASE
(FromConstStringRef)
103
{
104
PRECICE_TEST
();
105
std::string
s =
"hello there"
;
106
const
std::string
&scr = s;
107
span<const char>
const_span{scr};
108
BOOST_TEST(s ==
std::string
(const_span.data(), const_span.size()));
109
}
102
BOOST_AUTO_TEST_CASE
(FromConstStringRef) {
…
}
110
111
PRECICE_TEST_SETUP
(1_rank)
112
BOOST_AUTO_TEST_CASE
(FromCString)
113
{
114
PRECICE_TEST
();
115
std::string
s =
"hello there"
;
116
char
*sp = s.
data
();
117
span<const char>
const_span{sp};
118
BOOST_TEST(s ==
std::string
(const_span.data(), const_span.size()));
119
}
112
BOOST_AUTO_TEST_CASE
(FromCString) {
…
}
120
121
PRECICE_TEST_SETUP
(1_rank)
122
BOOST_AUTO_TEST_CASE
(FromConstCString)
123
{
124
PRECICE_TEST
();
125
const
char
*s =
"hello there"
;
126
span<const char>
const_span{s};
127
BOOST_TEST(s ==
std::string
(const_span.data(), const_span.size()));
128
}
122
BOOST_AUTO_TEST_CASE
(FromConstCString) {
…
}
129
130
PRECICE_TEST_SETUP
(1_rank)
131
BOOST_AUTO_TEST_CASE
(ToStringView)
132
{
133
PRECICE_TEST
();
134
const
char
*s =
"hello there"
;
135
span<const char>
const_span{s};
136
std::string_view
sv{const_span.
data
(), const_span.size()};
137
138
BOOST_TEST(s ==
std::string
(const_span.data(), const_span.size()));
139
BOOST_TEST(s == sv);
140
}
131
BOOST_AUTO_TEST_CASE
(ToStringView) {
…
}
141
142
BOOST_AUTO_TEST_SUITE_END
()
143
BOOST_AUTO_TEST_SUITE_END
()
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(PreProcess)
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(FromDoubleVector)
Definition
SpanTests.cpp:15
Testing.hpp
PRECICE_TEST
#define PRECICE_TEST()
Definition
Testing.hpp:39
PRECICE_TEST_SETUP
#define PRECICE_TEST_SETUP(...)
Creates and attaches a TestSetup to a Boost test case.
Definition
Testing.hpp:29
array
std::string
std::string_view
std::string::begin
T begin(T... args)
precice::span
A C++ 11 implementation of the non-owning C++20 std::span type.
Definition
span.hpp:284
std::string::data
T data(T... args)
std::string::end
T end(T... args)
span.hpp
string
string_view
vector