diff options
author | MikeGitb <MikeGitb@users.noreply.github.com> | 2017-04-02 21:30:49 +0200 |
---|---|---|
committer | Neil MacIntosh <neilmac@microsoft.com> | 2017-04-02 12:30:49 -0700 |
commit | ade86caa92e47ad5e5560b8a00d88cb31d79b53b (patch) | |
tree | 566c58f7ac7985cae6337730281f859615530d78 /tests/byte_tests.cpp | |
parent | 33006026535d3664629585b67b852daeb6eaca9f (diff) | |
download | Microsoft-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/byte_tests.cpp')
-rw-r--r-- | tests/byte_tests.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/byte_tests.cpp b/tests/byte_tests.cpp index 8cb0da8..82fdcc0 100644 --- a/tests/byte_tests.cpp +++ b/tests/byte_tests.cpp @@ -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); } } |