FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp11/cpp11test/src/test-list_of.cpp at master · vermosen/cpp11 · GitHub
vermosen
/
cpp11
Public
forked from
r-lib/cpp11
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp11
/
cpp11test
/
src
/
test-list_of.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (35 loc) · 1.36 KB
Breadcrumbs
cpp11
/
cpp11test
/
src
/
test-list_of.cpp
Copy path
File metadata and controls
49 lines (35 loc) · 1.36 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
<
testthat.h
>
#
include
"
cpp11/doubles.hpp
"
#
include
"
cpp11/list.hpp
"
#
include
"
cpp11/list_of.hpp
"
#
include
"
cpp11/strings.hpp
"
context
(
"
list_of-C++
"
) {
test_that
(
"
list_of works
"
) {
using
namespace
cpp11
::literals
;
cpp11::writable::list
x
({
"
x
"
_nm =
cpp11::writable::doubles
({
1
.,
2
.,
3
.}),
"
y
"
_nm =
cpp11::writable::doubles
({
4
.,
5
.,
6
.})});
cpp11::list_of<cpp11::doubles>
res
(x);
expect_true
(res.
size
() ==
2
);
expect_true
(res[
0
][
0
] ==
1
.);
expect_true
(res[
1
][
0
] ==
4
.);
expect_true
(res.
names
()[
0
] ==
"
x
"
);
expect_true
(res.
names
()[
1
] ==
"
y
"
);
}
test_that
(
"
writable::list_of works
"
) {
using
namespace
cpp11
::literals
;
cpp11::writable::list
x
({
"
x
"
_nm =
cpp11::writable::doubles
({
1
.,
2
.,
3
.}),
"
y
"
_nm =
cpp11::writable::doubles
({
4
.,
5
.,
6
.})});
cpp11::writable::list_of<cpp11::writable::doubles>
res
(x);
res.
push_back
({
"
z
"
_nm =
cpp11::writable::doubles
({
7
.,
8
.,
9
.})});
expect_true
(res.
size
() ==
3
);
expect_true
(
REAL
(
VECTOR_ELT
(res,
2
))[
0
] ==
7
.);
res[
0
][
0
] =
2
.;
expect_true
(
REAL
(
VECTOR_ELT
(res,
0
))[
0
] ==
2
.);
res[
1
] =
cpp11::writable::doubles
({
7
.,
8
.,
9
.});
expect_true
(
REAL
(res[
1
])[
0
] ==
7
.);
expect_true
(
REAL
(res[
1
])[
1
] ==
8
.);
expect_true
(
REAL
(res[
1
])[
2
] ==
9
.);
res[
"
x
"
][
0
] =
4
;
expect_true
(
REAL
(res[
0
])[
0
] ==
4
.);
}
}
Back
|
FazBrowse Home
|
New Git URL