26 namespace array_view_tests {
29 #define CHECK_TRAIT(TRAIT) \ 30 static_assert (std::TRAIT<gdb::array_view<gdb_byte>>::value, "") 32 #if HAVE_IS_TRIVIALLY_COPYABLE 46 template<
typename From,
typename To>
50 return std::is_convertible<From, To>::value;
86 struct B :
A {
int j; };
87 struct C :
A {
int l; };
125 static constexpr
bool 142 static constexpr
bool 154 &&
is_convertible <std::array<const T, 1>, array_view<const T>> ());
162 template<
typename View,
typename Container>
168 if (view.size () != c.size ())
170 if (view.data () != c.data ())
172 for (
size_t i = 0; i < c.size (); i++)
174 if (&view[i] != &c[i])
185 template<
typename View,
typename Elem>
191 if (view.size () != 1)
193 if (view.data () != &e)
205 template<
typename View,
206 typename = decltype (std::declval<View> ()[0]
207 = std::declval<typename View::value_type> ())>
230 T data[] = {0x11, 0x22, 0x33, 0x44};
250 template<
typename T,
typename... Args>
251 static constexpr
bool 254 static_assert (!std::is_constructible<T, Args...>::value,
"");
268 A *array[] = { &an_a };
269 const A *
const carray[] = { &an_a };
276 require_not_constructible<gdb::array_view<A *>, decltype (carray),
size_t> ();
300 T data[] = {0x11, 0x22, 0x33, 0x44};
310 gdb_byte array[] = {0x11, 0x22, 0x33, 0x44};
312 gdb_byte *p2 = array + ARRAY_SIZE (array);
321 gdb_byte array[] = {0x11, 0x22, 0x33, 0x44};
337 T data[] = {1, 2, 3, 4};
341 for (
auto &elem : view)
356 static_assert (view1.empty (),
"");
357 static_assert (view1.data () ==
nullptr,
"");
358 static_assert (view1.size () == 0,
"");
359 static_assert (view2.empty (),
"");
360 static_assert (view2.size () == 0,
"");
361 static_assert (view2.data () ==
nullptr,
"");
364 std::vector<gdb_byte> vec = {0x11, 0x22, 0x33, 0x44 };
365 std::array<gdb_byte, 4> array = {{0x11, 0x22, 0x33, 0x44}};
389 view = std::move (vec);
394 view = std::move (array);
400 view = std::move (elem);
406 gdb_byte data[] = {0x11, 0x22, 0x33, 0x44};
423 gdb_byte data[] = {0x55, 0x66, 0x77, 0x88};
433 view3 = std::move (view1);
436 cview3 = std::move (cview1);
447 std::vector<gdb_byte> vec = {0x11, 0x22};
463 check_ptr_size_ctor<const gdb_byte> ();
464 check_ptr_size_ctor<gdb_byte> ();
466 check_ptr_ptr_ctor<const gdb_byte> ();
467 check_ptr_ptr_ctor<gdb_byte> ();
470 check_range_for<gdb_byte> ();
471 check_range_for<const gdb_byte> ();
476 using Vec = std::vector<gdb_byte>;
void check_ptr_size_ctor2()
constexpr size_type size() const noexcept
#define CHECK_TRAIT(TRAIT)
static bool check_elem_view(const View &view, const Elem &e)
static bool check_op_subscript(const View &view)
static void check_ptr_ptr_mixed_cv()
static constexpr bool check_convertible_from_std_array()
static bool check_container_view(const View &view, const Container &c)
static void check_range_for()
static void check_ptr_size_ctor()
constexpr bool empty() const noexcept
static constexpr bool check_convertible_from_std_vector()
static constexpr bool is_convertible()
void _initialize_array_view_selftests()
static constexpr bool require_not_constructible()
void register_test(const std::string &name, selftest *test)
static constexpr bool check()
static void check_ptr_ptr_ctor()
static constexpr bool check_convertible()
#define SELF_CHECK(VALUE)