From c1f74c69f3fd30a126a92d32713be51178da0a73 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Mon, 25 Nov 2024 12:45:52 +0100 Subject: [PATCH] build_log_test.cc: Remove `using namespace std` usage. --- src/build_log_test.cc | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/build_log_test.cc b/src/build_log_test.cc index 630b1f1a92..2b0d6cda2f 100644 --- a/src/build_log_test.cc +++ b/src/build_log_test.cc @@ -27,8 +27,6 @@ #endif #include -using namespace std; - namespace { const char kTestFilename[] = "BuildLogTest-tempfile"; @@ -50,7 +48,7 @@ TEST_F(BuildLogTest, WriteRead) { "build mid: cat in\n"); BuildLog log1; - string err; + std::string err; EXPECT_TRUE(log1.OpenForWrite(kTestFilename, *this, &err)); ASSERT_EQ("", err); log1.RecordCommand(state_.edges_[0], 15, 18); @@ -77,7 +75,7 @@ TEST_F(BuildLogTest, FirstWriteAddsSignature) { const size_t kVersionPos = strlen(kExpectedVersion) - 2; // Points at 'X'. BuildLog log; - string contents, err; + std::string contents, err; EXPECT_TRUE(log.OpenForWrite(kTestFilename, *this, &err)); ASSERT_EQ("", err); @@ -111,7 +109,7 @@ TEST_F(BuildLogTest, DoubleEntry) { BuildLog::LogEntry::HashCommand("command def")); fclose(f); - string err; + std::string err; BuildLog log; EXPECT_TRUE(log.Load(kTestFilename, &err)); ASSERT_EQ("", err); @@ -128,7 +126,7 @@ TEST_F(BuildLogTest, Truncate) { { BuildLog log1; - string err; + std::string err; EXPECT_TRUE(log1.OpenForWrite(kTestFilename, *this, &err)); ASSERT_EQ("", err); log1.RecordCommand(state_.edges_[0], 15, 18); @@ -148,7 +146,7 @@ TEST_F(BuildLogTest, Truncate) { // crash when parsing. for (off_t size = statbuf.st_size; size > 0; --size) { BuildLog log2; - string err; + std::string err; EXPECT_TRUE(log2.OpenForWrite(kTestFilename, *this, &err)); ASSERT_EQ("", err); log2.RecordCommand(state_.edges_[0], 15, 18); @@ -169,10 +167,10 @@ TEST_F(BuildLogTest, ObsoleteOldVersion) { fprintf(f, "123 456 0 out command\n"); fclose(f); - string err; + std::string err; BuildLog log; EXPECT_TRUE(log.Load(kTestFilename, &err)); - ASSERT_NE(err.find("version"), string::npos); + ASSERT_NE(err.find("version"), std::string::npos); } TEST_F(BuildLogTest, SpacesInOutput) { @@ -182,7 +180,7 @@ TEST_F(BuildLogTest, SpacesInOutput) { BuildLog::LogEntry::HashCommand("command")); fclose(f); - string err; + std::string err; BuildLog log; EXPECT_TRUE(log.Load(kTestFilename, &err)); ASSERT_EQ("", err); @@ -208,7 +206,7 @@ TEST_F(BuildLogTest, DuplicateVersionHeader) { BuildLog::LogEntry::HashCommand("command2")); fclose(f); - string err; + std::string err; BuildLog log; EXPECT_TRUE(log.Load(kTestFilename, &err)); ASSERT_EQ("", err); @@ -229,22 +227,23 @@ TEST_F(BuildLogTest, DuplicateVersionHeader) { } struct TestDiskInterface : public DiskInterface { - virtual TimeStamp Stat(const string& path, string* err) const { + virtual TimeStamp Stat(const std::string& path, std::string* err) const { return 4; } - virtual bool WriteFile(const string& path, const string& contents) { + virtual bool WriteFile(const std::string& path, const std::string& contents) { assert(false); return true; } - virtual bool MakeDir(const string& path) { + virtual bool MakeDir(const std::string& path) { assert(false); return false; } - virtual Status ReadFile(const string& path, string* contents, string* err) { + virtual Status ReadFile(const std::string& path, std::string* contents, + std::string* err) { assert(false); return NotFound; } - virtual int RemoveFile(const string& path) { + virtual int RemoveFile(const std::string& path) { assert(false); return 0; } @@ -289,7 +288,7 @@ TEST_F(BuildLogTest, VeryLongInputLine) { BuildLog::LogEntry::HashCommand("command2")); fclose(f); - string err; + std::string err; BuildLog log; EXPECT_TRUE(log.Load(kTestFilename, &err)); ASSERT_EQ("", err); @@ -335,7 +334,7 @@ TEST_F(BuildLogRecompactTest, Recompact) { "build out2: cat in\n"); BuildLog log1; - string err; + std::string err; EXPECT_TRUE(log1.OpenForWrite(kTestFilename, *this, &err)); ASSERT_EQ("", err); // Record the same edge several times, to trigger recompaction