diff --git a/libc/test/UnitTest/ErrnoSetterMatcher.h b/libc/test/UnitTest/ErrnoSetterMatcher.h --- a/libc/test/UnitTest/ErrnoSetterMatcher.h +++ b/libc/test/UnitTest/ErrnoSetterMatcher.h @@ -45,24 +45,20 @@ void explainError() override { if (ActualReturn != ExpectedReturn) { if constexpr (cpp::is_floating_point_v) { - __llvm_libc::testing::tlog - << "Expected return value to be: " - << str(__llvm_libc::fputil::FPBits(ExpectedReturn)) << '\n'; - __llvm_libc::testing::tlog - << " But got: " - << str(__llvm_libc::fputil::FPBits(ActualReturn)) << '\n'; + tlog << "Expected return value to be: " + << str(fputil::FPBits(ExpectedReturn)) << '\n'; + tlog << " But got: " + << str(fputil::FPBits(ActualReturn)) << '\n'; } else { - __llvm_libc::testing::tlog << "Expected return value to be " - << ExpectedReturn << " but got " - << ActualReturn << ".\n"; + tlog << "Expected return value to be " << ExpectedReturn << " but got " + << ActualReturn << ".\n"; } } if constexpr (!ignore_errno()) { if (ActualErrno != ExpectedErrno) { - __llvm_libc::testing::tlog - << "Expected errno to be \"" << get_error_string(ExpectedErrno) - << "\" but got \"" << get_error_string(ActualErrno) << "\".\n"; + tlog << "Expected errno to be \"" << get_error_string(ExpectedErrno) + << "\" but got \"" << get_error_string(ActualErrno) << "\".\n"; } } } diff --git a/libc/test/UnitTest/FPExceptMatcher.h b/libc/test/UnitTest/FPExceptMatcher.h --- a/libc/test/UnitTest/FPExceptMatcher.h +++ b/libc/test/UnitTest/FPExceptMatcher.h @@ -14,12 +14,11 @@ #include "test/UnitTest/Test.h" namespace __llvm_libc { -namespace fputil { namespace testing { // TODO: Make the matcher match specific exceptions instead of just identifying // that an exception was raised. -class FPExceptMatcher : public __llvm_libc::testing::Matcher { +class FPExceptMatcher : public Matcher { bool exceptionRaised; public: @@ -45,22 +44,19 @@ bool match(bool unused) { return exceptionRaised; } void explainError() override { - __llvm_libc::testing::tlog - << "A floating point exception should have been raised but it " - << "wasn't\n"; + tlog << "A floating point exception should have been raised but it " + << "wasn't\n"; } }; } // namespace testing -} // namespace fputil } // namespace __llvm_libc #define ASSERT_RAISES_FP_EXCEPT(func) \ ASSERT_THAT( \ true, \ - __llvm_libc::fputil::testing::FPExceptMatcher( \ - __llvm_libc::fputil::testing::FPExceptMatcher::getFunctionCaller( \ - func))) + __llvm_libc::testing::FPExceptMatcher( \ + __llvm_libc::testing::FPExceptMatcher::getFunctionCaller(func))) #else #define ASSERT_RAISES_FP_EXCEPT(func) ASSERT_DEATH(func, WITH_SIGNAL(SIGFPE)) #endif // LIBC_COPT_TEST_USE_FUCHSIA diff --git a/libc/test/UnitTest/FPExceptMatcher.cpp b/libc/test/UnitTest/FPExceptMatcher.cpp --- a/libc/test/UnitTest/FPExceptMatcher.cpp +++ b/libc/test/UnitTest/FPExceptMatcher.cpp @@ -14,7 +14,6 @@ #include namespace __llvm_libc { -namespace fputil { namespace testing { #if defined(_WIN32) @@ -48,5 +47,4 @@ } } // namespace testing -} // namespace fputil } // namespace __llvm_libc diff --git a/libc/test/UnitTest/MemoryMatcher.h b/libc/test/UnitTest/MemoryMatcher.h --- a/libc/test/UnitTest/MemoryMatcher.h +++ b/libc/test/UnitTest/MemoryMatcher.h @@ -14,38 +14,36 @@ #include "test/UnitTest/Test.h" namespace __llvm_libc { -namespace memory { namespace testing { using MemoryView = __llvm_libc::cpp::span; } // namespace testing -} // namespace memory } // namespace __llvm_libc #ifdef LIBC_COPT_TEST_USE_FUCHSIA #define EXPECT_MEM_EQ(expected, actual) \ do { \ - __llvm_libc::memory::testing::MemoryView e = (expected); \ - __llvm_libc::memory::testing::MemoryView a = (actual); \ + __llvm_libc::testing::MemoryView e = (expected); \ + __llvm_libc::testing::MemoryView a = (actual); \ ASSERT_EQ(e.size(), a.size()); \ EXPECT_BYTES_EQ(e.data(), a.data(), e.size()); \ } while (0) #define ASSERT_MEM_EQ(expected, actual) \ do { \ - __llvm_libc::memory::testing::MemoryView e = (expected); \ - __llvm_libc::memory::testing::MemoryView a = (actual); \ + __llvm_libc::testing::MemoryView e = (expected); \ + __llvm_libc::testing::MemoryView a = (actual); \ ASSERT_EQ(e.size(), a.size()); \ ASSERT_BYTES_EQ(e.data(), a.data(), e.size()); \ } while (0) #else -namespace __llvm_libc::memory::testing { +namespace __llvm_libc::testing { -class MemoryMatcher : public __llvm_libc::testing::Matcher { +class MemoryMatcher : public Matcher { MemoryView expected; MemoryView actual; bool mismatch_size = false; @@ -59,12 +57,12 @@ void explainError() override; }; -} // namespace __llvm_libc::memory::testing +} // namespace __llvm_libc::testing #define EXPECT_MEM_EQ(expected, actual) \ - EXPECT_THAT(actual, __llvm_libc::memory::testing::MemoryMatcher(expected)) + EXPECT_THAT(actual, __llvm_libc::testing::MemoryMatcher(expected)) #define ASSERT_MEM_EQ(expected, actual) \ - ASSERT_THAT(actual, __llvm_libc::memory::testing::MemoryMatcher(expected)) + ASSERT_THAT(actual, __llvm_libc::testing::MemoryMatcher(expected)) #endif diff --git a/libc/test/UnitTest/MemoryMatcher.cpp b/libc/test/UnitTest/MemoryMatcher.cpp --- a/libc/test/UnitTest/MemoryMatcher.cpp +++ b/libc/test/UnitTest/MemoryMatcher.cpp @@ -13,7 +13,6 @@ using __llvm_libc::testing::tlog; namespace __llvm_libc { -namespace memory { namespace testing { template @@ -76,5 +75,4 @@ } } // namespace testing -} // namespace memory } // namespace __llvm_libc diff --git a/libc/test/UnitTest/PrintfMatcher.h b/libc/test/UnitTest/PrintfMatcher.h --- a/libc/test/UnitTest/PrintfMatcher.h +++ b/libc/test/UnitTest/PrintfMatcher.h @@ -15,32 +15,28 @@ #include namespace __llvm_libc { -namespace printf_core { namespace testing { -class FormatSectionMatcher - : public __llvm_libc::testing::Matcher { - FormatSection expected; - FormatSection actual; +class FormatSectionMatcher : public Matcher { + printf_core::FormatSection expected; + printf_core::FormatSection actual; public: - FormatSectionMatcher(FormatSection expectedValue) : expected(expectedValue) {} + FormatSectionMatcher(printf_core::FormatSection expectedValue) + : expected(expectedValue) {} - bool match(FormatSection actualValue); + bool match(printf_core::FormatSection actualValue); void explainError() override; }; } // namespace testing -} // namespace printf_core } // namespace __llvm_libc #define EXPECT_PFORMAT_EQ(expected, actual) \ - EXPECT_THAT(actual, __llvm_libc::printf_core::testing::FormatSectionMatcher( \ - expected)) + EXPECT_THAT(actual, __llvm_libc::testing::FormatSectionMatcher(expected)) #define ASSERT_PFORMAT_EQ(expected, actual) \ - ASSERT_THAT(actual, __llvm_libc::printf_core::testing::FormatSectionMatcher( \ - expected)) + ASSERT_THAT(actual, __llvm_libc::testing::FormatSectionMatcher(expected)) #endif // LLVM_LIBC_UTILS_UNITTEST_PRINTF_MATCHER_H diff --git a/libc/test/UnitTest/PrintfMatcher.cpp b/libc/test/UnitTest/PrintfMatcher.cpp --- a/libc/test/UnitTest/PrintfMatcher.cpp +++ b/libc/test/UnitTest/PrintfMatcher.cpp @@ -16,12 +16,13 @@ #include -using __llvm_libc::testing::tlog; - namespace __llvm_libc { -namespace printf_core { namespace testing { +using printf_core::FormatFlags; +using printf_core::FormatSection; +using printf_core::LengthModifier; + bool FormatSectionMatcher::match(FormatSection actualValue) { actual = actualValue; return expected == actual; @@ -93,5 +94,4 @@ } } // namespace testing -} // namespace printf_core } // namespace __llvm_libc diff --git a/libc/test/UnitTest/ScanfMatcher.h b/libc/test/UnitTest/ScanfMatcher.h --- a/libc/test/UnitTest/ScanfMatcher.h +++ b/libc/test/UnitTest/ScanfMatcher.h @@ -15,32 +15,28 @@ #include namespace __llvm_libc { -namespace scanf_core { namespace testing { -class FormatSectionMatcher - : public __llvm_libc::testing::Matcher { - FormatSection expected; - FormatSection actual; +class FormatSectionMatcher : public Matcher { + scanf_core::FormatSection expected; + scanf_core::FormatSection actual; public: - FormatSectionMatcher(FormatSection expectedValue) : expected(expectedValue) {} + FormatSectionMatcher(scanf_core::FormatSection expectedValue) + : expected(expectedValue) {} - bool match(FormatSection actualValue); + bool match(scanf_core::FormatSection actualValue); void explainError() override; }; } // namespace testing -} // namespace scanf_core } // namespace __llvm_libc #define EXPECT_SFORMAT_EQ(expected, actual) \ - EXPECT_THAT(actual, __llvm_libc::scanf_core::testing::FormatSectionMatcher( \ - expected)) + EXPECT_THAT(actual, __llvm_libc::testing::FormatSectionMatcher(expected)) #define ASSERT_SFORMAT_EQ(expected, actual) \ - ASSERT_THAT(actual, __llvm_libc::scanf_core::testing::FormatSectionMatcher( \ - expected)) + ASSERT_THAT(actual, __llvm_libc::testing::FormatSectionMatcher(expected)) #endif // LLVM_LIBC_UTILS_UNITTEST_SCANF_MATCHER_H diff --git a/libc/test/UnitTest/ScanfMatcher.cpp b/libc/test/UnitTest/ScanfMatcher.cpp --- a/libc/test/UnitTest/ScanfMatcher.cpp +++ b/libc/test/UnitTest/ScanfMatcher.cpp @@ -16,12 +16,13 @@ #include -using __llvm_libc::testing::tlog; - namespace __llvm_libc { -namespace scanf_core { namespace testing { +using scanf_core::FormatFlags; +using scanf_core::FormatSection; +using scanf_core::LengthModifier; + bool FormatSectionMatcher::match(FormatSection actualValue) { actual = actualValue; return expected == actual; @@ -98,5 +99,4 @@ } } // namespace testing -} // namespace scanf_core } // namespace __llvm_libc diff --git a/libc/test/src/__support/File/file_test.cpp b/libc/test/src/__support/File/file_test.cpp --- a/libc/test/src/__support/File/file_test.cpp +++ b/libc/test/src/__support/File/file_test.cpp @@ -16,7 +16,7 @@ #include using ModeFlags = __llvm_libc::File::ModeFlags; -using MemoryView = __llvm_libc::memory::testing::MemoryView; +using MemoryView = __llvm_libc::testing::MemoryView; using __llvm_libc::ErrorOr; using __llvm_libc::File; using __llvm_libc::FileIOResult; diff --git a/libc/test/src/stdio/fopencookie_test.cpp b/libc/test/src/stdio/fopencookie_test.cpp --- a/libc/test/src/stdio/fopencookie_test.cpp +++ b/libc/test/src/stdio/fopencookie_test.cpp @@ -22,7 +22,7 @@ #include #include -using MemoryView = __llvm_libc::memory::testing::MemoryView; +using MemoryView = __llvm_libc::testing::MemoryView; struct StringStream { char *buf; diff --git a/libc/test/src/time/TmMatcher.h b/libc/test/src/time/TmMatcher.h --- a/libc/test/src/time/TmMatcher.h +++ b/libc/test/src/time/TmMatcher.h @@ -14,10 +14,9 @@ #include "test/UnitTest/Test.h" namespace __llvm_libc { -namespace tmmatcher { namespace testing { -class StructTmMatcher : public __llvm_libc::testing::Matcher<::tm> { +class StructTmMatcher : public Matcher<::tm> { ::tm expected; ::tm actual; @@ -38,17 +37,17 @@ } void describeValue(const char *label, ::tm value) { - __llvm_libc::testing::tlog << label; - __llvm_libc::testing::tlog << " sec: " << value.tm_sec; - __llvm_libc::testing::tlog << " min: " << value.tm_min; - __llvm_libc::testing::tlog << " hour: " << value.tm_hour; - __llvm_libc::testing::tlog << " mday: " << value.tm_mday; - __llvm_libc::testing::tlog << " mon: " << value.tm_mon; - __llvm_libc::testing::tlog << " year: " << value.tm_year; - __llvm_libc::testing::tlog << " wday: " << value.tm_wday; - __llvm_libc::testing::tlog << " yday: " << value.tm_yday; - __llvm_libc::testing::tlog << " isdst: " << value.tm_isdst; - __llvm_libc::testing::tlog << '\n'; + tlog << label; + tlog << " sec: " << value.tm_sec; + tlog << " min: " << value.tm_min; + tlog << " hour: " << value.tm_hour; + tlog << " mday: " << value.tm_mday; + tlog << " mon: " << value.tm_mon; + tlog << " year: " << value.tm_year; + tlog << " wday: " << value.tm_wday; + tlog << " yday: " << value.tm_yday; + tlog << " isdst: " << value.tm_isdst; + tlog << '\n'; } void explainError() override { @@ -58,11 +57,9 @@ }; } // namespace testing -} // namespace tmmatcher } // namespace __llvm_libc #define EXPECT_TM_EQ(expected, actual) \ - EXPECT_THAT((actual), \ - __llvm_libc::tmmatcher::testing::StructTmMatcher((expected))) + EXPECT_THAT((actual), __llvm_libc::testing::StructTmMatcher((expected))) #endif // LLVM_LIBC_TEST_SRC_TIME_TM_MATCHER_H