From 506ff320f2bf85b3d685c67358994026a2110e84 Mon Sep 17 00:00:00 2001 From: Ashton Fagg Date: Fri, 6 Nov 2020 18:39:59 -0500 Subject: [PATCH] Fix build failure when not using fcntl with -Werror (#1990) --- test/gtest-extra-test.cc | 12 ++---------- test/posix-mock-test.cc | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/test/gtest-extra-test.cc b/test/gtest-extra-test.cc index ea728607..8855bd35 100644 --- a/test/gtest-extra-test.cc +++ b/test/gtest-extra-test.cc @@ -22,14 +22,6 @@ namespace { -// This is used to suppress coverity warnings about untrusted values. -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(static_cast(*i & 0xff)); - return result; -} - // Tests that assertion macros evaluate their arguments exactly once. class SingleEvaluationTest : public ::testing::Test { protected: @@ -388,8 +380,8 @@ TEST(OutputRedirectTest, RestoreAndRead) { std::fprintf(file.get(), "[[["); OutputRedirect redir(file.get()); std::fprintf(file.get(), "censored"); - EXPECT_EQ("censored", sanitize(redir.restore_and_read())); - EXPECT_EQ("", sanitize(redir.restore_and_read())); + EXPECT_EQ("censored", redir.restore_and_read()); + EXPECT_EQ("", redir.restore_and_read()); std::fprintf(file.get(), "]]]"); file = buffered_file(); EXPECT_READ(read_end, "[[[]]]"); diff --git a/test/posix-mock-test.cc b/test/posix-mock-test.cc index eb85756d..2f30e81c 100644 --- a/test/posix-mock-test.cc +++ b/test/posix-mock-test.cc @@ -194,12 +194,12 @@ int(test::fileno)(FILE* stream) { # define EXPECT_EQ_POSIX(expected, actual) #endif +#if FMT_USE_FCNTL static void write_file(fmt::cstring_view filename, fmt::string_view content) { fmt::buffered_file f(filename, "w"); f.print("{}", content); } -#if FMT_USE_FCNTL using fmt::file; TEST(UtilTest, GetPageSize) {