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