X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/eb6b6ca394357805f2bdba989abae309f718b4d8..f427ee49d309d8fc33ebf3042c3a775f2f530ded:/tests/bounded_array_ref_src/operator.subscript.cpp?ds=sidebyside diff --git a/tests/bounded_array_ref_src/operator.subscript.cpp b/tests/bounded_array_ref_src/operator.subscript.cpp new file mode 100644 index 000000000..ae7ed088f --- /dev/null +++ b/tests/bounded_array_ref_src/operator.subscript.cpp @@ -0,0 +1,35 @@ +// +// Tests for +// T& operator[](ptrdiff_t n) const; +// + +#include +#include "test_policy.h" +#include +#include + +struct T { int i; }; +inline bool +operator==(T const& a, T const& b) +{ + return a.i == b.i; +}; + +template +static void +tests() +{ + { + T array[5] = {T{0}, T{1}, T{2}, T{3}, T{4}}; + test_bounded_array_ref view(array); + CHECK(view[0] == T{0}); + CHECK(view[1] == T{1}); + CHECK(view[2] == T{2}); + CHECK(view[3] == T{3}); + CHECK(view[4] == T{4}); + } +} + +T_DECL(operator_subscript, "bounded_array_ref.operator.subscript") { + tests(); +}