]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/ext/pod_char_traits.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / ext / pod_char_traits.cc
CommitLineData
9e7facfd
BK
1// POD character, std::char_traits specialization -*- C++ -*-
2
83ffe9cd 3// Copyright (C) 2002-2023 Free Software Foundation, Inc.
9e7facfd
BK
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
748086b7 8// Free Software Foundation; either version 3, or (at your option)
9e7facfd
BK
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License along
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
19
9e7facfd
BK
20
21// Gabriel Dos Reis <gdr@integrable-solutions.net>
22// Benjamin Kosnik <bkoz@redhat.com>
23
24#include <ext/pod_char_traits.h>
13feb023 25#include <testsuite_hooks.h>
9e7facfd
BK
26
27int main()
28{
9e7facfd
BK
29 using namespace __gnu_cxx;
30
31 typedef unsigned short value_type;
32 typedef unsigned int int_type;
33 typedef character<value_type, int_type> char_type;
36606f39 34 typedef std::char_traits<char_type> traits_type;
9e7facfd 35
1558d39e 36 bool test = true;
9e7facfd
BK
37
38 // 1 char_type <-> value_type conversions
39 value_type uc1 = 'c';
40 value_type uc2 = 'd';
41 char_type c1 = { uc1 };
42 char_type c2 = { uc2 };
43 test = !(c1 == c2);
13feb023 44 VERIFY( test );
9e7facfd
BK
45
46 // 2 char_traits
47 test = traits_type::eq(c1, c2);
13feb023
JW
48 VERIFY( ! test );
49
9e7facfd 50 // 3 basic_string<char_type>
b66ea7d4 51 typedef std::basic_string<char_type> string_type;
9e7facfd
BK
52 string_type str;
53 char_type c3 = { value_type('b') };
54 char_type c4 = { value_type('o') };
55 char_type c5 = { value_type('r') };
56 char_type c6 = { value_type('a') };
57 char_type c7 = { value_type('c') };
58 char_type c8 = { value_type('a') };
59 char_type c9 = { value_type('y') };
60 str += c3;
61 str += c4;
62 str += c5;
63 str += c6;
64 str += c7;
65 str += c8;
66 str += c9;
11f10e6b
BK
67 string_type::size_type len __attribute__((unused)) = str.size();
68 const char_type* arr __attribute__((unused)) = str.c_str();
9e7facfd
BK
69
70 return 0;
71}