]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/re/re.traits/transform_primary.pass.cpp
Vendor import of libc++ trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / test / std / re / re.traits / transform_primary.pass.cpp
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 //                     The LLVM Compiler Infrastructure
5 //
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10 //
11 // NetBSD does not support LC_COLLATE at the moment
12 // XFAIL: netbsd
13
14 // REQUIRES: locale.cs_CZ.ISO8859-2
15
16 // <regex>
17
18 // template <class charT> struct regex_traits;
19
20 // template <class ForwardIterator>
21 //   string_type
22 //   transform_primary(ForwardIterator first, ForwardIterator last) const;
23
24 #include <regex>
25 #include <cassert>
26
27 #include "test_macros.h"
28 #include "test_iterators.h"
29 #include "platform_support.h" // locale name macros
30
31 int main()
32 {
33     {
34         std::regex_traits<char> t;
35         const char A[] = "A";
36         const char Aacute[] = "\xC1";
37         typedef forward_iterator<const char*> F;
38         assert(t.transform_primary(F(A), F(A+1)) !=
39                t.transform_primary(F(Aacute), F(Aacute+1)));
40         t.imbue(std::locale(LOCALE_cs_CZ_ISO8859_2));
41         assert(t.transform_primary(F(A), F(A+1)) ==
42                t.transform_primary(F(Aacute), F(Aacute+1)));
43     }
44     {
45         std::regex_traits<wchar_t> t;
46         const wchar_t A[] = L"A";
47         const wchar_t Aacute[] = L"\xC1";
48         typedef forward_iterator<const wchar_t*> F;
49         assert(t.transform_primary(F(A), F(A+1)) !=
50                t.transform_primary(F(Aacute), F(Aacute+1)));
51         t.imbue(std::locale(LOCALE_cs_CZ_ISO8859_2));
52         assert(t.transform_primary(F(A), F(A+1)) ==
53                t.transform_primary(F(Aacute), F(Aacute+1)));
54     }
55 }