]> git.saurik.com Git - apple/xnu.git/blame - tests/bounded_array_src/for_loop.cpp
xnu-7195.50.7.100.1.tar.gz
[apple/xnu.git] / tests / bounded_array_src / for_loop.cpp
CommitLineData
f427ee49
A
1//
2// Make sure `bounded_array` works nicely with the range-based for-loop.
3//
4
5#include <libkern/c++/bounded_array.h>
6#include <darwintest.h>
7#include "test_policy.h"
8
9struct T {
10 int i;
11};
12
13template <typename T>
14static void
15tests()
16{
17 test_bounded_array<T, 5> array = {T{0}, T{1}, T{2}, T{3}, T{4}};
18 for (T& element : array) {
19 element = T{3};
20 }
21
22 for (T const& element : array) {
23 CHECK(element.i == 3);
24 }
25}
26
27T_DECL(for_loop, "bounded_array.for_loop") {
28 tests<T>();
29}