aboutsummaryrefslogtreecommitdiff
path: root/tests/span_tests.cpp
diff options
context:
space:
mode:
authorMikeGitb <MikeGitb@users.noreply.github.com>2017-04-02 21:30:49 +0200
committerNeil MacIntosh <neilmac@microsoft.com>2017-04-02 12:30:49 -0700
commitade86caa92e47ad5e5560b8a00d88cb31d79b53b (patch)
tree566c58f7ac7985cae6337730281f859615530d78 /tests/span_tests.cpp
parent33006026535d3664629585b67b852daeb6eaca9f (diff)
downloadMicrosoft-GSL-ade86caa92e47ad5e5560b8a00d88cb31d79b53b.tar.gz
Fix some corechecker warnings (#470)
* Improve const correctness in string_span * Improve const correctness in bounds_tests.cpp and byte_tests.cpp * Improve const correctness in span_tests.cpp * Improve const correctness in utils_tests.cpp * Use gsl::owner for dynamically allocated memory in string_span_tests.cpp * Improve const correctness in string_span_tests.cpp * Improve const correctness for strided_span_tests.cpp
Diffstat (limited to 'tests/span_tests.cpp')
-rw-r--r--tests/span_tests.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/tests/span_tests.cpp b/tests/span_tests.cpp
index 18c18b1..08947cf 100644
--- a/tests/span_tests.cpp
+++ b/tests/span_tests.cpp
@@ -930,7 +930,7 @@ SUITE(span_tests)
CHECK(av.subspan(4).length() == 1);
CHECK(av.subspan(5).length() == 0);
CHECK_THROW(av.subspan(6).length(), fail_fast);
- auto av2 = av.subspan(1);
+ const auto av2 = av.subspan(1);
for (int i = 0; i < 4; ++i) CHECK(av2[i] == i + 2);
}
@@ -941,7 +941,7 @@ SUITE(span_tests)
CHECK(av.subspan(4).length() == 1);
CHECK(av.subspan(5).length() == 0);
CHECK_THROW(av.subspan(6).length(), fail_fast);
- auto av2 = av.subspan(1);
+ const auto av2 = av.subspan(1);
for (int i = 0; i < 4; ++i) CHECK(av2[i] == i + 2);
}
}
@@ -1117,7 +1117,7 @@ SUITE(span_tests)
CHECK(it == beyond);
CHECK(it - beyond == 0);
- for (auto& n : s)
+ for (const auto& n : s)
{
CHECK(n == 5);
}
@@ -1214,7 +1214,7 @@ SUITE(span_tests)
CHECK(it == beyond);
CHECK(it - beyond == 0);
- for (auto& n : s)
+ for (const auto& n : s)
{
CHECK(n == 5);
}
@@ -1386,16 +1386,16 @@ SUITE(span_tests)
int a[] = {1, 2, 3, 4};
{
- span<const int> s = a;
+ const span<const int> s = a;
CHECK(s.length() == 4);
- span<const byte> bs = as_bytes(s);
+ const span<const byte> bs = as_bytes(s);
CHECK(static_cast<const void*>(bs.data()) == static_cast<const void*>(s.data()));
CHECK(bs.length() == s.length_bytes());
}
{
span<int> s;
- auto bs = as_bytes(s);
+ const auto bs = as_bytes(s);
CHECK(bs.length() == s.length());
CHECK(bs.length() == 0);
CHECK(bs.size_bytes() == 0);
@@ -1405,7 +1405,7 @@ SUITE(span_tests)
{
span<int> s = a;
- auto bs = as_bytes(s);
+ const auto bs = as_bytes(s);
CHECK(static_cast<const void*>(bs.data()) == static_cast<const void*>(s.data()));
CHECK(bs.length() == s.length_bytes());
}
@@ -1428,7 +1428,7 @@ SUITE(span_tests)
{
span<int> s;
- auto bs = as_writeable_bytes(s);
+ const auto bs = as_writeable_bytes(s);
CHECK(bs.length() == s.length());
CHECK(bs.length() == 0);
CHECK(bs.size_bytes() == 0);
@@ -1438,7 +1438,7 @@ SUITE(span_tests)
{
span<int> s = a;
- auto bs = as_writeable_bytes(s);
+ const auto bs = as_writeable_bytes(s);
CHECK(static_cast<void*>(bs.data()) == static_cast<void*>(s.data()));
CHECK(bs.length() == s.length_bytes());
}
@@ -1484,11 +1484,11 @@ SUITE(span_tests)
// you can convert statically
{
- span<int, 2> s2 = {arr, 2};
+ const span<int, 2> s2 = {arr, 2};
static_cast<void>(s2);
}
{
- span<int, 1> s1 = s4.first<1>();
+ const span<int, 1> s1 = s4.first<1>();
static_cast<void>(s1);
}
@@ -1532,7 +1532,7 @@ SUITE(span_tests)
{
char lat[] = { '1', '2', '3', '4', '5', '6', 'E', 'F', 'G' };
span<char> s = lat;
- auto f_it = s.begin() + 7;
+ const auto f_it = s.begin() + 7;
std::match_results<span<char>::iterator> match;