Try fixing bogus coverity warnings, take n

This commit is contained in:
vitaut 2015-10-22 07:33:01 -07:00
parent b64913b00b
commit fb27723a9f
2 changed files with 10 additions and 3 deletions

View File

@ -140,8 +140,9 @@ template <>
struct IntChecker<true> {
template <typename T>
static bool fits_in_int(T value) {
return internal::check(value >= INT_MIN) && value <= INT_MAX;
return value >= INT_MIN && value <= INT_MAX;
}
static bool fits_in_int(int value) { return true; }
};
const char RESET_COLOR[] = "\x1b[0m";

View File

@ -42,6 +42,13 @@ using testing::internal::scoped_ptr;
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 & 0xff);
return result;
}
// Tests that assertion macros evaluate their arguments exactly once.
class SingleEvaluationTest : public ::testing::Test {
protected:
@ -377,8 +384,7 @@ TEST(OutputRedirectTest, RestoreAndRead) {
std::fprintf(file.get(), "[[[");
OutputRedirect redir(file.get());
std::fprintf(file.get(), "censored");
// coverity[tainted_data]
EXPECT_EQ("censored", redir.restore_and_read());
EXPECT_EQ("censored", sanitize(redir.restore_and_read()));
EXPECT_EQ("", redir.restore_and_read());
std::fprintf(file.get(), "]]]");
file = BufferedFile();