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
This commit is contained in:
MikeGitb
2017-04-02 21:30:49 +02:00
committed by Neil MacIntosh
parent 3300602653
commit ade86caa92
7 changed files with 469 additions and 468 deletions

View File

@@ -35,22 +35,22 @@ SUITE(byte_tests)
TEST(construction)
{
{
byte b = static_cast<byte>(4);
const byte b = static_cast<byte>(4);
CHECK(static_cast<unsigned char>(b) == 4);
}
{
byte b = byte(12);
const byte b = byte(12);
CHECK(static_cast<unsigned char>(b) == 12);
}
{
byte b = to_byte<12>();
const byte b = to_byte<12>();
CHECK(static_cast<unsigned char>(b) == 12);
}
{
unsigned char uc = 12;
byte b = to_byte(uc);
const unsigned char uc = 12;
const byte b = to_byte(uc);
CHECK(static_cast<unsigned char>(b) == 12);
}
@@ -63,7 +63,7 @@ SUITE(byte_tests)
TEST(bitwise_operations)
{
byte b = to_byte<0xFF>();
const byte b = to_byte<0xFF>();
byte a = to_byte<0x00>();
CHECK((b | a) == to_byte<0xFF>());
@@ -79,7 +79,7 @@ SUITE(byte_tests)
CHECK(a == to_byte<0x01>());
CHECK((b ^ a) == to_byte<0xFE>());
CHECK(a == to_byte<0x01>());
a ^= b;
CHECK(a == to_byte<0xFE>());
@@ -99,7 +99,7 @@ SUITE(byte_tests)
TEST(to_integer)
{
byte b = to_byte<0x12>();
const byte b = to_byte<0x12>();
CHECK(0x12 == gsl::to_integer<char>(b));
CHECK(0x12 == gsl::to_integer<short>(b));
@@ -125,7 +125,7 @@ SUITE(byte_tests)
TEST(aliasing)
{
int i{ 0 };
int res = modify_both(reinterpret_cast<byte&>(i), i);
const int res = modify_both(reinterpret_cast<byte&>(i), i);
CHECK(res == i);
}
}