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
path: root/tests
diff options
context:
space:
mode:
authorJordan Maples <jomaples@microsoft.com>2020-05-20 20:59:57 +0300
committerJordan Maples <jomaples@microsoft.com>2020-05-20 20:59:57 +0300
commit552cd20472e46a7e30962b153720af560a89a6fd (patch)
treea88133e544ea808a4afd413f43153ba6d4d6dd04 /tests
parent2085c7acde1068bc1ea94b7fcb29080e261009e7 (diff)
addressing most of Casey's comments
Diffstat (limited to 'tests')
-rw-r--r--tests/span_ext_tests.cpp2
-rw-r--r--tests/span_tests.cpp10
-rw-r--r--tests/string_span_tests.cpp17
3 files changed, 14 insertions, 15 deletions
diff --git a/tests/span_ext_tests.cpp b/tests/span_ext_tests.cpp
index 726d38f..d413e03 100644
--- a/tests/span_ext_tests.cpp
+++ b/tests/span_ext_tests.cpp
@@ -320,7 +320,7 @@ TEST(span_ext_test, make_span_from_array_constructor)
{
int arr[] = {1, 2, 3};
- span<int> s1 = span<int>(&arr[0], 2); // shorter
+ span<int> s1 = {&arr[0], 2}; // shorter
span<int> s2 = arr; // longer
EXPECT_TRUE(s1 != s2);
diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp
index a3da486..ae4503e 100644
--- a/tests/span_tests.cpp
+++ b/tests/span_tests.cpp
@@ -157,7 +157,7 @@ TEST(span_test, from_pointer_length_constructor)
for (int i = 0; i < 4; ++i)
{
{
- span<int> s = span<int>(&arr[0], narrow_cast<std::size_t>(i));
+ span<int> s = {&arr[0], narrow_cast<std::size_t>(i)};
EXPECT_TRUE(s.size() == narrow_cast<std::size_t>(i));
EXPECT_TRUE(s.data() == &arr[0]);
EXPECT_TRUE(s.empty() == (i == 0));
@@ -165,7 +165,7 @@ TEST(span_test, from_pointer_length_constructor)
EXPECT_TRUE(arr[j] == s[narrow_cast<std::size_t>(j)]);
}
{
- span<int> s = span<int>(&arr[i], 4 - narrow_cast<std::size_t>(i));
+ span<int> s = {&arr[i], 4 - narrow_cast<std::size_t>(i)};
EXPECT_TRUE(s.size() == 4 - narrow_cast<std::size_t>(i));
EXPECT_TRUE(s.data() == &arr[i]);
EXPECT_TRUE(s.empty() == ((4 - i) == 0));
@@ -678,7 +678,7 @@ TEST(span_test, from_array_constructor)
s2 = s1;
EXPECT_TRUE(s2.empty());
- auto get_temp_span = [&]() -> span<int> { return span<int>(&arr[1], 2); };
+ auto get_temp_span = [&]() -> span<int> { return {&arr[1], 2}; };
auto use_span = [&](span<const int> s) {
EXPECT_TRUE(s.size() == 2);
EXPECT_TRUE(s.data() == &arr[1]);
@@ -1144,7 +1144,7 @@ TEST(span_test, from_array_constructor)
// you can convert statically
{
- const span<int, 2> s2 = {&arr[0], 2};
+ const span<int, 2> s2(&arr[0], 2);
static_cast<void>(s2);
}
{
@@ -1180,7 +1180,7 @@ TEST(span_test, from_array_constructor)
#endif
{
auto f = [&]() {
- const span<int, 4> _s4 = {arr2, 2};
+ const span<int, 4> _s4(arr2, 2);
static_cast<void>(_s4);
};
EXPECT_DEATH(f(), deathstring);
diff --git a/tests/string_span_tests.cpp b/tests/string_span_tests.cpp
index 09e475e..86cf28e 100644
--- a/tests/string_span_tests.cpp
+++ b/tests/string_span_tests.cpp
@@ -128,7 +128,6 @@ cu16zstring_span<> CreateTempNameU16(u16string_span<> span)
span[last] = u'\0';
auto ret = span.subspan(0, 4);
- // return cu16zstring_span<>(ret);
return {ret};
}
@@ -961,7 +960,7 @@ TEST(string_span_tests, zstring)
char buf[1];
buf[0] = '\0';
- zstring_span<> zspan(span<char>(buf, 1));
+ zstring_span<> zspan({buf, 1});
EXPECT_TRUE(generic::strlen(zspan.assume_z()) == 0);
EXPECT_TRUE(zspan.as_string_span().size() == 0);
@@ -973,7 +972,7 @@ TEST(string_span_tests, zstring)
char buf[1];
buf[0] = 'a';
- auto workaround_macro = [&]() { const zstring_span<> zspan(span<char>(buf, 1)); };
+ auto workaround_macro = [&]() { const zstring_span<> zspan({buf, 1}); };
EXPECT_DEATH(workaround_macro(), deathstring);
}
@@ -1002,7 +1001,7 @@ TEST(string_span_tests, wzstring)
wchar_t buf[1];
buf[0] = L'\0';
- wzstring_span<> zspan(span<wchar_t>(buf, 1));
+ wzstring_span<> zspan({buf, 1});
EXPECT_TRUE(generic::strnlen(zspan.assume_z(), 1) == 0);
EXPECT_TRUE(zspan.as_string_span().size() == 0);
@@ -1014,7 +1013,7 @@ TEST(string_span_tests, wzstring)
wchar_t buf[1];
buf[0] = L'a';
- const auto workaround_macro = [&]() { const wzstring_span<> zspan(span<wchar_t>(buf, 1)); };
+ const auto workaround_macro = [&]() { const wzstring_span<> zspan({buf, 1}); };
EXPECT_DEATH(workaround_macro(), deathstring);
}
@@ -1043,7 +1042,7 @@ TEST(string_span_tests, u16zstring)
char16_t buf[1];
buf[0] = L'\0';
- u16zstring_span<> zspan(span<char16_t>(buf, 1));
+ u16zstring_span<> zspan({buf, 1});
EXPECT_TRUE(generic::strnlen(zspan.assume_z(), 1) == 0);
EXPECT_TRUE(zspan.as_string_span().size() == 0);
@@ -1055,7 +1054,7 @@ TEST(string_span_tests, u16zstring)
char16_t buf[1];
buf[0] = u'a';
- const auto workaround_macro = [&]() { const u16zstring_span<> zspan(span<char16_t>(buf, 1)); };
+ const auto workaround_macro = [&]() { const u16zstring_span<> zspan({buf, 1}); };
EXPECT_DEATH(workaround_macro(), deathstring);
}
@@ -1084,7 +1083,7 @@ TEST(string_span_tests, u32zstring)
char32_t buf[1];
buf[0] = L'\0';
- u32zstring_span<> zspan(span<char32_t>(buf, 1));
+ u32zstring_span<> zspan({buf, 1});
EXPECT_TRUE(generic::strnlen(zspan.assume_z(), 1) == 0);
EXPECT_TRUE(zspan.as_string_span().size() == 0);
@@ -1096,7 +1095,7 @@ TEST(string_span_tests, u32zstring)
char32_t buf[1];
buf[0] = u'a';
- const auto workaround_macro = [&]() { const u32zstring_span<> zspan(span<char32_t>(buf, 1)); };
+ const auto workaround_macro = [&]() { const u32zstring_span<> zspan({buf, 1}); };
EXPECT_DEATH(workaround_macro(), deathstring);
}