1*bb611c8fSApple OSS Distributions // 2*bb611c8fSApple OSS Distributions // Tests for 3*bb611c8fSApple OSS Distributions // T& operator[](ptrdiff_t n) const; 4*bb611c8fSApple OSS Distributions // 5*bb611c8fSApple OSS Distributions 6*bb611c8fSApple OSS Distributions #include <libkern/c++/bounded_array_ref.h> 7*bb611c8fSApple OSS Distributions #include "test_policy.h" 8*bb611c8fSApple OSS Distributions #include <darwintest.h> 9*bb611c8fSApple OSS Distributions #include <darwintest_utils.h> 10*bb611c8fSApple OSS Distributions 11*bb611c8fSApple OSS Distributions struct T { int i; }; 12*bb611c8fSApple OSS Distributions inline bool 13*bb611c8fSApple OSS Distributions operator==(T const& a, T const& b) 14*bb611c8fSApple OSS Distributions { 15*bb611c8fSApple OSS Distributions return a.i == b.i; 16*bb611c8fSApple OSS Distributions }; 17*bb611c8fSApple OSS Distributions 18*bb611c8fSApple OSS Distributions template <typename T> 19*bb611c8fSApple OSS Distributions static void 20*bb611c8fSApple OSS Distributions tests() 21*bb611c8fSApple OSS Distributions { 22*bb611c8fSApple OSS Distributions { 23*bb611c8fSApple OSS Distributions T array[5] = {T{0}, T{1}, T{2}, T{3}, T{4}}; 24*bb611c8fSApple OSS Distributions test_bounded_array_ref<T> view(array); 25*bb611c8fSApple OSS Distributions CHECK(view[0] == T{0}); 26*bb611c8fSApple OSS Distributions CHECK(view[1] == T{1}); 27*bb611c8fSApple OSS Distributions CHECK(view[2] == T{2}); 28*bb611c8fSApple OSS Distributions CHECK(view[3] == T{3}); 29*bb611c8fSApple OSS Distributions CHECK(view[4] == T{4}); 30*bb611c8fSApple OSS Distributions } 31*bb611c8fSApple OSS Distributions } 32*bb611c8fSApple OSS Distributions 33*bb611c8fSApple OSS Distributions T_DECL(operator_subscript, "bounded_array_ref.operator.subscript") { 34*bb611c8fSApple OSS Distributions tests<T>(); 35*bb611c8fSApple OSS Distributions } 36