Skip to content

Commit f16d8b5

Browse files
committed
Add negative tests for for_each_value.
1 parent b980b98 commit f16d8b5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/errors.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace nda {
2222
shape_of_rank<2> s;
2323
dense_array_ref<int, 2> ref;
2424
dense_array<int, 3> a;
25+
const dense_array<int, 3> const_a;
2526

2627
void range_range_bad_copy_construct() {
2728
fixed_range<3> x;
@@ -104,6 +105,13 @@ void array_ref_at_too_few_indices() {
104105
ref(0);
105106
}
106107

108+
void array_ref_for_each_value_bad_type() {
109+
ref.for_each_value([&](float& i) { i = 0; });
110+
}
111+
112+
void array_ref_for_each_value_too_many_args() {
113+
ref.for_each_value([&](int i, int j) { });
114+
}
107115

108116
void array_at_too_many_indices() {
109117
a(0, 1, 2, 3);
@@ -113,6 +121,10 @@ void array_at_too_few_indices() {
113121
a(0, 1);
114122
}
115123

124+
void array_for_each_value_non_const() {
125+
const_a.for_each_value([&](int& i) { i = 0; });
126+
}
127+
116128

117129
void copy_different_rank() {
118130
copy(a, ref);

0 commit comments

Comments
 (0)