Skip to content

Commit eece3cd

Browse files
committed
test fixes
1 parent 64e1f70 commit eece3cd

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

flang/runtime/extensions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@
1818
#include <ctime>
1919

2020
#ifdef _WIN32
21-
inline void ctime_alloc(char *buffer, size_t bufsize, const time_t cur_time,
21+
inline void CtimeBuffer(char *buffer, size_t bufsize, const time_t cur_time,
2222
Fortran::runtime::Terminator terminator) {
2323
int error{ctime_s(buffer, bufsize, &cur_time)};
2424
RUNTIME_CHECK(terminator, error == 0);
2525
}
2626
#elif _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE || \
2727
_POSIX_SOURCE
28-
inline void ctime_alloc(char *buffer, size_t bufsize, const time_t cur_time,
28+
inline void CtimeBuffer(char *buffer, size_t bufsize, const time_t cur_time,
2929
Fortran::runtime::Terminator terminator) {
3030
const char *res{ctime_r(&cur_time, buffer)};
3131
RUNTIME_CHECK(terminator, res != nullptr);
3232
}
3333
#else
34-
inline void ctime_alloc(char *buffer, size_t bufsize, const time_t cur_time,
34+
inline void CtimeBuffer(char *buffer, size_t bufsize, const time_t cur_time,
3535
Fortran::runtime::Terminator terminator) {
3636
buffer[0] = '\0';
3737
terminator.Crash("fdate is not supported.");

flang/unittests/Runtime/CommandTest.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,17 @@ TEST_F(NoArgv, FdateGetDate) {
230230

231231
// Tue May 26 21:51:03 2015\n\0
232232
// index at 3, 7, 10, 19 should be space
233-
EXPECT_EQ(input[3], ' ');
234-
EXPECT_EQ(input[7], ' ');
235-
EXPECT_EQ(input[10], ' ');
236-
EXPECT_EQ(input[19], ' ');
233+
// when date is less than two digit, index 8 would be space
234+
// Tue May 6 21:51:03 2015\n\0
235+
for (std::size_t i{0}; i < charLen; i++) {
236+
if (i == 8)
237+
continue;
238+
if (i == 3 || i == 7 || i == 10 || i == 19) {
239+
EXPECT_EQ(input[i], ' ');
240+
continue;
241+
}
242+
EXPECT_NE(input[i], ' ');
243+
}
237244
}
238245

239246
TEST_F(NoArgv, FdateGetDateTooShort) {

0 commit comments

Comments
 (0)