diff options
author | kobake <kobake@users.sourceforge.net> | 2017-03-08 05:19:31 +0900 |
---|---|---|
committer | kobake <kobake@users.sourceforge.net> | 2017-03-08 15:43:40 +0900 |
commit | 8e0720bdb9141b00b4c00893b8139904c67ddacf (patch) | |
tree | a0fdfa9c31529ef96c21805bf079f3c4a8b129a7 /src | |
parent | 292112f87ef1780fee6164063a60af9ee7bf3f86 (diff) |
Fix msvc compiler error C4146 (unary minus operator applied to unsigned type)
On msvc14, int literal '-2147483648' is invalid, because '2147483648' is unsigned type and cant't apply minus operator to unsigned type.
To define the int literal correctly, use '-2147483647 - 1' formula that is also used to define INT_MIN in limits.h.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/util_tests.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 641655621c..79d02257fa 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -321,7 +321,7 @@ BOOST_AUTO_TEST_CASE(test_ParseInt32) BOOST_CHECK(ParseInt32("1234", &n) && n == 1234); BOOST_CHECK(ParseInt32("01234", &n) && n == 1234); // no octal BOOST_CHECK(ParseInt32("2147483647", &n) && n == 2147483647); - BOOST_CHECK(ParseInt32("-2147483648", &n) && n == -2147483648); + BOOST_CHECK(ParseInt32("-2147483648", &n) && n == (-2147483647 - 1)); // (-2147483647 - 1) equals INT_MIN BOOST_CHECK(ParseInt32("-1234", &n) && n == -1234); // Invalid values BOOST_CHECK(!ParseInt32("", &n)); |