From 3ff9b17a9f82225c99d9312ccc0227b8f8b594e6 Mon Sep 17 00:00:00 2001 From: Neil MacIntosh Date: Mon, 14 Sep 2015 17:57:29 -0700 Subject: [PATCH] Restoring empty_array_view tests. --- tests/array_view_tests.cpp | 60 ++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/tests/array_view_tests.cpp b/tests/array_view_tests.cpp index 4537ce8..63909fa 100644 --- a/tests/array_view_tests.cpp +++ b/tests/array_view_tests.cpp @@ -758,20 +758,62 @@ SUITE(array_view_tests) } #endif - array_view empty_av(nullptr); + { + array_view empty_av(nullptr); - CHECK(empty_av.bounds().index_bounds() == index<1>{ 0 }); - CHECK_THROW(empty_av[0], fail_fast); + CHECK(empty_av.bounds().index_bounds() == index<1>{ 0 }); + CHECK_THROW(empty_av[0], fail_fast); + CHECK_THROW(empty_av.begin()[0], fail_fast); + CHECK_THROW(empty_av.cbegin()[0], fail_fast); + + for (auto& v : empty_av) + { + CHECK(false); + } + } - strided_array_view empty_sav{ empty_av, { 0, 1 } }; + { + array_view empty_av = {}; + + CHECK(empty_av.bounds().index_bounds() == index<1>{ 0 }); + CHECK_THROW(empty_av[0], fail_fast); + CHECK_THROW(empty_av.begin()[0], fail_fast); + CHECK_THROW(empty_av.cbegin()[0], fail_fast); + + for (auto& v : empty_av) + { + CHECK(false); + } + } - CHECK(empty_sav.bounds().index_bounds() == index<1>{ 0 }); - CHECK_THROW(empty_sav[0], fail_fast); + { + array_view empty_av(nullptr); + strided_array_view empty_sav{ empty_av, { 0, 1 } }; - strided_array_view empty_sav2{ nullptr, 0, { 0, 1 } }; + CHECK(empty_sav.bounds().index_bounds() == index<1>{ 0 }); + CHECK_THROW(empty_sav[0], fail_fast); + CHECK_THROW(empty_sav.begin()[0], fail_fast); + CHECK_THROW(empty_sav.cbegin()[0], fail_fast); - CHECK(empty_sav.bounds().index_bounds() == index<1>{ 0 }); - CHECK_THROW(empty_sav[0], fail_fast); + for (auto& v : empty_sav) + { + CHECK(false); + } + } + + { + strided_array_view empty_sav{ nullptr, 0, { 0, 1 } }; + + CHECK(empty_sav.bounds().index_bounds() == index<1>{ 0 }); + CHECK_THROW(empty_sav[0], fail_fast); + CHECK_THROW(empty_sav.begin()[0], fail_fast); + CHECK_THROW(empty_sav.cbegin()[0], fail_fast); + + for (auto& v : empty_sav) + { + CHECK(false); + } + } } TEST(index_constructor)