Skip to content

Commit 339e824

Browse files
committed
[libc++][lit][AIX] Port tests for getting time to AIX
Summary: This patch ports libc++ LIT test cases for getting time in various locales to AIX. Reviewed by: philnik, Mordante, libc++ Differential Revision: https://reviews.llvm.org/D128087
1 parent 80baa56 commit 339e824

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one.pass.cpp

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
//
99
// NetBSD does not support LC_TIME at the moment
1010
// XFAIL: netbsd
11-
// XFAIL: LIBCXX-AIX-FIXME
1211

1312
// REQUIRES: locale.en_US.UTF-8
1413
// REQUIRES: locale.fr_FR.UTF-8
@@ -54,6 +53,8 @@ int main(int, char**)
5453
const char in[] = "12/31/2061 11:55:59 PM";
5554
#elif defined(TEST_HAS_GLIBC)
5655
const char in[] = "Sat 31 Dec 2061 11:55:59 PM";
56+
#elif defined(_AIX)
57+
const char in[] = "Dec 31, 2061 at 11:55:59 PM";
5758
#else
5859
const char in[] = "Sat Dec 31 23:55:59 2061";
5960
#endif
@@ -67,14 +68,14 @@ int main(int, char**)
6768
assert(t.tm_mday == 31);
6869
assert(t.tm_mon == 11);
6970
assert(t.tm_year == 161);
70-
#ifndef _WIN32
71+
#if !defined(_WIN32) && !defined(_AIX)
7172
assert(t.tm_wday == 6);
7273
#endif
7374
assert(err == std::ios_base::eofbit);
7475
}
7576
{
7677
const my_facet f(LOCALE_en_US_UTF_8, 1);
77-
#if defined(_WIN32) || defined(TEST_HAS_GLIBC)
78+
#if defined(_WIN32) || defined(TEST_HAS_GLIBC) || defined(_AIX)
7879
const char in[] = "11:55:59 PM";
7980
#else
8081
const char in[] = "23:55:59";
@@ -94,6 +95,8 @@ int main(int, char**)
9495
const char in[] = "31/12/2061 23:55:59";
9596
#elif defined(TEST_HAS_GLIBC)
9697
const char in[] = "sam. 31 d""\xC3\xA9""c. 2061 23:55:59";
98+
#elif defined(_AIX)
99+
const char in[] = "31 d""\xC3\xA9""c. 2061 ""\xC3\xA0"" 23:55:59";
97100
#else
98101
const char in[] = "Sam 31 d""\xC3\xA9""c 23:55:59 2061";
99102
#endif
@@ -107,7 +110,7 @@ int main(int, char**)
107110
assert(t.tm_mday == 31);
108111
assert(t.tm_mon == 11);
109112
assert(t.tm_year == 161);
110-
#ifndef _WIN32
113+
#if !defined(_WIN32) && !defined(_AIX)
111114
assert(t.tm_wday == 6);
112115
#endif
113116
assert(err == std::ios_base::eofbit);
@@ -130,6 +133,8 @@ int main(int, char**)
130133
const char in[] = "\xD0\xA1\xD0\xB1 31 \xD0\xB4\xD0\xB5\xD0\xBA 2061 23:55:59";
131134
#elif defined(_WIN32)
132135
const char in[] = "31.12.2061 23:55:59";
136+
#elif defined(_AIX)
137+
const char in[] = "31 \xD0\xB4\xD0\xB5\xD0\xBA. 2061 \xD0\xB3., 23:55:59";
133138
#else
134139
const char in[] = "\xD1\x81\xD1\x83\xD0\xB1\xD0\xB1"
135140
"\xD0\xBE\xD1\x82\xD0\xB0"
@@ -150,7 +155,7 @@ int main(int, char**)
150155
assert(t.tm_mday == 31);
151156
assert(t.tm_mon == 11);
152157
assert(t.tm_year == 161);
153-
#ifndef _WIN32
158+
#if !defined(_WIN32) && !defined(_AIX)
154159
assert(t.tm_wday == 6);
155160
#endif
156161
assert(err == std::ios_base::eofbit);
@@ -177,28 +182,42 @@ int main(int, char**)
177182
"\xE7\xA7\x92";
178183
#elif defined(_WIN32)
179184
const char in[] = "2061/12/31 23:55:59";
185+
#elif defined(_AIX)
186+
// The time field is omitted in the definition below because in the
187+
// date-time format of locale zh_CN.UTF-8 on AIX, there is %Z before
188+
// the time field, i.e, "... %Z %p%I:%M:%S", and its value varies
189+
// depending on the date of the year and the location of the machine
190+
// where the test case is run.
191+
const char in[] = "2061" "\xE5\xB9\xB4" "12" "\xE6\x9C\x88" "31"
192+
"\xE6\x97\xA5";
180193
#else
181194
const char in[] = "\xE5\x85\xAD 12/31 23:55:59 2061";
182195
#endif
183196
err = std::ios_base::goodbit;
184197
t = std::tm();
185198
I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c');
186199
assert(base(i) == in+sizeof(in)/sizeof(in[0])-1);
200+
#ifndef _AIX
187201
assert(t.tm_sec == 59);
188202
assert(t.tm_min == 55);
189203
assert(t.tm_hour == 23);
204+
#endif
190205
assert(t.tm_mday == 31);
191206
assert(t.tm_mon == 11);
192207
assert(t.tm_year == 161);
193-
#ifndef _WIN32
208+
#if !defined(_WIN32) && !defined(_AIX)
194209
assert(t.tm_wday == 6);
195210
#endif
211+
#if !defined(_AIX)
196212
assert(err == std::ios_base::eofbit);
213+
#endif
197214
}
198215
{
199216
const my_facet f(LOCALE_zh_CN_UTF_8, 1);
200217
#if defined(_WIN32)
201218
const char in[] = "23:55:59";
219+
#elif defined(_AIX)
220+
const char in[] = "\xE4\xB8\x8B\xE5\x8D\x88" "11:55:59";
202221
#else
203222
const char in[] = "23""\xE6\x97\xB6""55""\xE5\x88\x86""59""\xE7\xA7\x92";
204223
#endif
@@ -208,7 +227,11 @@ int main(int, char**)
208227
assert(base(i) == in+sizeof(in)/sizeof(in[0])-1);
209228
assert(t.tm_sec == 59);
210229
assert(t.tm_min == 55);
230+
#if defined(_AIX)
231+
assert(t.tm_hour == 11);
232+
#else
211233
assert(t.tm_hour == 23);
234+
#endif
212235
assert(err == std::ios_base::eofbit);
213236
}
214237

libcxx/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
//
99
// NetBSD does not support LC_TIME at the moment
1010
// XFAIL: netbsd
11-
// XFAIL: LIBCXX-AIX-FIXME
1211

1312
// XFAIL: no-wide-characters
1413

@@ -56,6 +55,8 @@ int main(int, char**)
5655
const wchar_t in[] = L"12/31/2061 11:55:59 PM";
5756
#elif defined(TEST_HAS_GLIBC)
5857
const wchar_t in[] = L"Sat 31 Dec 2061 11:55:59 PM";
58+
#elif defined(_AIX)
59+
const wchar_t in[] = L"Dec 31, 2061 at 11:55:59 PM";
5960
#else
6061
const wchar_t in[] = L"Sat Dec 31 23:55:59 2061";
6162
#endif
@@ -69,14 +70,14 @@ int main(int, char**)
6970
assert(t.tm_mday == 31);
7071
assert(t.tm_mon == 11);
7172
assert(t.tm_year == 161);
72-
#ifndef _WIN32
73+
#if !defined(_WIN32) && !defined(_AIX)
7374
assert(t.tm_wday == 6);
7475
#endif
7576
assert(err == std::ios_base::eofbit);
7677
}
7778
{
7879
const my_facet f(LOCALE_en_US_UTF_8, 1);
79-
#if defined(_WIN32) || defined(TEST_HAS_GLIBC)
80+
#if defined(_WIN32) || defined(TEST_HAS_GLIBC) || defined(_AIX)
8081
const wchar_t in[] = L"11:55:59 PM";
8182
#else
8283
const wchar_t in[] = L"23:55:59";
@@ -96,6 +97,8 @@ int main(int, char**)
9697
const wchar_t in[] = L"31/12/2061 23:55:59";
9798
#elif defined(TEST_HAS_GLIBC)
9899
const wchar_t in[] = L"sam. 31 d" L"\xE9" L"c. 2061 23:55:59";
100+
#elif defined(_AIX)
101+
const wchar_t in[] = L"31 d" L"\xE9" L"c. 2061" L"\xE0" L"23:55:59";
99102
#else
100103
const wchar_t in[] = L"Sam 31 d" L"\xE9" L"c 23:55:59 2061";
101104
#endif
@@ -109,7 +112,7 @@ int main(int, char**)
109112
assert(t.tm_mday == 31);
110113
assert(t.tm_mon == 11);
111114
assert(t.tm_year == 161);
112-
#ifndef _WIN32
115+
#if !defined(_WIN32) && !defined(_AIX)
113116
assert(t.tm_wday == 6);
114117
#endif
115118
assert(err == std::ios_base::eofbit);
@@ -184,6 +187,8 @@ int main(int, char**)
184187
const my_facet f(LOCALE_zh_CN_UTF_8, 1);
185188
#ifdef _WIN32
186189
const wchar_t in[] = L"23:55:59";
190+
#elif defined(_AIX)
191+
const wchar_t in[] = L"\x4E0B\x5348" L"11:55:59";
187192
#else
188193
const wchar_t in[] = L"23" L"\x65F6" L"55" L"\x5206" L"59" L"\x79D2";
189194
#endif
@@ -193,7 +198,11 @@ int main(int, char**)
193198
assert(base(i) == in+sizeof(in)/sizeof(in[0])-1);
194199
assert(t.tm_sec == 59);
195200
assert(t.tm_min == 55);
201+
#if defined(_AIX)
202+
assert(t.tm_hour == 11);
203+
#else
196204
assert(t.tm_hour == 23);
205+
#endif
197206
assert(err == std::ios_base::eofbit);
198207
}
199208

0 commit comments

Comments
 (0)