From 9ffe98c00e1f0a76f20ef74a1ee2788b2bb8e8b1 Mon Sep 17 00:00:00 2001 From: vitaut Date: Sat, 19 Mar 2016 06:39:33 -0700 Subject: [PATCH] Fix/suppress MSVC warnings --- test/format-impl-test.cc | 2 +- test/gtest-extra-test.cc | 2 +- test/posix-mock-test.cc | 4 ++++ test/printf-test.cc | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/format-impl-test.cc b/test/format-impl-test.cc index a8994bc0..05a5bcdd 100644 --- a/test/format-impl-test.cc +++ b/test/format-impl-test.cc @@ -171,7 +171,7 @@ TEST(FormatTest, WriteToOStreamMaxSize) { EXPECT_CALL(buffer, xsputn(data, static_cast(n))) .WillOnce(testing::Return(max_streamsize)); data += n; - size -= n; + size -= static_cast(n); } while (size != 0); fmt::write(os, w); } diff --git a/test/gtest-extra-test.cc b/test/gtest-extra-test.cc index 1990f311..8f681c2c 100644 --- a/test/gtest-extra-test.cc +++ b/test/gtest-extra-test.cc @@ -46,7 +46,7 @@ namespace { std::string sanitize(const std::string &s) { std::string result; for (std::string::const_iterator i = s.begin(), end = s.end(); i != end; ++i) - result.push_back(*i & static_cast(0xff)); + result.push_back(static_cast(*i & 0xff)); return result; } diff --git a/test/posix-mock-test.cc b/test/posix-mock-test.cc index 2ccd3301..fe131dea 100644 --- a/test/posix-mock-test.cc +++ b/test/posix-mock-test.cc @@ -487,6 +487,9 @@ struct LocaleMock { } *LocaleMock::instance; #ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4273) + _locale_t _create_locale(int category, const char *locale) { return LocaleMock::instance->newlocale(category, locale, 0); } @@ -498,6 +501,7 @@ void _free_locale(_locale_t locale) { double _strtod_l(const char *nptr, char **endptr, _locale_t locale) { return LocaleMock::instance->strtod_l(nptr, endptr, locale); } +# pragma warning(pop) #endif LocaleType newlocale(int category_mask, const char *locale, LocaleType base) { diff --git a/test/printf-test.cc b/test/printf-test.cc index a3a60276..76b09fa2 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -379,7 +379,7 @@ TEST(PrintfTest, Bool) { TEST(PrintfTest, Int) { EXPECT_PRINTF("-42", "%d", -42); EXPECT_PRINTF("-42", "%i", -42); - unsigned u = -42u; + unsigned u = 0 - 42u; EXPECT_PRINTF(fmt::format("{}", u), "%u", -42); EXPECT_PRINTF(fmt::format("{:o}", u), "%o", -42); EXPECT_PRINTF(fmt::format("{:x}", u), "%x", -42);