• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright (c) 2004
4  * John Maddock
5  *
6  * Use, modification and distribution are subject to the
7  * Boost Software License, Version 1.0. (See accompanying file
8  * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9  *
10  */
11 
12  /*
13   *   LOCATION:    see http://www.boost.org for most recent version.
14   *   FILE         unicode_iterator_test.cpp
15   *   VERSION      see <boost/version.hpp>
16   *   DESCRIPTION: Simple test suite for Unicode interconversions.
17   */
18 
19 #include <boost/regex/pending/unicode_iterator.hpp>
20 #include <boost/detail/lightweight_main.hpp>
21 #include "../test_macros.hpp"
22 #include <vector>
23 #include <iterator>
24 #include <algorithm>
25 #include <iostream>
26 #include <iomanip>
27 #include <cstring>
28 
29 #if !defined(TEST_UTF8) && !defined(TEST_UTF16)
30 #  define TEST_UTF8
31 #  define TEST_UTF16
32 #endif
33 
34 template <class I>
iterate_over(I a,I b)35 typename I::value_type iterate_over(I a, I b)
36 {
37    typedef typename I::value_type value_type;
38    value_type v = 0;
39    while(a != b)
40    {
41       v ^= *a;
42       ++a;
43    }
44    return v;
45 }
46 
spot_checks()47 void spot_checks()
48 {
49    // test specific values ripped straight out of the Unicode standard
50    // to verify that our encoding is the same as theirs, as well as
51    // self-consistent:
52    ::boost::uint32_t spot16[] = { 0x10302u, };
53    typedef boost::u32_to_u16_iterator<const ::boost::uint32_t*> u32to16type;
54 
55    u32to16type it(spot16);
56    BOOST_CHECK_EQUAL(*it++, 0xD800u);
57    BOOST_CHECK_EQUAL(*it++, 0xDF02u);
58    BOOST_CHECK_EQUAL(*--it, 0xDF02u);
59    BOOST_CHECK_EQUAL(*--it, 0xD800u);
60 
61    ::boost::uint32_t spot8[] = { 0x004Du, 0x0430u, 0x4E8Cu, 0x10302u, };
62    typedef boost::u32_to_u8_iterator<const ::boost::uint32_t*> u32to8type;
63 
64    u32to8type it8(spot8);
65    BOOST_CHECK_EQUAL(*it8++, 0x4Du);
66    BOOST_CHECK_EQUAL(*it8++, 0xD0u);
67    BOOST_CHECK_EQUAL(*it8++, 0xB0u);
68    BOOST_CHECK_EQUAL(*it8++, 0xE4u);
69    BOOST_CHECK_EQUAL(*it8++, 0xBAu);
70    BOOST_CHECK_EQUAL(*it8++, 0x8Cu);
71    BOOST_CHECK_EQUAL(*it8++, 0xF0u);
72    BOOST_CHECK_EQUAL(*it8++, 0x90u);
73    BOOST_CHECK_EQUAL(*it8++, 0x8Cu);
74    BOOST_CHECK_EQUAL(*it8++, 0x82u);
75 
76    BOOST_CHECK_EQUAL(*--it8, 0x82u);
77    BOOST_CHECK_EQUAL(*--it8, 0x8Cu);
78    BOOST_CHECK_EQUAL(*--it8, 0x90u);
79    BOOST_CHECK_EQUAL(*--it8, 0xF0u);
80    BOOST_CHECK_EQUAL(*--it8, 0x8Cu);
81    BOOST_CHECK_EQUAL(*--it8, 0xBAu);
82    BOOST_CHECK_EQUAL(*--it8, 0xE4u);
83    BOOST_CHECK_EQUAL(*--it8, 0xB0u);
84    BOOST_CHECK_EQUAL(*--it8, 0xD0u);
85    BOOST_CHECK_EQUAL(*--it8, 0x4Du);
86    //
87    // Test some bad sequences and verify that our iterators will catch them:
88    //
89    boost::uint8_t bad_seq[10] = { 0x4Du, 0xD0u, 0xB0u, 0xE4u, 0xBAu, 0x8Cu, 0xF0u, 0x90u, 0x8Cu, 0x82u };
90    BOOST_CHECK_EQUAL(
91       iterate_over(
92          boost::u8_to_u32_iterator<const boost::uint8_t*>(bad_seq, bad_seq, bad_seq + 10),
93          boost::u8_to_u32_iterator<const boost::uint8_t*>(bad_seq+10, bad_seq, bad_seq + 10)),
94       0x000149f3u);
95    BOOST_CHECK_THROW(boost::u8_to_u32_iterator<const boost::uint8_t*>(bad_seq, bad_seq, bad_seq + 9), std::out_of_range);
96    BOOST_CHECK_THROW(boost::u8_to_u32_iterator<const boost::uint8_t*>(bad_seq, bad_seq, bad_seq + 8), std::out_of_range);
97    BOOST_CHECK_THROW(boost::u8_to_u32_iterator<const boost::uint8_t*>(bad_seq, bad_seq, bad_seq + 7), std::out_of_range);
98    BOOST_CHECK_THROW(boost::u8_to_u32_iterator<const boost::uint8_t*>(bad_seq + 2, bad_seq, bad_seq + 10), std::out_of_range);
99    BOOST_CHECK_THROW(boost::u8_to_u32_iterator<const boost::uint8_t*>(bad_seq + 2, bad_seq + 2, bad_seq + 10), std::out_of_range);
100 
101    boost::uint16_t bad_seq2[6] =  { 0xD800, 0xDF02, 0xD800, 0xDF02, 0xD800, 0xDF02 };
102    BOOST_CHECK_EQUAL(
103       iterate_over(
104          boost::u16_to_u32_iterator<const boost::uint16_t*>(bad_seq2, bad_seq2, bad_seq2 + 6),
105          boost::u16_to_u32_iterator<const boost::uint16_t*>(bad_seq2+6, bad_seq2, bad_seq2 + 6)),
106       66306u);
107    BOOST_CHECK_THROW(boost::u16_to_u32_iterator<const boost::uint16_t*>(bad_seq2, bad_seq2, bad_seq2 + 5), std::out_of_range);
108    BOOST_CHECK_THROW(boost::u16_to_u32_iterator<const boost::uint16_t*>(bad_seq2 + 1, bad_seq2 + 1, bad_seq2 + 6), std::out_of_range);
109    BOOST_CHECK_THROW(boost::u16_to_u32_iterator<const boost::uint16_t*>(bad_seq2 + 1, bad_seq2, bad_seq2 + 6), std::out_of_range);
110 
111    boost::uint8_t bad_seq3[5] = { '.', '*', 0xe4, '.', '*' };
112    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const boost::uint8_t*>(bad_seq3, bad_seq3, bad_seq3 + 5), boost::u8_to_u32_iterator<const boost::uint8_t*>(bad_seq3 + 5, bad_seq3, bad_seq3 + 5)), std::out_of_range);
113    boost::uint8_t bad_seq4[5] = { '.', '*', 0xf6, '.', '*' };
114    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const boost::uint8_t*>(bad_seq4, bad_seq4, bad_seq4 + 5), boost::u8_to_u32_iterator<const boost::uint8_t*>(bad_seq4 + 5, bad_seq4, bad_seq4 + 5)), std::out_of_range);
115 
116    // Invalid sequences containing surrogate pairs:
117    const char* invalid_pseq = "\xed\xa0\x80"; // single lowest lead surrogate U+D800
118    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
119    invalid_pseq = "\xed\xb0\x80"; // single lowest trail surrogate U+DC00
120    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
121    invalid_pseq = "\xed\xb0\x80"; // single lowest trail surrogate U+DC00
122    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
123    invalid_pseq = "\xed\xbf\xbf"; // single highest trail surrogate U+DFFF
124    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
125 
126    // overlong encodings (created by left-padding with zero bits)
127    invalid_pseq = "\xc0\x80"; // illegal 2-byte encoding of 1-byte character U+0000
128    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
129    invalid_pseq = "\xe0\x80\x80"; // illegal 3-byte encoding of 1-byte character U+0000
130    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
131    invalid_pseq = "\xf0\x80\x80\x80"; // illegal 4-byte encoding of 1-byte character U+0000
132    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
133 
134    invalid_pseq = "\xc1\xbf"; // illegal 2-byte encoding of 1-byte character U+007F
135    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
136    invalid_pseq = "\xe0\x81\xbf"; // illegal 3-byte encoding of 1-byte character U+007F
137    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
138    invalid_pseq = "\xf0\x80\x81\xbf"; // illegal 4-byte encoding of 1-byte character U+007F
139    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
140 
141    invalid_pseq = "\xe0\x82\x80"; // illegal 3-byte encoding of 2-byte character U+0080
142    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
143    invalid_pseq = "\xf0\x80\x82\x80"; // illegal 4-byte encoding of 2-byte character U+0080
144    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
145 
146    invalid_pseq = "\xe0\x9f\xbf"; // illegal 3-byte encoding of 2-byte character U+07FF
147    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
148    invalid_pseq = "\xf0\x80\x9f\xbf"; // illegal 4-byte encoding of 2-byte character U+07FF
149    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
150 
151    invalid_pseq = "\xf0\x80\xa0\x80"; // illegal 4-byte encoding of 3-byte character U+0800
152    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
153    invalid_pseq = "\xf0\x8f\xbf\xbf"; // illegal 4-byte encoding of 3-byte character U+FFFF
154    BOOST_CHECK_THROW(iterate_over(boost::u8_to_u32_iterator<const char*>(invalid_pseq, invalid_pseq, invalid_pseq + std::strlen(invalid_pseq)), boost::u8_to_u32_iterator<const char*>(invalid_pseq + std::strlen(invalid_pseq), invalid_pseq, invalid_pseq + std::strlen(invalid_pseq))), std::out_of_range);
155 }
156 
test(const std::vector<::boost::uint32_t> & v)157 void test(const std::vector< ::boost::uint32_t>& v)
158 {
159    typedef std::vector< ::boost::uint32_t> vector32_type;
160 #ifdef TEST_UTF16
161    typedef std::vector< ::boost::uint16_t> vector16_type;
162 #endif
163    typedef std::vector< ::boost::uint8_t>  vector8_type;
164 #ifdef TEST_UTF16
165    typedef boost::u32_to_u16_iterator<vector32_type::const_iterator, ::boost::uint16_t> u32to16type;
166    typedef boost::u16_to_u32_iterator<vector16_type::const_iterator, ::boost::uint32_t> u16to32type;
167 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_STD_ITERATOR) && !defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
168    typedef std::reverse_iterator<u32to16type> ru32to16type;
169    typedef std::reverse_iterator<u16to32type> ru16to32type;
170 #endif
171 #endif // TEST_UTF16
172 #ifdef TEST_UTF8
173    typedef boost::u32_to_u8_iterator<vector32_type::const_iterator, ::boost::uint8_t> u32to8type;
174    typedef boost::u8_to_u32_iterator<vector8_type::const_iterator, ::boost::uint32_t> u8to32type;
175 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_STD_ITERATOR) && !defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
176    typedef std::reverse_iterator<u32to8type> ru32to8type;
177    typedef std::reverse_iterator<u8to32type> ru8to32type;
178 #endif
179 #endif // TEST_UTF8
180    vector8_type  v8;
181 #ifdef TEST_UTF16
182    vector16_type v16;
183 #endif
184    vector32_type v32;
185    vector32_type::const_iterator i, j, k;
186 
187 #ifdef TEST_UTF16
188    //
189    // begin by testing forward iteration, of 32-16 bit interconversions:
190    //
191 #if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
192    v16.assign(u32to16type(v.begin()), u32to16type(v.end()));
193 #else
194    v16.clear();
195    std::copy(u32to16type(v.begin()), u32to16type(v.end()), std::back_inserter(v16));
196 #endif
197 #ifndef BOOST_NO_STD_DISTANCE
198    BOOST_CHECK_EQUAL((std::size_t)std::distance(u32to16type(v.begin()), u32to16type(v.end())), v16.size());
199 #endif
200 #if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
201    v32.assign(u16to32type(v16.begin(), v16.begin(), v16.end()), u16to32type(v16.end(), v16.begin(), v16.end()));
202 #else
203    v32.clear();
204    std::copy(u16to32type(v16.begin(), v16.begin(), v16.end()), u16to32type(v16.end(), v16.begin(), v16.end()), std::back_inserter(v32));
205 #endif
206 #ifndef BOOST_NO_STD_DISTANCE
207    BOOST_CHECK_EQUAL((std::size_t)std::distance(u16to32type(v16.begin(), v16.begin(), v16.end()), u16to32type(v16.end(), v16.begin(), v16.end())), v32.size());
208 #endif
209    BOOST_CHECK_EQUAL(v.size(), v32.size());
210    i = v.begin();
211    j = i;
212    std::advance(j, (std::min)(v.size(), v32.size()));
213    k = v32.begin();
214    BOOST_CHECK_EQUAL_COLLECTIONS(v.begin(), v.end(), v32.begin(), v32.end());
215    //
216    // test backward iteration, of 32-16 bit interconversions:
217    //
218 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_STD_ITERATOR) && !defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
219    v16.assign(ru32to16type(u32to16type(v.end())), ru32to16type(u32to16type(v.begin())));
220 #ifndef BOOST_NO_STD_DISTANCE
221    BOOST_CHECK_EQUAL((std::size_t)std::distance(ru32to16type(u32to16type(v.end())), ru32to16type(u32to16type(v.begin()))), v16.size());
222 #endif
223    std::reverse(v16.begin(), v16.end());
224    v32.assign(ru16to32type(u16to32type(v16.end(), v16.begin(), v16.end())), ru16to32type(u16to32type(v16.begin(), v16.begin(), v16.end())));
225 #ifndef BOOST_NO_STD_DISTANCE
226    BOOST_CHECK_EQUAL((std::size_t)std::distance(ru16to32type(u16to32type(v16.end(), v16.begin(), v16.end())), ru16to32type(u16to32type(v16.begin(), v16.begin(), v16.end()))), v32.size());
227 #endif
228    BOOST_CHECK_EQUAL(v.size(), v32.size());
229    std::reverse(v32.begin(), v32.end());
230    i = v.begin();
231    j = i;
232    std::advance(j, (std::min)(v.size(), v32.size()));
233    k = v32.begin();
234    BOOST_CHECK_EQUAL_COLLECTIONS(v.begin(), v.end(), v32.begin(), v32.end());
235 #endif
236 #endif // TEST_UTF16
237 
238 #ifdef TEST_UTF8
239    //
240    // Test forward iteration, of 32-8 bit interconversions:
241    //
242 #if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
243    v8.assign(u32to8type(v.begin()), u32to8type(v.end()));
244 #else
245    v8.clear();
246    std::copy(u32to8type(v.begin()), u32to8type(v.end()), std::back_inserter(v8));
247 #endif
248 #ifndef BOOST_NO_STD_DISTANCE
249    BOOST_CHECK_EQUAL((std::size_t)std::distance(u32to8type(v.begin()), u32to8type(v.end())), v8.size());
250 #endif
251 #if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)
252    v32.assign(u8to32type(v8.begin(), v8.begin(), v8.end()), u8to32type(v8.end(), v8.begin(), v8.end()));
253 #else
254    v32.clear();
255    std::copy(u8to32type(v8.begin(), v8.begin(), v8.end()), u8to32type(v8.end(), v8.begin(), v8.end()), std::back_inserter(v32));
256 #endif
257 #ifndef BOOST_NO_STD_DISTANCE
258    BOOST_CHECK_EQUAL((std::size_t)std::distance(u8to32type(v8.begin(), v8.begin(), v8.end()), u8to32type(v8.end(), v8.begin(), v8.end())), v32.size());
259 #endif
260    BOOST_CHECK_EQUAL(v.size(), v32.size());
261    i = v.begin();
262    j = i;
263    std::advance(j, (std::min)(v.size(), v32.size()));
264    k = v32.begin();
265    BOOST_CHECK_EQUAL_COLLECTIONS(v.begin(), v.end(), v32.begin(), v32.end());
266    //
267    // test backward iteration, of 32-8 bit interconversions:
268    //
269 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_NO_STD_ITERATOR) && !defined(_RWSTD_NO_CLASS_PARTIAL_SPEC)
270    v8.assign(ru32to8type(u32to8type(v.end())), ru32to8type(u32to8type(v.begin())));
271 #ifndef BOOST_NO_STD_DISTANCE
272    BOOST_CHECK_EQUAL((std::size_t)std::distance(ru32to8type(u32to8type(v.end())), ru32to8type(u32to8type(v.begin()))), v8.size());
273 #endif
274    std::reverse(v8.begin(), v8.end());
275    v32.assign(ru8to32type(u8to32type(v8.end(), v8.begin(), v8.end())), ru8to32type(u8to32type(v8.begin(), v8.begin(), v8.end())));
276 #ifndef BOOST_NO_STD_DISTANCE
277    BOOST_CHECK_EQUAL((std::size_t)std::distance(ru8to32type(u8to32type(v8.end(), v8.begin(), v8.end())), ru8to32type(u8to32type(v8.begin(), v8.begin(), v8.end()))), v32.size());
278 #endif
279    BOOST_CHECK_EQUAL(v.size(), v32.size());
280    std::reverse(v32.begin(), v32.end());
281    i = v.begin();
282    j = i;
283    std::advance(j, (std::min)(v.size(), v32.size()));
284    k = v32.begin();
285    BOOST_CHECK_EQUAL_COLLECTIONS(v.begin(), v.end(), v32.begin(), v32.end());
286 #endif
287 #endif // TEST_UTF8
288    //
289    // Test checked construction of UTF-8/16 iterators at each location in the sequences:
290    //
291 #ifdef TEST_UTF8
292    for(u8to32type v8p(v8.begin(), v8.begin(), v8.end()), v8e(v8.end(), v8.begin(), v8.end()); v8p != v8e; ++v8p)
293    {
294       u8to32type pos(v8p.base(), v8p.base(), v8.end());
295       BOOST_CHECK(pos == v8p);
296       BOOST_CHECK(*pos == *v8p);
297    }
298 #endif
299 #ifdef TEST_UTF16
300    for(u16to32type v16p(v16.begin(), v16.begin(), v16.end()), v16e(v16.end(), v16.begin(), v16.end()); v16p != v16e; ++v16p)
301    {
302       u16to32type pos(v16p.base(), v16p.base(), v16.end());
303       BOOST_CHECK(pos == v16p);
304       BOOST_CHECK(*pos == *v16p);
305    }
306 #endif
307 }
308 
cpp_main(int,char * [])309 int cpp_main( int, char* [] )
310 {
311    // test specific value points from the standard:
312    spot_checks();
313    // now test a bunch of values for self-consistency and round-tripping:
314    std::vector< ::boost::uint32_t> v;
315    for(unsigned i = 0; i < 0xD800; ++i)
316       v.push_back(i);
317    for(unsigned i = 0xDFFF + 1; i < 0x10FFFF; ++i)
318       v.push_back(i);
319    test(v);
320    return 0;
321 }
322 
323