libcxx initial import

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103490 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2010-05-11 19:42:16 +00:00
commit bc8d3f97eb
3893 changed files with 1209942 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <clocale>
#include <clocale>
#include <type_traits>
#ifndef LC_ALL
#error LC_ALL not defined
#endif
#ifndef LC_COLLATE
#error LC_COLLATE not defined
#endif
#ifndef LC_CTYPE
#error LC_CTYPE not defined
#endif
#ifndef LC_MONETARY
#error LC_MONETARY not defined
#endif
#ifndef LC_NUMERIC
#error LC_NUMERIC not defined
#endif
#ifndef LC_TIME
#error LC_TIME not defined
#endif
#ifndef NULL
#error NULL not defined
#endif
int main()
{
std::lconv lc;
static_assert((std::is_same<__typeof__(std::setlocale(0, "")), char*>::value), "");
static_assert((std::is_same<__typeof__(std::localeconv()), std::lconv*>::value), "");
}

View File

@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <clocale>
#include <clocale>
#ifndef _LIBCPP_VERSION
#error _LIBCPP_VERSION not defined
#endif
int main()
{
}

View File

@@ -0,0 +1,118 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. 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_senstive 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);
}
}

View File

@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class collate_byname
// int compare(const charT* low1, const charT* high1,
// const charT* low2, const charT* high2) const;
// I'm currently unable to confirm that collation based on named locales
// has any difference from "C" collation. But I do believe I'm picking
// up the OS's collation files.
#include <locale>
#include <string>
#include <cassert>
#include <stdio.h>
int main()
{
{
std::locale l("en_US");
{
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
std::string s2("aaaaaaA");
std::string s3("BaaaaaA");
assert(f.compare(s2.data(), s2.data() + s2.size(),
s3.data(), s3.data() + s3.size()) == 1);
}
{
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
std::wstring s2(L"aaaaaaA");
std::wstring s3(L"BaaaaaA");
assert(f.compare(s2.data(), s2.data() + s2.size(),
s3.data(), s3.data() + s3.size()) == 1);
}
}
{
std::locale l("");
{
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
std::string s2("aaaaaaA");
std::string s3("BaaaaaA");
assert(f.compare(s2.data(), s2.data() + s2.size(),
s3.data(), s3.data() + s3.size()) == 1);
}
{
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
std::wstring s2(L"aaaaaaA");
std::wstring s3(L"BaaaaaA");
assert(f.compare(s2.data(), s2.data() + s2.size(),
s3.data(), s3.data() + s3.size()) == 1);
}
}
{
std::locale l("C");
{
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
std::string s2("aaaaaaA");
std::string s3("BaaaaaA");
assert(f.compare(s2.data(), s2.data() + s2.size(),
s3.data(), s3.data() + s3.size()) == 1);
}
{
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
std::wstring s2(L"aaaaaaA");
std::wstring s3(L"BaaaaaA");
assert(f.compare(s2.data(), s2.data() + s2.size(),
s3.data(), s3.data() + s3.size()) == 1);
}
}
}

View File

@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class collate_byname
// long hash(const charT* low, const charT* high) const;
// This test is not portable
#include <locale>
#include <string>
#include <cassert>
int main()
{
std::locale l("en_US");
{
std::string x1("1234");
std::string x2("12345");
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
assert(f.hash(x1.data(), x1.data() + x1.size())
!= f.hash(x2.data(), x2.data() + x2.size()));
}
{
std::wstring x1(L"1234");
std::wstring x2(L"12345");
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
assert(f.hash(x1.data(), x1.data() + x1.size())
!= f.hash(x2.data(), x2.data() + x2.size()));
}
}

View File

@@ -0,0 +1,63 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class collate_byname
// string_type transform(const charT* low, const charT* high) const;
#include <locale>
#include <string>
#include <cassert>
#include <stdio.h>
int main()
{
{
std::locale l("en_US");
{
std::string x("1234");
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
assert(f.transform(x.data(), x.data() + x.size()) != x);
}
{
std::wstring x(L"1234");
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
assert(f.transform(x.data(), x.data() + x.size()) != x);
}
}
{
std::locale l("");
{
std::string x("1234");
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
assert(f.transform(x.data(), x.data() + x.size()) != x);
}
{
std::wstring x(L"1234");
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
assert(f.transform(x.data(), x.data() + x.size()) != x);
}
}
{
std::locale l("C");
{
std::string x("1234");
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
assert(f.transform(x.data(), x.data() + x.size()) == x);
}
{
std::wstring x(L"1234");
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
assert(f.transform(x.data(), x.data() + x.size()) == x);
}
}
}

View File

@@ -0,0 +1,43 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT>
// class collate_byname
// : public collate<charT>
// {
// public:
// typedef basic_string<charT> string_type;
// explicit collate_byname(const char*, size_t refs = 0);
// explicit collate_byname(const string&, size_t refs = 0);
// protected:
// ~collate_byname();
// };
#include <locale>
#include <string>
#include <cassert>
#include <stdio.h>
int main()
{
std::locale l("en_US");
{
assert(std::has_facet<std::collate_byname<char> >(l));
assert(&std::use_facet<std::collate<char> >(l)
== &std::use_facet<std::collate_byname<char> >(l));
}
{
assert(std::has_facet<std::collate_byname<wchar_t> >(l));
assert(&std::use_facet<std::collate<wchar_t> >(l)
== &std::use_facet<std::collate_byname<wchar_t> >(l));
}
}

View File

@@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class collate;
// explicit collate(size_t refs = 0);
#include <locale>
#include <type_traits>
#include <cassert>
template <class C>
class my_facet
: public std::collate<C>
{
public:
static int count;
explicit my_facet(std::size_t refs = 0)
: std::collate<C>(refs) {++count;}
~my_facet() {--count;}
};
template <class C> int my_facet<C>::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet<char>);
assert(my_facet<char>::count == 1);
}
assert(my_facet<char>::count == 0);
{
my_facet<char> f(1);
assert(my_facet<char>::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet<char>::count == 1);
}
assert(my_facet<char>::count == 1);
}
assert(my_facet<char>::count == 0);
{
std::locale l(std::locale::classic(), new my_facet<wchar_t>);
assert(my_facet<wchar_t>::count == 1);
}
assert(my_facet<wchar_t>::count == 0);
{
my_facet<wchar_t> f(1);
assert(my_facet<wchar_t>::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet<wchar_t>::count == 1);
}
assert(my_facet<wchar_t>::count == 1);
}
assert(my_facet<wchar_t>::count == 0);
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class collate;
// int compare(const charT* low1, const charT* high1,
// const charT* low2, const charT* high2) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
const char ia[] = "1234";
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
const char ib[] = "123";
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
assert(f.compare(ia, ia+sa, ib, ib+2) == 1);
assert(f.compare(ib, ib+2, ia, ia+sa) == -1);
assert(f.compare(ia, ia+sa, ib, ib+3) == 1);
assert(f.compare(ib, ib+3, ia, ia+sa) == -1);
assert(f.compare(ia, ia+sa, ib+1, ib+3) == -1);
assert(f.compare(ib+1, ib+3, ia, ia+sa) == 1);
assert(f.compare(ia, ia+3, ib, ib+3) == 0);
}
{
const wchar_t ia[] = L"1234";
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
const wchar_t ib[] = L"123";
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
assert(f.compare(ia, ia+sa, ib, ib+2) == 1);
assert(f.compare(ib, ib+2, ia, ia+sa) == -1);
assert(f.compare(ia, ia+sa, ib, ib+3) == 1);
assert(f.compare(ib, ib+3, ia, ia+sa) == -1);
assert(f.compare(ia, ia+sa, ib+1, ib+3) == -1);
assert(f.compare(ib+1, ib+3, ia, ia+sa) == 1);
assert(f.compare(ia, ia+3, ib, ib+3) == 0);
}
}

View File

@@ -0,0 +1,39 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class collate;
// long hash(const charT* low, const charT* high) const;
// This test is not portable
#include <locale>
#include <string>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
std::string x1("1234");
std::string x2("12345");
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
assert(f.hash(x1.data(), x1.data() + x1.size())
!= f.hash(x2.data(), x2.data() + x2.size()));
}
{
std::wstring x1(L"1234");
std::wstring x2(L"12345");
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
assert(f.hash(x1.data(), x1.data() + x1.size())
!= f.hash(x2.data(), x2.data() + x2.size()));
}
}

View File

@@ -0,0 +1,34 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class collate;
// string_type transform(const charT* low, const charT* high) const;
#include <locale>
#include <string>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
std::string x("1234");
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
assert(f.transform(x.data(), x.data() + x.size()) == x);
}
{
std::wstring x(L"1234");
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
assert(f.transform(x.data(), x.data() + x.size()) == x);
}
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,49 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT>
// class collate
// : public locale::facet {
// public:
// typedef charT char_type;
// typedef basic_string<charT>string_type;
//
// static locale::id id;
// };
#include <locale>
#include <type_traits>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
assert(std::has_facet<std::collate<char> >(l));
const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
{
(void)std::collate<char>::id;
}
static_assert((std::is_same<std::collate<char>::char_type, char>::value), "");
static_assert((std::is_same<std::collate<char>::string_type, std::string>::value), "");
static_assert((std::is_base_of<std::locale::facet, std::collate<char> >::value), "");
}
{
assert(std::has_facet<std::collate<wchar_t> >(l));
const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
{
(void)std::collate<wchar_t>::id;
}
static_assert((std::is_same<std::collate<wchar_t>::char_type, wchar_t>::value), "");
static_assert((std::is_same<std::collate<wchar_t>::string_type, std::wstring>::value), "");
static_assert((std::is_base_of<std::locale::facet, std::collate<wchar_t> >::value), "");
}
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,57 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// class ctype_base
// {
// public:
// typedef T mask;
//
// // numeric values are for exposition only.
// static const mask space = 1 << 0;
// static const mask print = 1 << 1;
// static const mask cntrl = 1 << 2;
// static const mask upper = 1 << 3;
// static const mask lower = 1 << 4;
// static const mask alpha = 1 << 5;
// static const mask digit = 1 << 6;
// static const mask punct = 1 << 7;
// static const mask xdigit = 1 << 8;
// static const mask alnum = alpha | digit;
// static const mask graph = alnum | punct;
// };
#include <locale>
#include <cassert>
int main()
{
assert(std::ctype_base::space);
assert(std::ctype_base::print);
assert(std::ctype_base::cntrl);
assert(std::ctype_base::upper);
assert(std::ctype_base::lower);
assert(std::ctype_base::alpha);
assert(std::ctype_base::digit);
assert(std::ctype_base::punct);
assert(std::ctype_base::xdigit);
assert(
( std::ctype_base::space
& std::ctype_base::print
& std::ctype_base::cntrl
& std::ctype_base::upper
& std::ctype_base::lower
& std::ctype_base::alpha
& std::ctype_base::digit
& std::ctype_base::punct
& std::ctype_base::xdigit) == 0);
assert(std::ctype_base::alnum == (std::ctype_base::alpha | std::ctype_base::digit));
assert(std::ctype_base::graph == (std::ctype_base::alnum | std::ctype_base::punct));
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>
// ~ctype();
#include <locale>
#include <cassert>
#include <new>
unsigned delete_called = 0;
void operator delete[](void* p) throw()
{
operator delete(p);
++delete_called;
}
int main()
{
{
delete_called = 0;
std::locale l(std::locale::classic(), new std::ctype<char>);
assert(delete_called == 0);
}
assert(delete_called == 0);
{
std::ctype<char>::mask table[256];
delete_called = 0;
std::locale l(std::locale::classic(), new std::ctype<char>(table));
assert(delete_called == 0);
}
assert(delete_called == 0);
{
delete_called = 0;
std::locale l(std::locale::classic(),
new std::ctype<char>(new std::ctype<char>::mask[256], true));
assert(delete_called == 0);
}
assert(delete_called == 1);
}

View File

@@ -0,0 +1,50 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype;
// explicit ctype(const mask* tbl = 0, bool del = false, size_t refs = 0);
#include <locale>
#include <cassert>
class my_facet
: public std::ctype<char>
{
public:
static int count;
explicit my_facet(const mask* tbl = 0, bool del = false, std::size_t refs = 0)
: std::ctype<char>(tbl, del, refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet);
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(0, false, 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
}

View File

@@ -0,0 +1,59 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// bool is(mask m, char c) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
assert(f.is(F::space, ' '));
assert(!f.is(F::space, 'A'));
assert(f.is(F::print, ' '));
assert(!f.is(F::print, '\x07'));
assert(f.is(F::cntrl, '\x07'));
assert(!f.is(F::cntrl, ' '));
assert(f.is(F::upper, 'A'));
assert(!f.is(F::upper, 'a'));
assert(f.is(F::lower, 'a'));
assert(!f.is(F::lower, 'A'));
assert(f.is(F::alpha, 'a'));
assert(!f.is(F::alpha, '1'));
assert(f.is(F::digit, '1'));
assert(!f.is(F::digit, 'a'));
assert(f.is(F::punct, '.'));
assert(!f.is(F::punct, 'a'));
assert(f.is(F::xdigit, 'a'));
assert(!f.is(F::xdigit, 'g'));
assert(f.is(F::alnum, 'a'));
assert(!f.is(F::alnum, '.'));
assert(f.is(F::graph, '.'));
assert(!f.is(F::graph, '\x07'));
}
}

View File

@@ -0,0 +1,118 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// const char* is(const char* low, const char* high, mask* vec) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
const std::string in(" A\x07.a1");
std::vector<F::mask> m(in.size());
const char* h = f.is(in.data(), in.data() + in.size(), m.data());
assert(h == in.data() + in.size());
// ' '
assert( (m[0] & F::space));
assert( (m[0] & F::print));
assert(!(m[0] & F::cntrl));
assert(!(m[0] & F::upper));
assert(!(m[0] & F::lower));
assert(!(m[0] & F::alpha));
assert(!(m[0] & F::digit));
assert(!(m[0] & F::punct));
assert(!(m[0] & F::xdigit));
assert( (m[0] & F::blank));
assert(!(m[0] & F::alnum));
assert(!(m[0] & F::graph));
// 'A'
assert(!(m[1] & F::space));
assert( (m[1] & F::print));
assert(!(m[1] & F::cntrl));
assert( (m[1] & F::upper));
assert(!(m[1] & F::lower));
assert( (m[1] & F::alpha));
assert(!(m[1] & F::digit));
assert(!(m[1] & F::punct));
assert( (m[1] & F::xdigit));
assert(!(m[1] & F::blank));
assert( (m[1] & F::alnum));
assert( (m[1] & F::graph));
// '\x07'
assert(!(m[2] & F::space));
assert(!(m[2] & F::print));
assert( (m[2] & F::cntrl));
assert(!(m[2] & F::upper));
assert(!(m[2] & F::lower));
assert(!(m[2] & F::alpha));
assert(!(m[2] & F::digit));
assert(!(m[2] & F::punct));
assert(!(m[2] & F::xdigit));
assert(!(m[2] & F::blank));
assert(!(m[2] & F::alnum));
assert(!(m[2] & F::graph));
// '.'
assert(!(m[3] & F::space));
assert( (m[3] & F::print));
assert(!(m[3] & F::cntrl));
assert(!(m[3] & F::upper));
assert(!(m[3] & F::lower));
assert(!(m[3] & F::alpha));
assert(!(m[3] & F::digit));
assert( (m[3] & F::punct));
assert(!(m[3] & F::xdigit));
assert(!(m[3] & F::blank));
assert(!(m[3] & F::alnum));
assert( (m[3] & F::graph));
// 'a'
assert(!(m[4] & F::space));
assert( (m[4] & F::print));
assert(!(m[4] & F::cntrl));
assert(!(m[4] & F::upper));
assert( (m[4] & F::lower));
assert( (m[4] & F::alpha));
assert(!(m[4] & F::digit));
assert(!(m[4] & F::punct));
assert( (m[4] & F::xdigit));
assert(!(m[4] & F::blank));
assert( (m[4] & F::alnum));
assert( (m[4] & F::graph));
// '1'
assert(!(m[5] & F::space));
assert( (m[5] & F::print));
assert(!(m[5] & F::cntrl));
assert(!(m[5] & F::upper));
assert(!(m[5] & F::lower));
assert(!(m[5] & F::alpha));
assert( (m[5] & F::digit));
assert(!(m[5] & F::punct));
assert( (m[5] & F::xdigit));
assert(!(m[5] & F::blank));
assert( (m[5] & F::alnum));
assert( (m[5] & F::graph));
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// char narrow(char c, char dfault) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
assert(f.narrow(' ', '*') == ' ');
assert(f.narrow('A', '*') == 'A');
assert(f.narrow('\x07', '*') == '\x07');
assert(f.narrow('.', '*') == '.');
assert(f.narrow('a', '*') == 'a');
assert(f.narrow('1', '*') == '1');
}
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// const char* narrow(const char* low, const char*, char dfault, char* to) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
std::string in(" A\x07.a1");
std::vector<char> v(in.size());
assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
assert(v[0] == ' ');
assert(v[1] == 'A');
assert(v[2] == '\x07');
assert(v[3] == '.');
assert(v[4] == 'a');
assert(v[5] == '1');
}
}

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// const char* scan_is(mask m, const char* low, const char* high) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
const std::string in(" A\x07.a1");
std::vector<F::mask> m(in.size());
assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 2);
assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 4);
assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 5);
assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 3);
assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 1);
}
}

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// const char* scan_not(mask m, const char* low, const char* high) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
const std::string in(" A\x07.a1");
std::vector<F::mask> m(in.size());
assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 2);
assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>
// const mask* table() const throw();
#include <locale>
#include <cassert>
int main()
{
typedef std::ctype<char> F;
{
std::locale l(std::locale::classic(), new std::ctype<char>);
const F& f = std::use_facet<F>(l);
assert(f.table() == f.classic_table());
}
{
std::ctype<char>::mask table[256];
std::locale l(std::locale::classic(), new std::ctype<char>(table));
const F& f = std::use_facet<F>(l);
assert(f.table() == table);
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// char tolower(char) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
assert(f.tolower(' ') == ' ');
assert(f.tolower('A') == 'a');
assert(f.tolower('\x07') == '\x07');
assert(f.tolower('.') == '.');
assert(f.tolower('a') == 'a');
assert(f.tolower('1') == '1');
}
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// const char* tolower(char* low, const char* high) const;
#include <locale>
#include <string>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
std::string in(" A\x07.a1");
assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
assert(in[0] == ' ');
assert(in[1] == 'a');
assert(in[2] == '\x07');
assert(in[3] == '.');
assert(in[4] == 'a');
assert(in[5] == '1');
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// char toupper(char) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
assert(f.toupper(' ') == ' ');
assert(f.toupper('A') == 'A');
assert(f.toupper('\x07') == '\x07');
assert(f.toupper('.') == '.');
assert(f.toupper('a') == 'A');
assert(f.toupper('1') == '1');
}
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// const char* toupper(char* low, const char* high) const;
#include <locale>
#include <string>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
std::string in(" A\x07.a1");
assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
assert(in[0] == ' ');
assert(in[1] == 'A');
assert(in[2] == '\x07');
assert(in[3] == '.');
assert(in[4] == 'A');
assert(in[5] == '1');
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// char widen(char c) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
assert(f.widen(' ') == ' ');
assert(f.widen('A') == 'A');
assert(f.widen('\x07') == '\x07');
assert(f.widen('.') == '.');
assert(f.widen('a') == 'a');
assert(f.widen('1') == '1');
}
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>;
// const char* widen(const char* low, const char* high, char* to) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
std::string in(" A\x07.a1");
std::vector<char> v(in.size());
assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
assert(v[0] == ' ');
assert(v[1] == 'A');
assert(v[2] == '\x07');
assert(v[3] == '.');
assert(v[4] == 'a');
assert(v[5] == '1');
}
}

View File

@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class ctype<char>
// static const mask* classic_table() throw();
#include <locale>
#include <cassert>
int main()
{
typedef std::ctype<char> F;
assert(F::classic_table() != 0);
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <>
// class ctype<char>
// : public locale::facet,
// public ctype_base
// {
// public:
// typedef char char_type;
// };
#include <locale>
#include <type_traits>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
assert(std::has_facet<std::ctype<char> >(l));
const std::ctype<char>& f = std::use_facet<std::ctype<char> >(l);
{
(void)std::ctype<char>::id;
}
static_assert((std::is_same<std::ctype<char>::char_type, char>::value), "");
static_assert((std::is_base_of<std::ctype_base, std::ctype<char> >::value), "");
static_assert((std::is_base_of<std::locale::facet, std::ctype<char> >::value), "");
}
}

View File

@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt_byname<char, char, mbstate_t>
// explicit codecvt_byname(const char* nm, size_t refs = 0);
// explicit codecvt_byname(const string& nm, size_t refs = 0);
#include <locale>
#include <cassert>
typedef std::codecvt_byname<char, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(const char* nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
explicit my_facet(const std::string& nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet("en_US"));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f("en_US", 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(std::string("en_US"), 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
}

View File

@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt_byname<char16_t, char, mbstate_t>
// explicit codecvt_byname(const char* nm, size_t refs = 0);
// explicit codecvt_byname(const string& nm, size_t refs = 0);
#include <locale>
#include <cassert>
typedef std::codecvt_byname<char16_t, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(const char* nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
explicit my_facet(const std::string& nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet("en_US"));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f("en_US", 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(std::string("en_US"), 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
}

View File

@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt_byname<char32_t, char, mbstate_t>
// explicit codecvt_byname(const char* nm, size_t refs = 0);
// explicit codecvt_byname(const string& nm, size_t refs = 0);
#include <locale>
#include <cassert>
typedef std::codecvt_byname<char32_t, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(const char* nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
explicit my_facet(const std::string& nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet("en_US"));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f("en_US", 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(std::string("en_US"), 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
}

View File

@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt_byname<wchar_t, char, mbstate_t>
// explicit codecvt_byname(const char* nm, size_t refs = 0);
// explicit codecvt_byname(const string& nm, size_t refs = 0);
#include <locale>
#include <cassert>
typedef std::codecvt_byname<wchar_t, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(const char* nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
explicit my_facet(const std::string& nm, std::size_t refs = 0)
: F(nm, refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet("en_US"));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f("en_US", 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
std::locale l(std::locale::classic(), new my_facet(std::string("en_US")));
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(std::string("en_US"), 1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
}

View File

@@ -0,0 +1,27 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// class codecvt_base
// {
// public:
// enum result {ok, partial, error, noconv};
// };
#include <locale>
#include <cassert>
int main()
{
assert(std::codecvt_base::ok == 0);
assert(std::codecvt_base::partial == 1);
assert(std::codecvt_base::error == 2);
assert(std::codecvt_base::noconv == 3);
}

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char, char, mbstate_t>
// explicit codecvt(size_t refs = 0);
#include <locale>
#include <cassert>
typedef std::codecvt<char, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(std::size_t refs = 0)
: F(refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet);
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
}

View File

@@ -0,0 +1,58 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// explicit codecvt(size_t refs = 0);
#include <locale>
#include <cassert>
//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(std::size_t refs = 0)
: F(refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
//#endif
int main()
{
//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
{
std::locale l(std::locale::classic(), new my_facet);
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
//#endif
}

View File

@@ -0,0 +1,58 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// explicit codecvt(size_t refs = 0);
#include <locale>
#include <cassert>
//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(std::size_t refs = 0)
: F(refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
//#endif
int main()
{
//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
{
std::locale l(std::locale::classic(), new my_facet);
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
//#endif
}

View File

@@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<wchar_t, char, mbstate_t>
// explicit codecvt(size_t refs = 0);
#include <locale>
#include <cassert>
typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
class my_facet
: public F
{
public:
static int count;
explicit my_facet(std::size_t refs = 0)
: F(refs) {++count;}
~my_facet() {--count;}
};
int my_facet::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet);
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
{
my_facet f(1);
assert(my_facet::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet::count == 1);
}
assert(my_facet::count == 1);
}
assert(my_facet::count == 0);
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// bool always_noconv() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(!f.always_noconv());
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// int encoding() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(f.encoding() == 0);
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// result in(stateT& state,
// const externT* from, const externT* from_end, const externT*& from_next,
// internT* to, internT* to_end, internT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const char from[] = "some text";
F::intern_type to[9];
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
const char* from_next = 0;
F::intern_type* to_next = 0;
assert(f.in(mbs, from, from + 9, from_next,
to, to + 9, to_next) == F::ok);
assert(from_next - from == 9);
assert(to_next - to == 9);
for (unsigned i = 0; i < 9; ++i)
assert(to[i] == from[i]);
}

View File

@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
#include <locale>
#include <cassert>
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
const char from[] = "some text";
assert(f.length(mbs, from, from+10, 0) == 0);
assert(f.length(mbs, from, from+10, 8) == 8);
assert(f.length(mbs, from, from+10, 9) == 9);
assert(f.length(mbs, from, from+10, 10) == 10);
assert(f.length(mbs, from, from+10, 100) == 10);
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// int max_length() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(f.max_length() == 4);
}

View File

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// result out(stateT& state,
// const internT* from, const internT* from_end, const internT*& from_next,
// externT* to, externT* to_end, externT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
{
F::intern_type from[9] = {'s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't'};
char to[9] = {0};
std::mbstate_t mbs;
const F::intern_type* from_next = 0;
char* to_next = 0;
F::result r = f.out(mbs, from, from + 9, from_next,
to, to + 9, to_next);
assert(r == F::ok);
assert(from_next - from == 9);
assert(to_next - to == 9);
for (unsigned i = 0; i < 9; ++i)
assert(to[i] == from[i]);
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char16_t, char, mbstate_t>
// result unshift(stateT& state,
// externT* to, externT* to_end, externT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
std::vector<char> to(3);
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
char* to_next = 0;
assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv);
assert(to_next == to.data());
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// bool always_noconv() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(!f.always_noconv());
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// int encoding() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(f.encoding() == 0);
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// result in(stateT& state,
// const externT* from, const externT* from_end, const externT*& from_next,
// internT* to, internT* to_end, internT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const char from[] = "some text";
F::intern_type to[9];
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
const char* from_next = 0;
F::intern_type* to_next = 0;
assert(f.in(mbs, from, from + 9, from_next,
to, to + 9, to_next) == F::ok);
assert(from_next - from == 9);
assert(to_next - to == 9);
for (unsigned i = 0; i < 9; ++i)
assert(to[i] == from[i]);
}

View File

@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
#include <locale>
#include <cassert>
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
const char from[] = "some text";
assert(f.length(mbs, from, from+10, 0) == 0);
assert(f.length(mbs, from, from+10, 8) == 8);
assert(f.length(mbs, from, from+10, 9) == 9);
assert(f.length(mbs, from, from+10, 10) == 10);
assert(f.length(mbs, from, from+10, 100) == 10);
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// int max_length() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(f.max_length() == 4);
}

View File

@@ -0,0 +1,45 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// result out(stateT& state,
// const internT* from, const internT* from_end, const internT*& from_next,
// externT* to, externT* to_end, externT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
{
F::intern_type from[9] = {'s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't'};
char to[9] = {0};
std::mbstate_t mbs;
const F::intern_type* from_next = 0;
char* to_next = 0;
F::result r = f.out(mbs, from, from + 9, from_next,
to, to + 9, to_next);
assert(r == F::ok);
assert(from_next - from == 9);
assert(to_next - to == 9);
for (unsigned i = 0; i < 9; ++i)
assert(to[i] == from[i]);
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// result unshift(stateT& state,
// externT* to, externT* to_end, externT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
std::vector<char> to(3);
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
char* to_next = 0;
assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv);
assert(to_next == to.data());
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char, char, mbstate_t>
// bool always_noconv() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(f.always_noconv());
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char, char, mbstate_t>
// int encoding() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(f.encoding() == 1);
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char, char, mbstate_t>
// result in(stateT& state,
// const externT* from, const externT* from_end, const externT*& from_next,
// internT* to, internT* to_end, internT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
typedef std::codecvt<char, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const std::basic_string<F::intern_type> from("some text");
std::vector<char> to(from.size());
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
const char* from_next = 0;
char* to_next = 0;
assert(f.in(mbs, from.data(), from.data() + from.size(), from_next,
to.data(), to.data() + to.size(), to_next) == F::noconv);
assert(from_next == from.data());
assert(to_next == to.data());
}

View File

@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char, char, mbstate_t>
// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
#include <locale>
#include <cassert>
typedef std::codecvt<char, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
const char from[10]= {0};
assert(f.length(mbs, from, from+10, 0) == 0);
assert(f.length(mbs, from, from+10, 9) == 9);
assert(f.length(mbs, from, from+10, 10) == 10);
assert(f.length(mbs, from, from+10, 11) == 10);
assert(f.length(mbs, from, from+10, 100) == 10);
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char, char, mbstate_t>
// int max_length() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<char, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(f.max_length() == 1);
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char, char, mbstate_t>
// result out(stateT& state,
// const internT* from, const internT* from_end, const internT*& from_next,
// externT* to, externT* to_end, externT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
typedef std::codecvt<char, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const std::basic_string<F::intern_type> from("some text");
std::vector<char> to(from.size());
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
const char* from_next = 0;
char* to_next = 0;
assert(f.out(mbs, from.data(), from.data() + from.size(), from_next,
to.data(), to.data() + to.size(), to_next) == F::noconv);
assert(from_next == from.data());
assert(to_next == to.data());
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char, char, mbstate_t>
// result unshift(stateT& state,
// externT* to, externT* to_end, externT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
typedef std::codecvt<char, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
std::vector<char> to(3);
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs;
char* to_next = 0;
assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv);
assert(to_next == to.data());
}

View File

@@ -0,0 +1,117 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<char32_t, char, mbstate_t>
// template <> class codecvt<char16_t, char, mbstate_t>
// template <> class codecvt<char32_t, char16_t, mbstate_t> // extension
// sanity check
#include <locale>
#include <cassert>
#include <stdio.h>
int main()
{
typedef std::codecvt<char32_t, char, std::mbstate_t> F32_8;
typedef std::codecvt<char16_t, char, std::mbstate_t> F16_8;
typedef std::codecvt<char32_t, char16_t, std::mbstate_t> F32_16;
std::locale l = std::locale(std::locale::classic(), new F32_16);
const F32_8& f32_8 = std::use_facet<F32_8>(l);
const F32_16& f32_16 = std::use_facet<F32_16>(l);
const F16_8& f16_8 = std::use_facet<F16_8>(l);
std::mbstate_t mbs = {0};
F32_8::intern_type* c32p;
F16_8::intern_type* c16p;
F32_8::extern_type* c8p;
const F32_8::intern_type* c_c32p;
const F16_8::intern_type* c_c16p;
const F32_8::extern_type* c_c8p;
F32_8::intern_type c32;
F16_8::intern_type c16[2];
F32_8::extern_type c8[4];
for (F32_8::intern_type c32x = 0; c32x < 0x110003; ++c32x)
{
if (0xD800 <= c32x && c32x < 0xE000 || c32x >= 0x110000)
{
assert(f32_16.out(mbs, &c32x, &c32x+1, c_c32p, c16+0, c16+2, c16p) == F32_8::error);
assert(f32_8.out(mbs, &c32x, &c32x+1, c_c32p, c8, c8+4, c8p) == F32_8::error);
}
else
{
assert(f32_16.out(mbs, &c32x, &c32x+1, c_c32p, c16, c16+2, c16p) == F32_8::ok);
assert(c_c32p-&c32x == 1);
if (c32x < 0x10000)
assert(c16p-c16 == 1);
else
assert(c16p-c16 == 2);
c_c16p = c16p;
assert(f16_8.out(mbs, c16, c_c16p, c_c16p, c8, c8+4, c8p) == F32_8::ok);
if (c32x < 0x10000)
assert(c_c16p-c16 == 1);
else
assert(c_c16p-c16 == 2);
if (c32x < 0x80)
assert(c8p-c8 == 1);
else if (c32x < 0x800)
assert(c8p-c8 == 2);
else if (c32x < 0x10000)
assert(c8p-c8 == 3);
else
assert(c8p-c8 == 4);
c_c8p = c8p;
assert(f32_8.in(mbs, c8, c_c8p, c_c8p, &c32, &c32+1, c32p) == F32_8::ok);
if (c32x < 0x80)
assert(c_c8p-c8 == 1);
else if (c32x < 0x800)
assert(c_c8p-c8 == 2);
else if (c32x < 0x10000)
assert(c_c8p-c8 == 3);
else
assert(c_c8p-c8 == 4);
assert(c32p-&c32 == 1);
assert(c32 == c32x);
assert(f32_8.out(mbs, &c32x, &c32x+1, c_c32p, c8, c8+4, c8p) == F32_8::ok);
assert(c_c32p-&c32x == 1);
if (c32x < 0x80)
assert(c8p-c8 == 1);
else if (c32x < 0x800)
assert(c8p-c8 == 2);
else if (c32x < 0x10000)
assert(c8p-c8 == 3);
else
assert(c8p-c8 == 4);
c_c8p = c8p;
assert(f16_8.in(mbs, c8, c_c8p, c_c8p, c16, c16+2, c16p) == F32_8::ok);
if (c32x < 0x80)
assert(c_c8p-c8 == 1);
else if (c32x < 0x800)
assert(c_c8p-c8 == 2);
else if (c32x < 0x10000)
assert(c_c8p-c8 == 3);
else
assert(c_c8p-c8 == 4);
if (c32x < 0x10000)
assert(c16p-c16 == 1);
else
assert(c16p-c16 == 2);
c_c16p = c16p;
assert(f32_16.in(mbs, c16, c_c16p, c_c16p, &c32, &c32+1, c32p) == F32_8::ok);
if (c32x < 0x10000)
assert(c_c16p-c16 == 1);
else
assert(c_c16p-c16 == 2);
assert(c32p-&c32 == 1);
assert(c32 == c32x);
}
}
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<wchar_t, char, mbstate_t>
// bool always_noconv() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(!f.always_noconv());
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<wchar_t, char, mbstate_t>
// int encoding() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(f.encoding() == 1);
}

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<wchar_t, char, mbstate_t>
// result in(stateT& state,
// const externT* from, const externT* from_end, const externT*& from_next,
// internT* to, internT* to_end, internT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const std::basic_string<F::extern_type> from("some text");
const std::basic_string<F::intern_type> expected(from.begin(), from.end());
std::basic_string<F::intern_type> to(from.size(), F::intern_type());
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs = {0};
const F::extern_type* from_next = 0;
F::intern_type* to_next = 0;
F::result r = f.in(mbs, from.data(), from.data() + from.size(), from_next,
&to[0], &to[0] + to.size(), to_next);
assert(r == F::ok);
assert(from_next - from.data() == from.size());
assert(to_next - to.data() == expected.size());
assert(to_next - to.data() == expected.size());
assert(to == expected);
}

View File

@@ -0,0 +1,32 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<wchar_t, char, mbstate_t>
// int length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
#include <locale>
#include <cassert>
typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs = {0};
const char* from = "123467890";
assert(f.length(mbs, from, from+10, 0) == 0);
assert(f.length(mbs, from, from+10, 9) == 9);
assert(f.length(mbs, from, from+10, 10) == 10);
assert(f.length(mbs, from, from+10, 11) == 10);
assert(f.length(mbs, from, from+10, 100) == 10);
}

View File

@@ -0,0 +1,26 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<wchar_t, char, mbstate_t>
// int max_length() const throw();
#include <locale>
#include <cassert>
typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
assert(f.max_length() == 1);
}

View File

@@ -0,0 +1,69 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<wchar_t, char, mbstate_t>
// result out(stateT& state,
// const internT* from, const internT* from_end, const internT*& from_next,
// externT* to, externT* to_end, externT*& to_next) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
const F& f = std::use_facet<F>(l);
{
const std::basic_string<F::intern_type> from(L"some text");
std::vector<char> to(from.size()+1);
std::mbstate_t mbs;
const F::intern_type* from_next = 0;
char* to_next = 0;
F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next,
to.data(), to.data() + to.size(), to_next);
assert(r == F::ok);
assert(from_next - from.data() == from.size());
assert(to_next - to.data() == from.size());
assert(to.data() == std::string("some text"));
}
{
std::basic_string<F::intern_type> from(L"some text");
from[4] = '\0';
std::vector<char> to(from.size()+1);
std::mbstate_t mbs;
const F::intern_type* from_next = 0;
char* to_next = 0;
F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next,
to.data(), to.data() + to.size(), to_next);
assert(r == F::ok);
assert(from_next - from.data() == from.size());
assert(to_next - to.data() == from.size());
assert(to.data() == std::string("some\0text", from.size()));
}
{
std::basic_string<F::intern_type> from(L"some text");
std::vector<char> to(from.size()-1);
std::mbstate_t mbs;
const F::intern_type* from_next = 0;
char* to_next = 0;
F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next,
to.data(), to.data() + to.size()-1, to_next);
assert(r == F::partial);
assert(from_next - from.data() == to.size()-1);
assert(to_next - to.data() == to.size()-1);
assert(to.data() == std::string("some te"));
}
}

View File

@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <> class codecvt<wchar_t, char, mbstate_t>
// result unshift(stateT& state,
// externT* to, externT* to_end, externT*& to_next) const;
// This is pretty much just an "are you breathing" test
#include <locale>
#include <string>
#include <vector>
#include <cassert>
typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
int main()
{
std::locale l = std::locale::classic();
std::vector<F::extern_type> to(3);
const F& f = std::use_facet<F>(l);
std::mbstate_t mbs = {0};
F::extern_type* to_next = 0;
assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::ok);
assert(to_next == to.data());
}

View File

@@ -0,0 +1,12 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main()
{
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <>
// class codecvt<char, char, mbstate_t>
// : public locale::facet,
// public codecvt_base
// {
// public:
// typedef char intern_type;
// typedef char extern_type;
// typedef mbstate_t state_type;
// ...
// };
#include <locale>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::codecvt<char, char, std::mbstate_t> F;
static_assert((std::is_base_of<std::locale::facet, F>::value), "");
static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
static_assert((std::is_same<F::intern_type, char>::value), "");
static_assert((std::is_same<F::extern_type, char>::value), "");
static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
std::locale l = std::locale::classic();
assert(std::has_facet<F>(l));
const F& f = std::use_facet<F>(l);
(void)F::id;
}

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <>
// class codecvt<char16_t, char, mbstate_t>
// : public locale::facet,
// public codecvt_base
// {
// public:
// typedef char16_t intern_type;
// typedef char extern_type;
// typedef mbstate_t state_type;
// ...
// };
#include <locale>
#include <type_traits>
#include <cassert>
int main()
{
//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef std::codecvt<char16_t, char, std::mbstate_t> F;
static_assert((std::is_base_of<std::locale::facet, F>::value), "");
static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
static_assert((std::is_same<F::intern_type, char16_t>::value), "");
static_assert((std::is_same<F::extern_type, char>::value), "");
static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
std::locale l = std::locale::classic();
assert(std::has_facet<F>(l));
const F& f = std::use_facet<F>(l);
(void)F::id;
//#endif
}

View File

@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <>
// class codecvt<char32_t, char, mbstate_t>
// : public locale::facet,
// public codecvt_base
// {
// public:
// typedef char32_t intern_type;
// typedef char extern_type;
// typedef mbstate_t state_type;
// ...
// };
#include <locale>
#include <type_traits>
#include <cassert>
int main()
{
//#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef std::codecvt<char32_t, char, std::mbstate_t> F;
static_assert((std::is_base_of<std::locale::facet, F>::value), "");
static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
static_assert((std::is_same<F::intern_type, char32_t>::value), "");
static_assert((std::is_same<F::extern_type, char>::value), "");
static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
std::locale l = std::locale::classic();
assert(std::has_facet<F>(l));
const F& f = std::use_facet<F>(l);
(void)F::id;
//#endif
}

View File

@@ -0,0 +1,40 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <>
// class codecvt<wchar_t, char, mbstate_t>
// : public locale::facet,
// public codecvt_base
// {
// public:
// typedef wchar_t intern_type;
// typedef char extern_type;
// typedef mbstate_t state_type;
// ...
// };
#include <locale>
#include <type_traits>
#include <cassert>
int main()
{
typedef std::codecvt<wchar_t, char, std::mbstate_t> F;
static_assert((std::is_base_of<std::locale::facet, F>::value), "");
static_assert((std::is_base_of<std::codecvt_base, F>::value), "");
static_assert((std::is_same<F::intern_type, wchar_t>::value), "");
static_assert((std::is_same<F::extern_type, char>::value), "");
static_assert((std::is_same<F::state_type, std::mbstate_t>::value), "");
std::locale l = std::locale::classic();
assert(std::has_facet<F>(l));
const F& f = std::use_facet<F>(l);
(void)F::id;
}

View File

@@ -0,0 +1,108 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype_byname;
// bool is(mask m, charT c) const;
#include <locale>
#include <type_traits>
#include <cassert>
int main()
{
{
std::locale l("en_US");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
assert(f.is(F::space, L' '));
assert(!f.is(F::space, L'A'));
assert(f.is(F::print, L' '));
assert(!f.is(F::print, L'\x07'));
assert(f.is(F::cntrl, L'\x07'));
assert(!f.is(F::cntrl, L' '));
assert(f.is(F::upper, L'A'));
assert(!f.is(F::upper, L'a'));
assert(f.is(F::lower, L'a'));
assert(!f.is(F::lower, L'A'));
assert(f.is(F::alpha, L'a'));
assert(!f.is(F::alpha, L'1'));
assert(f.is(F::digit, L'1'));
assert(!f.is(F::digit, L'a'));
assert(f.is(F::punct, L'.'));
assert(!f.is(F::punct, L'a'));
assert(f.is(F::xdigit, L'a'));
assert(!f.is(F::xdigit, L'g'));
assert(f.is(F::alnum, L'a'));
assert(!f.is(F::alnum, L'.'));
assert(f.is(F::graph, L'.'));
assert(!f.is(F::graph, L'\x07'));
assert(f.is(F::alpha, L'\x00DA'));
assert(f.is(F::upper, L'\x00DA'));
}
}
{
std::locale l("C");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
assert(f.is(F::space, L' '));
assert(!f.is(F::space, L'A'));
assert(f.is(F::print, L' '));
assert(!f.is(F::print, L'\x07'));
assert(f.is(F::cntrl, L'\x07'));
assert(!f.is(F::cntrl, L' '));
assert(f.is(F::upper, L'A'));
assert(!f.is(F::upper, L'a'));
assert(f.is(F::lower, L'a'));
assert(!f.is(F::lower, L'A'));
assert(f.is(F::alpha, L'a'));
assert(!f.is(F::alpha, L'1'));
assert(f.is(F::digit, L'1'));
assert(!f.is(F::digit, L'a'));
assert(f.is(F::punct, L'.'));
assert(!f.is(F::punct, L'a'));
assert(f.is(F::xdigit, L'a'));
assert(!f.is(F::xdigit, L'g'));
assert(f.is(F::alnum, L'a'));
assert(!f.is(F::alnum, L'.'));
assert(f.is(F::graph, L'.'));
assert(!f.is(F::graph, L'\x07'));
assert(!f.is(F::alpha, L'\x00DA'));
assert(!f.is(F::upper, L'\x00DA'));
}
}
}

View File

@@ -0,0 +1,243 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype_byname;
// const charT* do_is(const charT* low, const charT* high, mask* vec) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
int main()
{
{
std::locale l("en_US");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
const std::wstring in(L"\x00DA A\x07.a1");
std::vector<F::mask> m(in.size());
const wchar_t* h = f.is(in.data(), in.data() + in.size(), m.data());
assert(h == in.data() + in.size());
// L'\x00DA'
assert(!(m[0] & F::space));
assert( (m[0] & F::print));
assert(!(m[0] & F::cntrl));
assert( (m[0] & F::upper));
assert(!(m[0] & F::lower));
assert( (m[0] & F::alpha));
assert(!(m[0] & F::digit));
assert(!(m[0] & F::punct));
assert(!(m[0] & F::xdigit));
assert(!(m[0] & F::blank));
assert( (m[0] & F::alnum));
assert( (m[0] & F::graph));
// L' '
assert( (m[1] & F::space));
assert( (m[1] & F::print));
assert(!(m[1] & F::cntrl));
assert(!(m[1] & F::upper));
assert(!(m[1] & F::lower));
assert(!(m[1] & F::alpha));
assert(!(m[1] & F::digit));
assert(!(m[1] & F::punct));
assert(!(m[1] & F::xdigit));
assert( (m[1] & F::blank));
assert(!(m[1] & F::alnum));
assert(!(m[1] & F::graph));
// L'A'
assert(!(m[2] & F::space));
assert( (m[2] & F::print));
assert(!(m[2] & F::cntrl));
assert( (m[2] & F::upper));
assert(!(m[2] & F::lower));
assert( (m[2] & F::alpha));
assert(!(m[2] & F::digit));
assert(!(m[2] & F::punct));
assert( (m[2] & F::xdigit));
assert(!(m[2] & F::blank));
assert( (m[2] & F::alnum));
assert( (m[2] & F::graph));
// L'\x07'
assert(!(m[3] & F::space));
assert(!(m[3] & F::print));
assert( (m[3] & F::cntrl));
assert(!(m[3] & F::upper));
assert(!(m[3] & F::lower));
assert(!(m[3] & F::alpha));
assert(!(m[3] & F::digit));
assert(!(m[3] & F::punct));
assert(!(m[3] & F::xdigit));
assert(!(m[3] & F::blank));
assert(!(m[3] & F::alnum));
assert(!(m[3] & F::graph));
// L'.'
assert(!(m[4] & F::space));
assert( (m[4] & F::print));
assert(!(m[4] & F::cntrl));
assert(!(m[4] & F::upper));
assert(!(m[4] & F::lower));
assert(!(m[4] & F::alpha));
assert(!(m[4] & F::digit));
assert( (m[4] & F::punct));
assert(!(m[4] & F::xdigit));
assert(!(m[4] & F::blank));
assert(!(m[4] & F::alnum));
assert( (m[4] & F::graph));
// L'a'
assert(!(m[5] & F::space));
assert( (m[5] & F::print));
assert(!(m[5] & F::cntrl));
assert(!(m[5] & F::upper));
assert( (m[5] & F::lower));
assert( (m[5] & F::alpha));
assert(!(m[5] & F::digit));
assert(!(m[5] & F::punct));
assert( (m[5] & F::xdigit));
assert(!(m[5] & F::blank));
assert( (m[5] & F::alnum));
assert( (m[5] & F::graph));
// L'1'
assert(!(m[6] & F::space));
assert( (m[6] & F::print));
assert(!(m[6] & F::cntrl));
assert(!(m[6] & F::upper));
assert(!(m[6] & F::lower));
assert(!(m[6] & F::alpha));
assert( (m[6] & F::digit));
assert(!(m[6] & F::punct));
assert( (m[6] & F::xdigit));
assert(!(m[6] & F::blank));
assert( (m[6] & F::alnum));
assert( (m[6] & F::graph));
}
}
{
std::locale l("C");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
const std::wstring in(L"\x00DA A\x07.a1");
std::vector<F::mask> m(in.size());
const wchar_t* h = f.is(in.data(), in.data() + in.size(), m.data());
assert(h == in.data() + in.size());
// L'\x00DA'
assert(!(m[0] & F::space));
assert(!(m[0] & F::print));
assert(!(m[0] & F::cntrl));
assert(!(m[0] & F::upper));
assert(!(m[0] & F::lower));
assert(!(m[0] & F::alpha));
assert(!(m[0] & F::digit));
assert(!(m[0] & F::punct));
assert(!(m[0] & F::xdigit));
assert(!(m[0] & F::blank));
assert(!(m[0] & F::alnum));
assert(!(m[0] & F::graph));
// L' '
assert( (m[1] & F::space));
assert( (m[1] & F::print));
assert(!(m[1] & F::cntrl));
assert(!(m[1] & F::upper));
assert(!(m[1] & F::lower));
assert(!(m[1] & F::alpha));
assert(!(m[1] & F::digit));
assert(!(m[1] & F::punct));
assert(!(m[1] & F::xdigit));
assert( (m[1] & F::blank));
assert(!(m[1] & F::alnum));
assert(!(m[1] & F::graph));
// L'A'
assert(!(m[2] & F::space));
assert( (m[2] & F::print));
assert(!(m[2] & F::cntrl));
assert( (m[2] & F::upper));
assert(!(m[2] & F::lower));
assert( (m[2] & F::alpha));
assert(!(m[2] & F::digit));
assert(!(m[2] & F::punct));
assert( (m[2] & F::xdigit));
assert(!(m[2] & F::blank));
assert( (m[2] & F::alnum));
assert( (m[2] & F::graph));
// L'\x07'
assert(!(m[3] & F::space));
assert(!(m[3] & F::print));
assert( (m[3] & F::cntrl));
assert(!(m[3] & F::upper));
assert(!(m[3] & F::lower));
assert(!(m[3] & F::alpha));
assert(!(m[3] & F::digit));
assert(!(m[3] & F::punct));
assert(!(m[3] & F::xdigit));
assert(!(m[3] & F::blank));
assert(!(m[3] & F::alnum));
assert(!(m[3] & F::graph));
// L'.'
assert(!(m[4] & F::space));
assert( (m[4] & F::print));
assert(!(m[4] & F::cntrl));
assert(!(m[4] & F::upper));
assert(!(m[4] & F::lower));
assert(!(m[4] & F::alpha));
assert(!(m[4] & F::digit));
assert( (m[4] & F::punct));
assert(!(m[4] & F::xdigit));
assert(!(m[4] & F::blank));
assert(!(m[4] & F::alnum));
assert( (m[4] & F::graph));
// L'a'
assert(!(m[5] & F::space));
assert( (m[5] & F::print));
assert(!(m[5] & F::cntrl));
assert(!(m[5] & F::upper));
assert( (m[5] & F::lower));
assert( (m[5] & F::alpha));
assert(!(m[5] & F::digit));
assert(!(m[5] & F::punct));
assert( (m[5] & F::xdigit));
assert(!(m[5] & F::blank));
assert( (m[5] & F::alnum));
assert( (m[5] & F::graph));
// L'1'
assert(!(m[6] & F::space));
assert( (m[6] & F::print));
assert(!(m[6] & F::cntrl));
assert(!(m[6] & F::upper));
assert(!(m[6] & F::lower));
assert(!(m[6] & F::alpha));
assert( (m[6] & F::digit));
assert(!(m[6] & F::punct));
assert( (m[6] & F::xdigit));
assert(!(m[6] & F::blank));
assert( (m[6] & F::alnum));
assert( (m[6] & F::graph));
}
}
}

View File

@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype_byname;
// char narrow(charT c, char dfault) const;
#include <locale>
#include <cassert>
int main()
{
{
std::locale l(std::string("fr_CA.ISO8859-1"));
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
assert(f.narrow(L' ', '*') == ' ');
assert(f.narrow(L'A', '*') == 'A');
assert(f.narrow(L'\x07', '*') == '\x07');
assert(f.narrow(L'.', '*') == '.');
assert(f.narrow(L'a', '*') == 'a');
assert(f.narrow(L'1', '*') == '1');
assert(f.narrow(L'\xDA', '*') == '\xDA');
}
}
{
std::locale l("en_US");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
assert(f.narrow(L' ', '*') == ' ');
assert(f.narrow(L'A', '*') == 'A');
assert(f.narrow(L'\x07', '*') == '\x07');
assert(f.narrow(L'.', '*') == '.');
assert(f.narrow(L'a', '*') == 'a');
assert(f.narrow(L'1', '*') == '1');
assert(f.narrow(L'\xDA', '*') == '*');
}
}
}

View File

@@ -0,0 +1,59 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype_byname;
// const charT* narrow(const charT* low, const charT*, char dfault, char* to) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
int main()
{
{
std::locale l("fr_CA.ISO8859-1");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
std::wstring in(L" A\x07.a1\xDA");
std::vector<char> v(in.size());
assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
assert(v[0] == ' ');
assert(v[1] == 'A');
assert(v[2] == '\x07');
assert(v[3] == '.');
assert(v[4] == 'a');
assert(v[5] == '1');
assert(v[6] == '\xDA');
}
}
{
std::locale l("en_US");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
std::wstring in(L" A\x07.a1\xDA");
std::vector<char> v(in.size());
assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
assert(v[0] == ' ');
assert(v[1] == 'A');
assert(v[2] == '\x07');
assert(v[3] == '.');
assert(v[4] == 'a');
assert(v[5] == '1');
assert(v[6] == '*');
}
}
}

View File

@@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype_byname;
// const charT* scan_is(mask m, const charT* low, const charT* high) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
int main()
{
{
std::locale l("en_US");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
const std::wstring in(L"\x00DA A\x07.a1");
std::vector<F::mask> m(in.size());
assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 3);
assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 5);
assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 6);
assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 4);
assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 2);
assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
}
}
{
std::locale l("C");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
const std::wstring in(L"\x00DA A\x07.a1");
std::vector<F::mask> m(in.size());
assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 3);
assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 2);
assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 5);
assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 2);
assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 6);
assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 4);
assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 2);
assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 2);
assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 2);
}
}
}

View File

@@ -0,0 +1,67 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype_byname;
// const charT* scan_not(mask m, const charT* low, const charT* high) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
int main()
{
{
std::locale l("en_US");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
const std::wstring in(L"\x00DA A\x07.a1");
std::vector<F::mask> m(in.size());
assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 3);
assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 1);
}
}
{
std::locale l("C");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
const std::wstring in(L"\x00DA A\x07.a1");
std::vector<F::mask> m(in.size());
assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
}
}
}

View File

@@ -0,0 +1,85 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype_byname;
// charT tolower(charT) const;
#include <locale>
#include <cassert>
int main()
{
{
std::locale l("en_US");
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
assert(f.tolower(' ') == ' ');
assert(f.tolower('A') == 'a');
assert(f.tolower('\x07') == '\x07');
assert(f.tolower('.') == '.');
assert(f.tolower('a') == 'a');
assert(f.tolower('1') == '1');
assert(f.tolower('\xDA') == '\xDA');
assert(f.tolower('\xFA') == '\xFA');
}
}
{
std::locale l("C");
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
assert(f.tolower(' ') == ' ');
assert(f.tolower('A') == 'a');
assert(f.tolower('\x07') == '\x07');
assert(f.tolower('.') == '.');
assert(f.tolower('a') == 'a');
assert(f.tolower('1') == '1');
assert(f.tolower('\xDA') == '\xDA');
assert(f.tolower('\xFA') == '\xFA');
}
}
{
std::locale l("en_US");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
assert(f.tolower(L' ') == L' ');
assert(f.tolower(L'A') == L'a');
assert(f.tolower(L'\x07') == L'\x07');
assert(f.tolower(L'.') == L'.');
assert(f.tolower(L'a') == L'a');
assert(f.tolower(L'1') == L'1');
assert(f.tolower(L'\xDA') == L'\xFA');
assert(f.tolower(L'\xFA') == L'\xFA');
}
}
{
std::locale l("C");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
assert(f.tolower(L' ') == L' ');
assert(f.tolower(L'A') == L'a');
assert(f.tolower(L'\x07') == L'\x07');
assert(f.tolower(L'.') == L'.');
assert(f.tolower(L'a') == L'a');
assert(f.tolower(L'1') == L'1');
assert(f.tolower(L'\xDA') == L'\xDA');
assert(f.tolower(L'\xFA') == L'\xFA');
}
}
}

View File

@@ -0,0 +1,90 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype_byname;
// const charT* tolower(charT* low, const charT* high) const;
#include <locale>
#include <string>
#include <cassert>
int main()
{
{
std::locale l("en_US");
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
std::string in("\xDA A\x07.a1");
assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
assert(in[0] == '\xDA');
assert(in[1] == ' ');
assert(in[2] == 'a');
assert(in[3] == '\x07');
assert(in[4] == '.');
assert(in[5] == 'a');
assert(in[6] == '1');
}
}
{
std::locale l("C");
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
std::string in("\xDA A\x07.a1");
assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
assert(in[0] == '\xDA');
assert(in[1] == ' ');
assert(in[2] == 'a');
assert(in[3] == '\x07');
assert(in[4] == '.');
assert(in[5] == 'a');
assert(in[6] == '1');
}
}
{
std::locale l("en_US");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
std::wstring in(L"\xDA A\x07.a1");
assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
assert(in[0] == L'\xFA');
assert(in[1] == L' ');
assert(in[2] == L'a');
assert(in[3] == L'\x07');
assert(in[4] == L'.');
assert(in[5] == L'a');
assert(in[6] == L'1');
}
}
{
std::locale l("C");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
std::wstring in(L"\xDA A\x07.a1");
assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
assert(in[0] == L'\xDA');
assert(in[1] == L' ');
assert(in[2] == L'a');
assert(in[3] == L'\x07');
assert(in[4] == L'.');
assert(in[5] == L'a');
assert(in[6] == L'1');
}
}
}

View File

@@ -0,0 +1,85 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype_byname;
// charT toupper(charT) const;
#include <locale>
#include <cassert>
int main()
{
{
std::locale l("en_US");
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
assert(f.toupper(' ') == ' ');
assert(f.toupper('A') == 'A');
assert(f.toupper('\x07') == '\x07');
assert(f.toupper('.') == '.');
assert(f.toupper('a') == 'A');
assert(f.toupper('1') == '1');
assert(f.toupper('\xDA') == '\xDA');
assert(f.toupper('\xFA') == '\xFA');
}
}
{
std::locale l("C");
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
assert(f.toupper(' ') == ' ');
assert(f.toupper('A') == 'A');
assert(f.toupper('\x07') == '\x07');
assert(f.toupper('.') == '.');
assert(f.toupper('a') == 'A');
assert(f.toupper('1') == '1');
assert(f.toupper('\xDA') == '\xDA');
assert(f.toupper('\xFA') == '\xFA');
}
}
{
std::locale l("en_US");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
assert(f.toupper(L' ') == L' ');
assert(f.toupper(L'A') == L'A');
assert(f.toupper(L'\x07') == L'\x07');
assert(f.toupper(L'.') == L'.');
assert(f.toupper(L'a') == L'A');
assert(f.toupper(L'1') == L'1');
assert(f.toupper(L'\xDA') == L'\xDA');
assert(f.toupper(L'\xFA') == L'\xDA');
}
}
{
std::locale l("C");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
assert(f.toupper(L' ') == L' ');
assert(f.toupper(L'A') == L'A');
assert(f.toupper(L'\x07') == L'\x07');
assert(f.toupper(L'.') == L'.');
assert(f.toupper(L'a') == L'A');
assert(f.toupper(L'1') == L'1');
assert(f.toupper(L'\xDA') == L'\xDA');
assert(f.toupper(L'\xFA') == L'\xFA');
}
}
}

View File

@@ -0,0 +1,90 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype_byname;
// const charT* toupper(charT* low, const charT* high) const;
#include <locale>
#include <string>
#include <cassert>
int main()
{
{
std::locale l("en_US");
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
std::string in("\xFA A\x07.a1");
assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
assert(in[0] == '\xFA');
assert(in[1] == ' ');
assert(in[2] == 'A');
assert(in[3] == '\x07');
assert(in[4] == '.');
assert(in[5] == 'A');
assert(in[6] == '1');
}
}
{
std::locale l("C");
{
typedef std::ctype<char> F;
const F& f = std::use_facet<F>(l);
std::string in("\xFA A\x07.a1");
assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
assert(in[0] == '\xFA');
assert(in[1] == ' ');
assert(in[2] == 'A');
assert(in[3] == '\x07');
assert(in[4] == '.');
assert(in[5] == 'A');
assert(in[6] == '1');
}
}
{
std::locale l("en_US");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
std::wstring in(L"\xFA A\x07.a1");
assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
assert(in[0] == L'\xDA');
assert(in[1] == L' ');
assert(in[2] == L'A');
assert(in[3] == L'\x07');
assert(in[4] == L'.');
assert(in[5] == L'A');
assert(in[6] == L'1');
}
}
{
std::locale l("C");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
std::wstring in(L"\xFA A\x07.a1");
assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
assert(in[0] == L'\xFA');
assert(in[1] == L' ');
assert(in[2] == L'A');
assert(in[3] == L'\x07');
assert(in[4] == L'.');
assert(in[5] == L'A');
assert(in[6] == L'1');
}
}
}

View File

@@ -0,0 +1,69 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class CharT>
// class ctype_byname
// : public ctype<CharT>
// {
// public:
// explicit ctype_byname(const char*, size_t = 0);
// explicit ctype_byname(const string&, size_t = 0);
//
// protected:
// ~ctype_byname();
// };
#include <locale>
#include <type_traits>
#include <cassert>
int main()
{
{
std::locale l("en_US");
{
assert(std::has_facet<std::ctype_byname<char> >(l));
assert(&std::use_facet<std::ctype<char> >(l)
== &std::use_facet<std::ctype_byname<char> >(l));
}
{
assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
assert(&std::use_facet<std::ctype<wchar_t> >(l)
== &std::use_facet<std::ctype_byname<wchar_t> >(l));
}
}
{
std::locale l("");
{
assert(std::has_facet<std::ctype_byname<char> >(l));
assert(&std::use_facet<std::ctype<char> >(l)
== &std::use_facet<std::ctype_byname<char> >(l));
}
{
assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
assert(&std::use_facet<std::ctype<wchar_t> >(l)
== &std::use_facet<std::ctype_byname<wchar_t> >(l));
}
}
{
std::locale l("C");
{
assert(std::has_facet<std::ctype_byname<char> >(l));
assert(&std::use_facet<std::ctype<char> >(l)
== &std::use_facet<std::ctype_byname<char> >(l));
}
{
assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
assert(&std::use_facet<std::ctype<wchar_t> >(l)
== &std::use_facet<std::ctype_byname<wchar_t> >(l));
}
}
}

View File

@@ -0,0 +1,54 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype_byname;
// charT widen(char c) const;
// I doubt this test is portable
#include <locale>
#include <cassert>
#include <limits.h>
int main()
{
{
std::locale l("en_US");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
assert(f.widen(' ') == L' ');
assert(f.widen('A') == L'A');
assert(f.widen('\x07') == L'\x07');
assert(f.widen('.') == L'.');
assert(f.widen('a') == L'a');
assert(f.widen('1') == L'1');
assert(f.widen(char(-5)) == wchar_t(-1));
}
}
{
std::locale l("C");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
assert(f.widen(' ') == L' ');
assert(f.widen('A') == L'A');
assert(f.widen('\x07') == L'\x07');
assert(f.widen('.') == L'.');
assert(f.widen('a') == L'a');
assert(f.widen('1') == L'1');
assert(f.widen(char(-5)) == wchar_t(251));
}
}
}

View File

@@ -0,0 +1,61 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype_byname;
// const char* widen(const char* low, const char* high, charT* to) const;
// I doubt this test is portable
#include <locale>
#include <string>
#include <vector>
#include <cassert>
int main()
{
{
std::locale l("en_US");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
std::string in(" A\x07.a1\x85");
std::vector<wchar_t> v(in.size());
assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
assert(v[0] == L' ');
assert(v[1] == L'A');
assert(v[2] == L'\x07');
assert(v[3] == L'.');
assert(v[4] == L'a');
assert(v[5] == L'1');
assert(v[6] == wchar_t(-1));
}
}
{
std::locale l("C");
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
std::string in(" A\x07.a1\x85");
std::vector<wchar_t> v(in.size());
assert(f.widen(&in[0], in.data() + in.size(), v.data()) == in.data() + in.size());
assert(v[0] == L' ');
assert(v[1] == L'A');
assert(v[2] == L'\x07');
assert(v[3] == L'.');
assert(v[4] == L'a');
assert(v[5] == L'1');
assert(v[6] == wchar_t(133));
}
}
}

View File

@@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype;
// explicit ctype(size_t refs = 0);
#include <locale>
#include <cassert>
template <class C>
class my_facet
: public std::ctype<C>
{
public:
static int count;
explicit my_facet(std::size_t refs = 0)
: std::ctype<C>(refs) {++count;}
~my_facet() {--count;}
};
template <class C> int my_facet<C>::count = 0;
int main()
{
{
std::locale l(std::locale::classic(), new my_facet<wchar_t>);
assert(my_facet<wchar_t>::count == 1);
}
assert(my_facet<wchar_t>::count == 0);
{
my_facet<wchar_t> f(1);
assert(my_facet<wchar_t>::count == 1);
{
std::locale l(std::locale::classic(), &f);
assert(my_facet<wchar_t>::count == 1);
}
assert(my_facet<wchar_t>::count == 1);
}
assert(my_facet<wchar_t>::count == 0);
}

View File

@@ -0,0 +1,59 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype;
// bool is(mask m, charT c) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
assert(f.is(F::space, L' '));
assert(!f.is(F::space, L'A'));
assert(f.is(F::print, L' '));
assert(!f.is(F::print, L'\x07'));
assert(f.is(F::cntrl, L'\x07'));
assert(!f.is(F::cntrl, L' '));
assert(f.is(F::upper, L'A'));
assert(!f.is(F::upper, L'a'));
assert(f.is(F::lower, L'a'));
assert(!f.is(F::lower, L'A'));
assert(f.is(F::alpha, L'a'));
assert(!f.is(F::alpha, L'1'));
assert(f.is(F::digit, L'1'));
assert(!f.is(F::digit, L'a'));
assert(f.is(F::punct, L'.'));
assert(!f.is(F::punct, L'a'));
assert(f.is(F::xdigit, L'a'));
assert(!f.is(F::xdigit, L'g'));
assert(f.is(F::alnum, L'a'));
assert(!f.is(F::alnum, L'.'));
assert(f.is(F::graph, L'.'));
assert(!f.is(F::graph, L'\x07'));
}
}

View File

@@ -0,0 +1,118 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype;
// const charT* do_is(const charT* low, const charT* high, mask* vec) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
const std::wstring in(L" A\x07.a1");
std::vector<F::mask> m(in.size());
const wchar_t* h = f.is(in.data(), in.data() + in.size(), m.data());
assert(h == in.data() + in.size());
// L' '
assert( (m[0] & F::space));
assert( (m[0] & F::print));
assert(!(m[0] & F::cntrl));
assert(!(m[0] & F::upper));
assert(!(m[0] & F::lower));
assert(!(m[0] & F::alpha));
assert(!(m[0] & F::digit));
assert(!(m[0] & F::punct));
assert(!(m[0] & F::xdigit));
assert( (m[0] & F::blank));
assert(!(m[0] & F::alnum));
assert(!(m[0] & F::graph));
// L'A'
assert(!(m[1] & F::space));
assert( (m[1] & F::print));
assert(!(m[1] & F::cntrl));
assert( (m[1] & F::upper));
assert(!(m[1] & F::lower));
assert( (m[1] & F::alpha));
assert(!(m[1] & F::digit));
assert(!(m[1] & F::punct));
assert( (m[1] & F::xdigit));
assert(!(m[1] & F::blank));
assert( (m[1] & F::alnum));
assert( (m[1] & F::graph));
// L'\x07'
assert(!(m[2] & F::space));
assert(!(m[2] & F::print));
assert( (m[2] & F::cntrl));
assert(!(m[2] & F::upper));
assert(!(m[2] & F::lower));
assert(!(m[2] & F::alpha));
assert(!(m[2] & F::digit));
assert(!(m[2] & F::punct));
assert(!(m[2] & F::xdigit));
assert(!(m[2] & F::blank));
assert(!(m[2] & F::alnum));
assert(!(m[2] & F::graph));
// L'.'
assert(!(m[3] & F::space));
assert( (m[3] & F::print));
assert(!(m[3] & F::cntrl));
assert(!(m[3] & F::upper));
assert(!(m[3] & F::lower));
assert(!(m[3] & F::alpha));
assert(!(m[3] & F::digit));
assert( (m[3] & F::punct));
assert(!(m[3] & F::xdigit));
assert(!(m[3] & F::blank));
assert(!(m[3] & F::alnum));
assert( (m[3] & F::graph));
// L'a'
assert(!(m[4] & F::space));
assert( (m[4] & F::print));
assert(!(m[4] & F::cntrl));
assert(!(m[4] & F::upper));
assert( (m[4] & F::lower));
assert( (m[4] & F::alpha));
assert(!(m[4] & F::digit));
assert(!(m[4] & F::punct));
assert( (m[4] & F::xdigit));
assert(!(m[4] & F::blank));
assert( (m[4] & F::alnum));
assert( (m[4] & F::graph));
// L'1'
assert(!(m[5] & F::space));
assert( (m[5] & F::print));
assert(!(m[5] & F::cntrl));
assert(!(m[5] & F::upper));
assert(!(m[5] & F::lower));
assert(!(m[5] & F::alpha));
assert( (m[5] & F::digit));
assert(!(m[5] & F::punct));
assert( (m[5] & F::xdigit));
assert(!(m[5] & F::blank));
assert( (m[5] & F::alnum));
assert( (m[5] & F::graph));
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype;
// char narrow(charT c, char dfault) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
assert(f.narrow(L' ', '*') == ' ');
assert(f.narrow(L'A', '*') == 'A');
assert(f.narrow(L'\x07', '*') == '\x07');
assert(f.narrow(L'.', '*') == '.');
assert(f.narrow(L'a', '*') == 'a');
assert(f.narrow(L'1', '*') == '1');
}
}

View File

@@ -0,0 +1,38 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype;
// const charT* narrow(const charT* low, const charT*, char dfault, char* to) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
std::wstring in(L" A\x07.a1");
std::vector<char> v(in.size());
assert(f.narrow(&in[0], in.data() + in.size(), '*', v.data()) == in.data() + in.size());
assert(v[0] == ' ');
assert(v[1] == 'A');
assert(v[2] == '\x07');
assert(v[3] == '.');
assert(v[4] == 'a');
assert(v[5] == '1');
}
}

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype;
// const charT* scan_is(mask m, const charT* low, const charT* high) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
const std::wstring in(L" A\x07.a1");
std::vector<F::mask> m(in.size());
assert(f.scan_is(F::space, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_is(F::print, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_is(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 2);
assert(f.scan_is(F::upper, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::lower, in.data(), in.data() + in.size()) - in.data() == 4);
assert(f.scan_is(F::alpha, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::digit, in.data(), in.data() + in.size()) - in.data() == 5);
assert(f.scan_is(F::punct, in.data(), in.data() + in.size()) - in.data() == 3);
assert(f.scan_is(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::blank, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_is(F::alnum, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_is(F::graph, in.data(), in.data() + in.size()) - in.data() == 1);
}
}

View File

@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype;
// const charT* scan_not(mask m, const charT* low, const charT* high) const;
#include <locale>
#include <string>
#include <vector>
#include <cassert>
#include <stdio.h>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
const std::wstring in(L" A\x07.a1");
std::vector<F::mask> m(in.size());
assert(f.scan_not(F::space, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_not(F::print, in.data(), in.data() + in.size()) - in.data() == 2);
assert(f.scan_not(F::cntrl, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::upper, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::lower, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::alpha, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::digit, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::punct, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::xdigit, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::blank, in.data(), in.data() + in.size()) - in.data() == 1);
assert(f.scan_not(F::alnum, in.data(), in.data() + in.size()) - in.data() == 0);
assert(f.scan_not(F::graph, in.data(), in.data() + in.size()) - in.data() == 0);
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype;
// charT tolower(charT) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
assert(f.tolower(L' ') == L' ');
assert(f.tolower(L'A') == L'a');
assert(f.tolower(L'\x07') == L'\x07');
assert(f.tolower(L'.') == L'.');
assert(f.tolower(L'a') == L'a');
assert(f.tolower(L'1') == L'1');
}
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype;
// const charT* tolower(charT* low, const charT* high) const;
#include <locale>
#include <string>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
std::wstring in(L" A\x07.a1");
assert(f.tolower(&in[0], in.data() + in.size()) == in.data() + in.size());
assert(in[0] == L' ');
assert(in[1] == L'a');
assert(in[2] == L'\x07');
assert(in[3] == L'.');
assert(in[4] == L'a');
assert(in[5] == L'1');
}
}

View File

@@ -0,0 +1,33 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype;
// charT toupper(charT) const;
#include <locale>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
assert(f.toupper(L' ') == L' ');
assert(f.toupper(L'A') == L'A');
assert(f.toupper(L'\x07') == L'\x07');
assert(f.toupper(L'.') == L'.');
assert(f.toupper(L'a') == L'A');
assert(f.toupper(L'1') == L'1');
}
}

View File

@@ -0,0 +1,36 @@
//===----------------------------------------------------------------------===//
//
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <locale>
// template <class charT> class ctype;
// const charT* toupper(charT* low, const charT* high) const;
#include <locale>
#include <string>
#include <cassert>
int main()
{
std::locale l = std::locale::classic();
{
typedef std::ctype<wchar_t> F;
const F& f = std::use_facet<F>(l);
std::wstring in(L" A\x07.a1");
assert(f.toupper(&in[0], in.data() + in.size()) == in.data() + in.size());
assert(in[0] == L' ');
assert(in[1] == L'A');
assert(in[2] == L'\x07');
assert(in[3] == L'.');
assert(in[4] == L'A');
assert(in[5] == L'1');
}
}

Some files were not shown because too many files have changed in this diff Show More