Skip to content

Commit 4c78587

Browse files
committed
Move core lib tests to anonymous namespace
Bug: b/503100488 #gemini
1 parent b69c667 commit 4c78587

12 files changed

Lines changed: 23 additions & 10 deletions

base/cvd/cuttlefish/common/libs/fs/shared_fd_test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <gtest/gtest.h>
2121

2222
namespace cuttlefish {
23+
namespace {
2324

2425
char pipe_message[] = "Testing the pipe";
2526

@@ -34,4 +35,5 @@ TEST(SendFD, Basic) {
3435
EXPECT_EQ(0, strcmp(buf, pipe_message));
3536
}
3637

37-
}
38+
} // namespace
39+
} // namespace cuttlefish

base/cvd/cuttlefish/common/libs/utils/base64_test.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "cuttlefish/result/result_type.h"
2626

2727
namespace cuttlefish {
28+
namespace {
2829

2930
TEST(Base64Test, EncodeMult3) {
3031
ASSERT_THAT(EncodeBase64("foobar"), IsOkAndValue("Zm9vYmFy"));
@@ -70,4 +71,6 @@ TEST(Base64Test, EncodeThreeZeroes) {
7071

7172
ASSERT_THAT(DecodeBase64(*string_encoding), IsOkAndValue(in));
7273
}
73-
}
74+
75+
} // namespace
76+
} // namespace cuttlefish

base/cvd/cuttlefish/common/libs/utils/files_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "cuttlefish/result/result_matchers.h"
2828

2929
namespace cuttlefish {
30+
namespace {
3031

3132
using testing::IsTrue;
3233

@@ -180,4 +181,5 @@ INSTANTIATE_TEST_SUITE_P(
180181
.home_dir_ = "/x/y/z",
181182
.expected_ = "/x/y/t/q"}));
182183

184+
} // namespace
183185
} // namespace cuttlefish

base/cvd/cuttlefish/common/libs/utils/flag_parser_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "cuttlefish/result/result_matchers.h"
3333

3434
namespace cuttlefish {
35+
namespace {
3536

3637
TEST(FlagParser, DuplicateAlias) {
3738
FlagAlias alias = {FlagAliasMode::kFlagExact, "--flag"};
@@ -481,4 +482,5 @@ TEST_F(FlagConsumesArbitraryTest, TwoValuesOtherFlag) {
481482
ASSERT_EQ(elems_, (std::vector<std::string>{"v1", "v2", ""}));
482483
}
483484

485+
} // namespace
484486
} // namespace cuttlefish

base/cvd/cuttlefish/common/libs/utils/proc_file_utils_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "cuttlefish/common/libs/utils/proc_file_utils.h"
2626

2727
namespace cuttlefish {
28+
namespace {
2829

2930
TEST(ProcFileUid, SelfUidTest) {
3031
auto my_pid = getpid();
@@ -43,4 +44,5 @@ TEST(ProcFilePid, CurrentPidCollected) {
4344
ASSERT_TRUE(Contains(*pids_result, this_pid));
4445
}
4546

47+
} // namespace
4648
} // namespace cuttlefish

base/cvd/cuttlefish/common/libs/utils/unix_sockets_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "cuttlefish/common/libs/fs/shared_fd.h"
2828

2929
namespace cuttlefish {
30+
namespace {
3031

3132
SharedFD CreateMemFDWithData(const std::string& data) {
3233
auto memfd = SharedFD::MemfdCreate("");
@@ -197,4 +198,5 @@ TEST(UnixMessageSocket, AutoCredentials) {
197198
ASSERT_EQ(getgid(), credentials_out->gid);
198199
}
199200

201+
} // namespace
200202
} // namespace cuttlefish

base/cvd/cuttlefish/io/in_memory_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "cuttlefish/result/result_matchers.h"
2626

2727
namespace cuttlefish {
28+
namespace {
2829

2930
TEST(InMemoryIoTest, WriteSeek) {
3031
std::unique_ptr<ReaderWriterSeeker> instance = InMemoryIo();
@@ -84,4 +85,5 @@ TEST(InMemoryIoTest, WriteWriteReadAt) {
8485
ASSERT_EQ(absl::StrCat(str, str), data_read);
8586
}
8687

88+
} // namespace
8789
} // namespace cuttlefish

base/cvd/cuttlefish/pretty/container_test.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ void ExpectFormatsTo(const PrettyContainerType& ps,
3838
EXPECT_EQ(sstream.str(), trimmed);
3939
}
4040

41-
} // namespace
42-
4341
TEST(PrettyContainer, Empty) {
4442
ExpectFormatsTo(PrettyContainer(std::vector<int>{}), "{}");
4543
}
@@ -96,4 +94,5 @@ TEST(PrettyContainer, NestedMember) {
9694
)");
9795
}
9896

97+
} // namespace
9998
} // namespace cuttlefish

base/cvd/cuttlefish/pretty/json_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "json/value.h"
2222

2323
namespace cuttlefish {
24+
namespace {
2425

2526
TEST(PrettyJson, Structured) {
2627
Json::Value structured;
@@ -42,4 +43,5 @@ TEST(PrettyJson, Structured) {
4243
EXPECT_TRUE(absl::StrContains(formatted, "\"value\""));
4344
}
4445

46+
} // namespace
4547
} // namespace cuttlefish

base/cvd/cuttlefish/pretty/pretty_test.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ PrettyStruct Pretty(const OuterStruct& outer,
7171
.Member("int_opt_unset", outer.int_opt_unset);
7272
}
7373

74-
} // namespace
75-
7674
TEST(Pretty, OuterInnerStruct) {
7775
OuterStruct outer{
7876
.number_vector = {1, 2, 3},
@@ -152,4 +150,5 @@ OuterStruct {
152150
EXPECT_EQ(absl::StrCat(Pretty(outer)), expected);
153151
}
154152

153+
} // namespace
155154
} // namespace cuttlefish

0 commit comments

Comments
 (0)