diff --git a/libcxx/test/std/input.output/iostream.format/print.fun/print.file.pass.cpp b/libcxx/test/std/input.output/iostream.format/print.fun/print.file.pass.cpp index 4a397d3e3d632..3edc0e2245d64 100644 --- a/libcxx/test/std/input.output/iostream.format/print.fun/print.file.pass.cpp +++ b/libcxx/test/std/input.output/iostream.format/print.fun/print.file.pass.cpp @@ -94,11 +94,8 @@ static void test_read_only() { TEST_VALIDATE_EXCEPTION( std::system_error, [&]([[maybe_unused]] const std::system_error& e) { -#ifdef _AIX - [[maybe_unused]] std::string_view what{"failed to write formatted output: Broken pipe"}; -#else - [[maybe_unused]] std::string_view what{"failed to write formatted output: Operation not permitted"}; -#endif + [[maybe_unused]] std::string_view what{ + "failed to write formatted output: " TEST_IF_AIX("Broken pipe", "Operation not permitted")}; TEST_LIBCPP_REQUIRE( e.what() == what, TEST_WRITE_CONCATENATED("\nExpected exception ", what, "\nActual exception ", e.what(), '\n')); diff --git a/libcxx/test/std/input.output/iostream.format/print.fun/println.file.pass.cpp b/libcxx/test/std/input.output/iostream.format/print.fun/println.file.pass.cpp index ebdddd074faf5..07272ebb57e5f 100644 --- a/libcxx/test/std/input.output/iostream.format/print.fun/println.file.pass.cpp +++ b/libcxx/test/std/input.output/iostream.format/print.fun/println.file.pass.cpp @@ -97,11 +97,8 @@ static void test_read_only() { TEST_VALIDATE_EXCEPTION( std::system_error, [&]([[maybe_unused]] const std::system_error& e) { -#ifdef _AIX - [[maybe_unused]] std::string_view what{"failed to write formatted output: Broken pipe"}; -#else - [[maybe_unused]] std::string_view what{"failed to write formatted output: Operation not permitted"}; -#endif + [[maybe_unused]] std::string_view what{ + "failed to write formatted output: " TEST_IF_AIX("Broken pipe", "Operation not permitted")}; TEST_LIBCPP_REQUIRE( e.what() == what, TEST_WRITE_CONCATENATED("\nExpected exception ", what, "\nActual exception ", e.what(), '\n')); diff --git a/libcxx/test/std/input.output/iostream.format/print.fun/vprint_nonunicode.file.pass.cpp b/libcxx/test/std/input.output/iostream.format/print.fun/vprint_nonunicode.file.pass.cpp index 9eb85f3b7b2d8..edc8bb3f543c4 100644 --- a/libcxx/test/std/input.output/iostream.format/print.fun/vprint_nonunicode.file.pass.cpp +++ b/libcxx/test/std/input.output/iostream.format/print.fun/vprint_nonunicode.file.pass.cpp @@ -103,11 +103,8 @@ static void test_read_only() { TEST_VALIDATE_EXCEPTION( std::system_error, [&]([[maybe_unused]] const std::system_error& e) { -#ifdef _AIX - [[maybe_unused]] std::string_view what{"failed to write formatted output: Broken pipe"}; -#else - [[maybe_unused]] std::string_view what{"failed to write formatted output: Operation not permitted"}; -#endif + [[maybe_unused]] std::string_view what{ + "failed to write formatted output: " TEST_IF_AIX("Broken pipe", "Operation not permitted")}; TEST_LIBCPP_REQUIRE( e.what() == what, TEST_WRITE_CONCATENATED("\nExpected exception ", what, "\nActual exception ", e.what(), '\n')); diff --git a/libcxx/test/std/input.output/iostream.format/print.fun/vprint_unicode.file.pass.cpp b/libcxx/test/std/input.output/iostream.format/print.fun/vprint_unicode.file.pass.cpp index 28379b9db50ed..bd9b99166922f 100644 --- a/libcxx/test/std/input.output/iostream.format/print.fun/vprint_unicode.file.pass.cpp +++ b/libcxx/test/std/input.output/iostream.format/print.fun/vprint_unicode.file.pass.cpp @@ -110,11 +110,8 @@ static void test_read_only() { TEST_VALIDATE_EXCEPTION( std::system_error, [&]([[maybe_unused]] const std::system_error& e) { -#ifdef _AIX - [[maybe_unused]] std::string_view what{"failed to write formatted output: Broken pipe"}; -#else - [[maybe_unused]] std::string_view what{"failed to write formatted output: Operation not permitted"}; -#endif + [[maybe_unused]] std::string_view what{ + "failed to write formatted output: " TEST_IF_AIX("Broken pipe", "Operation not permitted")}; TEST_LIBCPP_REQUIRE( e.what() == what, TEST_WRITE_CONCATENATED("\nExpected exception ", what, "\nActual exception ", e.what(), '\n')); diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h index e549ec2ca7a1a..f3c6d8080ff6d 100644 --- a/libcxx/test/support/test_macros.h +++ b/libcxx/test/support/test_macros.h @@ -443,4 +443,10 @@ inline void DoNotOptimize(Tp const& value) { # define TEST_WORKAROUND_BUG_109234844_WEAK /* nothing */ #endif +#ifdef _AIX +# define TEST_IF_AIX(arg_true, arg_false) arg_true +#else +# define TEST_IF_AIX(arg_true, arg_false) arg_false +#endif + #endif // SUPPORT_TEST_MACROS_HPP