diff --git a/test/format-test.cc b/test/format-test.cc index 3c4e6c8b..d331f9d4 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -148,7 +148,8 @@ std::string GetSystemErrorMessage(int error_code) { enum { BUFFER_SIZE = 200 }; char buffer[BUFFER_SIZE]; EXPECT_EQ(0, strerror_s(buffer, BUFFER_SIZE, error_code)); - EXPECT_LT(std::strlen(buffer), BUFFER_SIZE - 1); + std::size_t max_len = BUFFER_SIZE - 1; + EXPECT_LT(std::strlen(buffer), max_len); return buffer; #endif } diff --git a/test/gtest-extra-test.cc b/test/gtest-extra-test.cc index af14fd5a..9215fa7c 100644 --- a/test/gtest-extra-test.cc +++ b/test/gtest-extra-test.cc @@ -262,7 +262,8 @@ std::string Read(File &f, std::size_t count) { std::size_t offset = 0; do { n = f.read(&buffer[offset], count - offset); - offset += n; + // We can't read more than size_t bytes since count has type size_t. + offset += static_cast(n); } while (offset < count && n != 0); buffer.resize(offset); return buffer; @@ -275,7 +276,9 @@ void Write(File &f, fmt::StringRef s) { do { std::streamsize count = f.write(ptr, num_chars_left); ptr += count; - num_chars_left -= count; + // We can't write more than size_t bytes since num_chars_left + // has type size_t. + num_chars_left -= static_cast(count); } while (num_chars_left != 0); }