From cfff3cde629e006e35db40014fdcc631b5240939 Mon Sep 17 00:00:00 2001 From: MikeGitb Date: Thu, 8 Dec 2016 16:15:39 +0100 Subject: [PATCH] Add compilation error test for as_writable_bytes --- tests/span_tests.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp index d622eb7..a5691ee 100644 --- a/tests/span_tests.cpp +++ b/tests/span_tests.cpp @@ -149,7 +149,7 @@ SUITE(span_tests) { auto workaround_macro = []() { span s{ nullptr, static_cast::index_type>(0) }; }; - CHECK_THROW(workaround_macro(), fail_fast); + CHECK_THROW(workaround_macro(), fail_fast); } { @@ -680,7 +680,7 @@ SUITE(span_tests) { #ifdef CONFIRM_COMPILATION_ERRORS span s{cstr}; -#endif +#endif span cs{cstr}; CHECK(cs.size() == narrow_cast(cstr.size()) && cs.data() == cstr.data()); @@ -691,7 +691,7 @@ SUITE(span_tests) auto get_temp_vector = []() -> std::vector { return {}; }; auto use_span = [](span s) { static_cast(s); }; use_span(get_temp_vector()); -#endif +#endif } { @@ -705,7 +705,7 @@ SUITE(span_tests) auto get_temp_string = []() -> std::string { return{}; }; auto use_span = [](span s) { static_cast(s); }; use_span(get_temp_string()); -#endif +#endif } { @@ -866,7 +866,7 @@ SUITE(span_tests) span av = arr; #ifdef CONFIRM_COMPILATION_ERRORS CHECK(av.last<6>().length() == 6); -#endif +#endif CHECK_THROW(av.last(6).length(), fail_fast); } @@ -1098,7 +1098,7 @@ SUITE(span_tests) CHECK(beyond - first == 4); CHECK(first - first == 0); CHECK(beyond - beyond == 0); - + ++it; CHECK(it - first == 1); CHECK(*it == 2); @@ -1478,9 +1478,10 @@ SUITE(span_tests) MyTC_t dst{ 1 }; auto src_b = as_bytes(src); auto dst_b = as_writeable_bytes(dst); - std::copy(src_b.begin(), src_b.end(), dst_b.begin()); - CHECK(std::equal(src_b.begin(), src_b.end(), dst_b.begin())); - CHECK(src == dst); + } + { + const std::array data{ 1, 2, 3, 4 }; + auto raw = as_writeable_bytes(data); } #endif } @@ -1556,7 +1557,7 @@ SUITE(span_tests) auto f = [&]() { span _s4 = {arr2, 2}; static_cast(_s4); - }; + }; CHECK_THROW(f(), fail_fast); } @@ -1564,7 +1565,7 @@ SUITE(span_tests) span av = arr2; auto f = [&]() { span _s4 = av; - static_cast(_s4); + static_cast(_s4); }; CHECK_THROW(f(), fail_fast); }