1*c54f35caSApple OSS Distributions // 2*c54f35caSApple OSS Distributions // Make sure `bounded_array` works nicely with the range-based for-loop. 3*c54f35caSApple OSS Distributions // 4*c54f35caSApple OSS Distributions 5*c54f35caSApple OSS Distributions #include <libkern/c++/bounded_array.h> 6*c54f35caSApple OSS Distributions #include <darwintest.h> 7*c54f35caSApple OSS Distributions #include "test_policy.h" 8*c54f35caSApple OSS Distributions 9*c54f35caSApple OSS Distributions struct T { 10*c54f35caSApple OSS Distributions int i; 11*c54f35caSApple OSS Distributions }; 12*c54f35caSApple OSS Distributions 13*c54f35caSApple OSS Distributions template <typename T> 14*c54f35caSApple OSS Distributions static void tests()15*c54f35caSApple OSS Distributionstests() 16*c54f35caSApple OSS Distributions { 17*c54f35caSApple OSS Distributions test_bounded_array<T, 5> array = {T{0}, T{1}, T{2}, T{3}, T{4}}; 18*c54f35caSApple OSS Distributions for (T& element : array) { 19*c54f35caSApple OSS Distributions element = T{3}; 20*c54f35caSApple OSS Distributions } 21*c54f35caSApple OSS Distributions 22*c54f35caSApple OSS Distributions for (T const& element : array) { 23*c54f35caSApple OSS Distributions CHECK(element.i == 3); 24*c54f35caSApple OSS Distributions } 25*c54f35caSApple OSS Distributions } 26*c54f35caSApple OSS Distributions 27*c54f35caSApple OSS Distributions T_DECL(for_loop, "bounded_array.for_loop") { 28*c54f35caSApple OSS Distributions tests<T>(); 29*c54f35caSApple OSS Distributions } 30