]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/basic_ios/cons/char/3.cc
1 // 2001-06-05 Benjamin Kosnik <bkoz@redhat.com>
3 // Copyright (C) 2001-2016 Free Software Foundation, Inc.
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
8 // Free Software Foundation; either version 3, or (at your option)
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.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
21 // 27.4.2.1.6 class ios_base::init
26 #include <testsuite_hooks.h>
28 // char_traits specialization
32 struct char_traits
<unsigned short>
34 typedef unsigned short char_type
;
35 // Unsigned as wint_t in unsigned.
36 typedef unsigned long int_type
;
37 typedef streampos pos_type
;
38 typedef streamoff off_type
;
39 typedef mbstate_t state_type
;
42 assign(char_type
& __c1
, const char_type
& __c2
)
46 eq(const char_type
& __c1
, const char_type
& __c2
)
47 { return __c1
== __c2
; }
50 lt(const char_type
& __c1
, const char_type
& __c2
)
51 { return __c1
< __c2
; }
54 compare(const char_type
* __s1
, const char_type
* __s2
, size_t __n
)
56 for (size_t __i
= 0; __i
< __n
; ++__i
)
57 if (!eq(__s1
[__i
], __s2
[__i
]))
58 return lt(__s1
[__i
], __s2
[__i
]) ? -1 : 1;
63 length(const char_type
* __s
)
65 const char_type
* __p
= __s
;
71 static const char_type
*
72 find(const char_type
* __s
, size_t __n
, const char_type
& __a
)
74 for (const char_type
* __p
= __s
; size_t(__p
- __s
) < __n
; ++__p
)
75 if (*__p
== __a
) return __p
;
80 move(char_type
* __s1
, const char_type
* __s2
, size_t __n
)
81 { return (char_type
*) memmove(__s1
, __s2
, __n
* sizeof(char_type
)); }
84 copy(char_type
* __s1
, const char_type
* __s2
, size_t __n
)
85 { return (char_type
*) memcpy(__s1
, __s2
, __n
* sizeof(char_type
)); }
88 assign(char_type
* __s
, size_t __n
, char_type __a
)
90 for (char_type
* __p
= __s
; __p
< __s
+ __n
; ++__p
)
96 to_char_type(const int_type
&)
97 { return char_type(); }
100 to_int_type(const char_type
&) { return int_type(); }
103 eq_int_type(const int_type
& __c1
, const int_type
& __c2
)
104 { return __c1
== __c2
; }
107 eof() { return static_cast<int_type
>(-1); }
110 not_eof(const int_type
& __c
)
111 { return eq_int_type(__c
, eof()) ? int_type(0) : __c
; }
115 // Non-required instantiations don't have the required facets inbued,
116 // by default, into the locale object.
121 bool test
__attribute__((unused
)) = true;
123 // 02: Calls basic_ios::init, which may call ctype<char_type>...
126 std::basic_string
<unsigned short> str
;
127 std::basic_ostringstream
<unsigned short> oss(str
);
129 // Try each member functions for unformatted io.
134 const unsigned short us
[4] = {1246, 433, 520, 0};
140 catch(const std::bad_cast
& obj
)
142 // Should be able to do the above without calling fill() and
143 // forcing a call to widen...
154 // Explicitly instantiate for systems with no COMDAT or weak support.
156 const std::basic_string
<unsigned short>::size_type
157 std::basic_string
<unsigned short>::_Rep::_S_max_size
;
161 std::basic_string
<unsigned short>::_Rep::_S_terminal
;