Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/GSL.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil MacIntosh <neilmac@microsoft.com>2016-06-15 06:14:17 +0300
committerNeil MacIntosh <neilmac@microsoft.com>2016-06-15 06:14:17 +0300
commit62f30205e5be7e87f1b566ee8395d9363f2ec984 (patch)
treeba0894118218a6d2833bdaaa8dc7d3792e76d971 /tests/span_tests.cpp
parentc94a66f4684e38ad599d5de15a5f6ac319395286 (diff)
Additional std::array ctor to support const element cases.
Diffstat (limited to 'tests/span_tests.cpp')
-rw-r--r--tests/span_tests.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp
index 81784c3..5c17552 100644
--- a/tests/span_tests.cpp
+++ b/tests/span_tests.cpp
@@ -400,6 +400,7 @@ SUITE(span_tests)
take_a_span(get_an_array());
}
#endif
+
{
auto get_an_array = []() -> std::array<int, 4> { return { 1, 2, 3, 4 }; };
auto take_a_span = [](span<const int> s) { static_cast<void>(s); };
@@ -445,6 +446,40 @@ SUITE(span_tests)
#endif
}
+ TEST(from_std_array_const_constructor)
+ {
+ std::array<const int, 4> arr = {1, 2, 3, 4};
+
+ {
+ span<const int> s{arr};
+ CHECK(s.size() == narrow_cast<ptrdiff_t>(arr.size()) && s.data() == arr.data());
+ }
+
+ {
+ span<const int, 4> s{arr};
+ CHECK(s.size() == narrow_cast<ptrdiff_t>(arr.size()) && s.data() == arr.data());
+ }
+#ifdef CONFIRM_COMPILATION_ERRORS
+ {
+ span<const int, 2> s{arr};
+ CHECK(s.size() == 2 && s.data() == arr.data());
+ }
+
+ {
+ span<const int, 0> s{arr};
+ CHECK(s.size() == 0 && s.data() == arr.data());
+ }
+
+ {
+ span<const int, 5> s{arr};
+ }
+
+ {
+ span<int, 4> s{arr};
+ }
+#endif
+ }
+
TEST(from_container_constructor)
{
std::vector<int> v = {1, 2, 3};