Skip to content

Commit

Permalink
build_log_test.cc: Remove using namespace std usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
digit-google committed Nov 26, 2024
1 parent d7ceecd commit c1f74c6
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/build_log_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#endif
#include <cassert>

using namespace std;

namespace {

const char kTestFilename[] = "BuildLogTest-tempfile";
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c1f74c6

Please sign in to comment.