diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:47:26 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:47:26 +0000 |
| commit | 51072bd6bf79ef2bc6a922079bff57c31c1effbc (patch) | |
| tree | 91a2effbc9e6f80bdbbf9eb70e06c51ad0867ea0 /test/libcxx/localization | |
| parent | bb5e33f003797b67974a8893f7f2930fc51b8210 (diff) | |
Notes
Diffstat (limited to 'test/libcxx/localization')
7 files changed, 316 insertions, 0 deletions
diff --git a/test/libcxx/localization/c.locales/version.pass.cpp b/test/libcxx/localization/c.locales/version.pass.cpp new file mode 100644 index 000000000000..0fce59e2b0b8 --- /dev/null +++ b/test/libcxx/localization/c.locales/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <clocale> + +#include <clocale> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/libcxx/localization/locale.categories/__scan_keyword.pass.cpp b/test/libcxx/localization/locale.categories/__scan_keyword.pass.cpp new file mode 100644 index 000000000000..b33aab9a730a --- /dev/null +++ b/test/libcxx/localization/locale.categories/__scan_keyword.pass.cpp @@ -0,0 +1,118 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <locale> + +// Not a portable test + +// __scan_keyword +// Scans [__b, __e) until a match is found in the basic_strings range +// [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke). +// __b will be incremented (visibly), consuming CharT until a match is found +// or proved to not exist. A keyword may be "", in which will match anything. +// If one keyword is a prefix of another, and the next CharT in the input +// might match another keyword, the algorithm will attempt to find the longest +// matching keyword. If the longer matching keyword ends up not matching, then +// no keyword match is found. If no keyword match is found, __ke is returned. +// Else an iterator pointing to the matching keyword is found. If more than +// one keyword matches, an iterator to the first matching keyword is returned. +// If on exit __b == __e, eofbit is set in __err. If __case_sensitive is false, +// __ct is used to force to lower case before comparing characters. +// Examples: +// Keywords: "a", "abb" +// If the input is "a", the first keyword matches and eofbit is set. +// If the input is "abc", no match is found and "ab" are consumed. +// +// template <class _InputIterator, class _ForwardIterator, class _Ctype> +// _ForwardIterator +// __scan_keyword(_InputIterator& __b, _InputIterator __e, +// _ForwardIterator __kb, _ForwardIterator __ke, +// const _Ctype& __ct, ios_base::iostate& __err, +// bool __case_sensitive = true); + +#include <locale> +#include <cassert> + +int main() +{ + const std::ctype<char>& ct = std::use_facet<std::ctype<char> >(std::locale::classic()); + std::ios_base::iostate err = std::ios_base::goodbit; + { + const char input[] = "a"; + const char* in = input; + std::string keys[] = {"a", "abb"}; + err = std::ios_base::goodbit; + std::string* k = std::__scan_keyword(in, input+sizeof(input)-1, + keys, keys+sizeof(keys)/sizeof(keys[0]), + ct, err); + assert(k - keys == 0); + assert(in == input+1); + assert(err == std::ios_base::eofbit); + } + { + const char input[] = "abc"; + const char* in = input; + std::string keys[] = {"a", "abb"}; + err = std::ios_base::goodbit; + std::string* k = std::__scan_keyword(in, input+sizeof(input)-1, + keys, keys+sizeof(keys)/sizeof(keys[0]), + ct, err); + assert(k - keys == 2); + assert(in == input+2); + assert(err == std::ios_base::failbit); + } + { + const char input[] = "abb"; + const char* in = input; + std::string keys[] = {"a", "abb"}; + err = std::ios_base::goodbit; + std::string* k = std::__scan_keyword(in, input+sizeof(input)-1, + keys, keys+sizeof(keys)/sizeof(keys[0]), + ct, err); + assert(k - keys == 1); + assert(in == input+3); + assert(err == std::ios_base::eofbit); + } + { + const char input[] = "Tue "; + const char* in = input; + std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"}; + err = std::ios_base::goodbit; + std::string* k = std::__scan_keyword(in, input+sizeof(input)-1, + keys, keys+sizeof(keys)/sizeof(keys[0]), + ct, err); + assert(k - keys == 2); + assert(in == input+3); + assert(err == std::ios_base::goodbit); + } + { + const char input[] = "tue "; + const char* in = input; + std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"}; + err = std::ios_base::goodbit; + std::string* k = std::__scan_keyword(in, input+sizeof(input)-1, + keys, keys+sizeof(keys)/sizeof(keys[0]), + ct, err); + assert(k - keys == 4); + assert(in == input+0); + assert(err == std::ios_base::failbit); + } + { + const char input[] = "tue "; + const char* in = input; + std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"}; + err = std::ios_base::goodbit; + std::string* k = std::__scan_keyword(in, input+sizeof(input)-1, + keys, keys+sizeof(keys)/sizeof(keys[0]), + ct, err, false); + assert(k - keys == 2); + assert(in == input+3); + assert(err == std::ios_base::goodbit); + } +} diff --git a/test/libcxx/localization/locale.stdcvt/version.pass.cpp b/test/libcxx/localization/locale.stdcvt/version.pass.cpp new file mode 100644 index 000000000000..3885380854cc --- /dev/null +++ b/test/libcxx/localization/locale.stdcvt/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <codecvt> + +#include <codecvt> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/libcxx/localization/locales/locale.convenience/conversions/conversions.string/ctor_move.pass.cpp b/test/libcxx/localization/locales/locale.convenience/conversions/conversions.string/ctor_move.pass.cpp new file mode 100644 index 000000000000..75e2aeb064eb --- /dev/null +++ b/test/libcxx/localization/locales/locale.convenience/conversions/conversions.string/ctor_move.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <locale> + +// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc> + +// wstring_convert(wstring_convert&& other); // EXTENSION + +#include <locale> +#include <codecvt> +#include <cassert> + +int main() +{ + typedef std::codecvt_utf8<wchar_t> Codecvt; + typedef std::wstring_convert<Codecvt> Myconv; + // create a converter and perform some conversions to generate some + // interesting state. + Myconv myconv; + myconv.from_bytes("\xF1\x80\x80\x83"); + const int old_converted = myconv.converted(); + assert(myconv.converted() == 4); + // move construct a new converter and make sure the state is the same. + Myconv myconv2(std::move(myconv)); + assert(myconv2.converted() == 4); +} diff --git a/test/libcxx/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp b/test/libcxx/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp new file mode 100644 index 000000000000..4a7f77ad5d9a --- /dev/null +++ b/test/libcxx/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <locale> + +// class locale::facet +// { +// protected: +// explicit facet(size_t refs = 0); +// virtual ~facet(); +// facet(const facet&) = delete; +// void operator=(const facet&) = delete; +// }; + +// This test isn't portable + +#include <locale> +#include <cassert> + +struct my_facet + : public std::locale::facet +{ + static int count; + my_facet(unsigned refs = 0) + : std::locale::facet(refs) + {++count;} + + ~my_facet() {--count;} +}; + +int my_facet::count = 0; + +int main() +{ + my_facet* f = new my_facet; + f->__add_shared(); + assert(my_facet::count == 1); + f->__release_shared(); + assert(my_facet::count == 0); + f = new my_facet(1); + f->__add_shared(); + assert(my_facet::count == 1); + f->__release_shared(); + assert(my_facet::count == 1); + f->__release_shared(); + assert(my_facet::count == 0); +} diff --git a/test/libcxx/localization/locales/locale/locale.types/locale.id/id.pass.cpp b/test/libcxx/localization/locales/locale/locale.types/locale.id/id.pass.cpp new file mode 100644 index 000000000000..3233624d87b4 --- /dev/null +++ b/test/libcxx/localization/locales/locale/locale.types/locale.id/id.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <locale> + +// class locale::id +// { +// public: +// id(); +// void operator=(const id&) = delete; +// id(const id&) = delete; +// }; + +// This test isn't portable + +#include <locale> +#include <cassert> + +std::locale::id id0; +std::locale::id id2; +std::locale::id id1; + +int main() +{ + long id = id0.__get(); + assert(id0.__get() == id+0); + assert(id0.__get() == id+0); + assert(id0.__get() == id+0); + assert(id1.__get() == id+1); + assert(id1.__get() == id+1); + assert(id1.__get() == id+1); + assert(id2.__get() == id+2); + assert(id2.__get() == id+2); + assert(id2.__get() == id+2); + assert(id0.__get() == id+0); + assert(id0.__get() == id+0); + assert(id0.__get() == id+0); + assert(id1.__get() == id+1); + assert(id1.__get() == id+1); + assert(id1.__get() == id+1); + assert(id2.__get() == id+2); + assert(id2.__get() == id+2); + assert(id2.__get() == id+2); +} diff --git a/test/libcxx/localization/version.pass.cpp b/test/libcxx/localization/version.pass.cpp new file mode 100644 index 000000000000..a64534c9f58b --- /dev/null +++ b/test/libcxx/localization/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <locale> + +#include <locale> + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} |
