| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| #include <boost/regex/config.hpp> |
| #include <boost/detail/lightweight_main.hpp> |
| #include "../test_macros.hpp" |
|
|
| #if defined(BOOST_HAS_ICU) |
|
|
| #include <boost/regex/icu.hpp> |
|
|
| #include <utility> |
|
|
| #include <unicode/uversion.h> |
| #include <unicode/uchar.h> |
|
|
| typedef std::pair<int, int> unicode_verinfo; |
|
|
| |
| |
| |
| unicode_verinfo get_unicode_version() |
| { |
| UVersionInfo versionArray = {}; |
| u_getUnicodeVersion(versionArray); |
| unicode_verinfo result(versionArray[0] , versionArray[1]); |
| return result; |
| } |
|
|
| void latin_1_checks() |
| { |
| typedef boost::icu_regex_traits traits_type; |
| traits_type traits; |
|
|
| |
| for (traits_type::char_type c = 0x0; c < 0x41; ++c) |
| { |
| traits_type::char_type nc = traits.translate_nocase(c); |
| BOOST_CHECK_EQUAL(nc, c); |
| } |
|
|
| |
| |
| for (traits_type::char_type c = 0x41; c <= 0x5A; ++c) |
| { |
| traits_type::char_type nc = traits.translate_nocase(c); |
| const int shift = 0x61 - 0x41; |
| BOOST_CHECK_EQUAL(nc, c + shift); |
| BOOST_CHECK_EQUAL(nc, traits.tolower(c)); |
| } |
|
|
| |
| for (traits_type::char_type c = 0x5A + 1; c < 0xB5; ++c) |
| { |
| traits_type::char_type nc = traits.translate_nocase(c); |
| BOOST_CHECK_EQUAL(nc, c); |
| } |
|
|
| |
| |
| { |
| traits_type::char_type c = 0xB5; |
| traits_type::char_type nc = traits.translate_nocase(c); |
| BOOST_CHECK_EQUAL(nc, 0x03BC); |
| } |
|
|
| |
| for (traits_type::char_type c = 0xB5 + 1; c <= 0xBF; ++c) |
| { |
| traits_type::char_type nc = traits.translate_nocase(c); |
| BOOST_CHECK_EQUAL(nc, c); |
| } |
|
|
| |
| |
| for (traits_type::char_type c = 0xC0; c <= 0xD6; ++c) |
| { |
| traits_type::char_type nc = traits.translate_nocase(c); |
| traits_type::char_type lc = traits.tolower(c); |
| BOOST_CHECK_EQUAL(nc, lc); |
| BOOST_CHECK_NE(nc, c); |
| } |
|
|
| |
| { |
| traits_type::char_type c = 0xD7; |
| traits_type::char_type nc = traits.translate_nocase(c); |
| BOOST_CHECK_EQUAL(nc, c); |
| } |
|
|
| |
| |
| for (traits_type::char_type c = 0xD8; c <= 0xDE; ++c) |
| { |
| traits_type::char_type nc = traits.translate_nocase(c); |
| traits_type::char_type lc = traits.tolower(c); |
| BOOST_CHECK_EQUAL(nc, lc); |
| BOOST_CHECK_NE(nc, c); |
| } |
|
|
| |
| |
| |
| |
| |
| for (traits_type::char_type c = 0xDF; c <= 0xFF; ++c) |
| { |
| traits_type::char_type nc = traits.translate_nocase(c); |
| BOOST_CHECK_EQUAL(nc, c); |
| } |
| } |
|
|
| void spot_checks() |
| { |
| |
| |
| typedef boost::icu_regex_traits traits_type; |
| traits_type traits; |
|
|
| const unicode_verinfo unicode_version = get_unicode_version(); |
|
|
| |
| |
| if (unicode_version >= unicode_verinfo(5, 1)) |
| { |
| traits_type::char_type c = 0x1E9E; |
| traits_type::char_type nc = traits.translate_nocase(c); |
| traits_type::char_type lc = traits.tolower(c); |
| BOOST_CHECK_EQUAL(nc, lc); |
| BOOST_CHECK_EQUAL(nc, 0xDF); |
| } |
|
|
| |
| |
| |
| { |
| traits_type::char_type c = 0x03A3; |
| traits_type::char_type nc = traits.translate_nocase(c); |
| traits_type::char_type lc = traits.tolower(c); |
| BOOST_CHECK_EQUAL(nc, lc); |
| BOOST_CHECK_EQUAL(nc, 0x03C3); |
| c = 0x03C2; |
| nc = traits.translate_nocase(c); |
| BOOST_CHECK_EQUAL(nc, 0x03C3); |
| c = 0x03C3; |
| nc = traits.translate_nocase(c); |
| BOOST_CHECK_EQUAL(nc, c); |
| } |
|
|
| |
| |
| |
| |
| |
| { |
| traits_type::char_type c = 0x0130; |
| traits_type::char_type nc = traits.translate_nocase(c); |
| BOOST_CHECK_EQUAL(nc, c); |
| c = 0x0049; |
| nc = traits.translate_nocase(c); |
| traits_type::char_type lc = traits.tolower(c); |
| BOOST_CHECK_EQUAL(nc, lc); |
| BOOST_CHECK_EQUAL(nc, 0x0069); |
| } |
|
|
| |
| |
| |
| if (unicode_version >= unicode_verinfo(8, 0)) |
| { |
| traits_type::char_type c = 0x13F8; |
| traits_type::char_type nc = traits.translate_nocase(c); |
| traits_type::char_type uc = traits.toupper(c); |
| BOOST_CHECK_EQUAL(nc, uc); |
| BOOST_CHECK_EQUAL(nc, 0x13F0); |
| } |
|
|
| } |
|
|
| #endif |
|
|
| int cpp_main( int, char* [] ) |
| { |
| #if defined(BOOST_HAS_ICU) |
| latin_1_checks(); |
| spot_checks(); |
| #endif |
| return boost::report_errors(); |
| } |
|
|