aboutsummaryrefslogtreecommitdiff
path: root/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp')
-rw-r--r--test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp
new file mode 100644
index 000000000000..31135a349435
--- /dev/null
+++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_weekday_wide.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: locale.en_US.UTF-8
+// REQUIRES: locale.fr_FR.UTF-8
+// REQUIRES: locale.ru_RU.UTF-8
+// REQUIRES: locale.zh_CN.UTF-8
+
+// <locale>
+
+// class time_get_byname<charT, InputIterator>
+
+// iter_type
+// get_weekday(iter_type s, iter_type end, ios_base& str,
+// ios_base::iostate& err, tm* t) const;
+
+// TODO: investigation needed
+// XFAIL: linux-gnu
+
+#include <locale>
+#include <cassert>
+#include "test_iterators.h"
+
+#include "platform_support.h" // locale name macros
+
+typedef input_iterator<const wchar_t*> I;
+
+typedef std::time_get_byname<wchar_t, I> F;
+
+class my_facet
+ : public F
+{
+public:
+ explicit my_facet(const std::string& nm, std::size_t refs = 0)
+ : F(nm, refs) {}
+};
+
+int main()
+{
+ std::ios ios(0);
+ std::ios_base::iostate err;
+ std::tm t;
+ {
+ const my_facet f(LOCALE_en_US_UTF_8, 1);
+ const wchar_t in[] = L"Monday";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_fr_FR_UTF_8, 1);
+ const wchar_t in[] = L"Lundi";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_ru_RU_UTF_8, 1);
+ const wchar_t in[] = L"\x43F\x43E\x43D\x435\x434\x435\x43B\x44C\x43D\x438\x43A";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+ {
+ const my_facet f(LOCALE_zh_CN_UTF_8, 1);
+ const wchar_t in[] = L"\x661F\x671F\x4E00";
+ err = std::ios_base::goodbit;
+ t = std::tm();
+ I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
+ assert(i.base() == in+sizeof(in)/sizeof(in[0])-1);
+ assert(t.tm_wday == 1);
+ assert(err == std::ios_base::eofbit);
+ }
+}