[flang-commits] [flang] [llvm] [flang] [flang-rt] Implement AT edit descriptor for Fortran 202X with appropriate handling and tests (PR #189157)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Fri Apr 10 12:52:18 PDT 2026
================
@@ -1018,3 +1018,66 @@ TEST(IOApiTests, ConfusingMinimization) {
EXPECT_TRUE(CompareFormattedStrings(" 65504. ", got))
<< "expected ' 65504. ', got '" << got << '\''; // not 65500.!
}
+
+// Test AT edit descriptor (F2023) - trims trailing blanks on output
+TEST(IOApiTests, ATEditDescriptorOutput) {
+ // Helper to test AT formatted output
+ auto testAT = [](const char *format, const char *input, std::size_t inputLen,
+ const char *expect) {
+ char buffer[800];
+ auto cookie{IONAME(BeginInternalFormattedOutput)(
+ buffer, sizeof buffer, format, std::strlen(format))};
+ EXPECT_TRUE(IONAME(OutputAscii)(cookie, input, inputLen));
+ auto status{IONAME(EndIoStatement)(cookie)};
+ EXPECT_EQ(status, 0) << "AT test: '" << format << "' failed, status "
+ << static_cast<int>(status);
+ std::string got{buffer, sizeof buffer};
+ auto lastNonBlank{got.find_last_not_of(" ")};
+ if (lastNonBlank != std::string::npos) {
+ got.resize(lastNonBlank + 1);
+ }
+ EXPECT_TRUE(CompareFormattedStrings(expect, got))
+ << "AT test: format '" << format << "' input '" << input
+ << "' expected '" << expect << "' got '" << got << "'";
+ };
+
+ // AT trims trailing blanks
+ testAT("(AT)", "hello ", 10, "hello");
+ testAT("(AT)", "hello", 5, "hello");
+ testAT("(AT)", " hi ", 6, " hi");
+ testAT("(AT)", " ", 10, ""); // all blanks -> empty
----------------
eugeneepshteyn wrote:
Would it be possible to avoid manually counting the length? Perhaps have `testAT` accept `const std::string&` instead of separate ptr and len.
https://github.com/llvm/llvm-project/pull/189157
More information about the flang-commits
mailing list