Commit 10cbfb51 by Ulrich Weigand Committed by Paolo Carlini

2002-03-27 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>

            Paolo Carlini  <pcarlini@unitus.it>

        * testsuite/22_locale/codecvt_members_unicode_wchar_t.cc
        (test01): Protect the test with _GLIBCPP_USE_WCHAR_T;
        fix i_lit_base e_lit_base arrays, making them independent
	from the endianness of the platform; tweak UCS4 to UCS-4BE.

Co-Authored-By: Paolo Carlini <pcarlini@unitus.it>

From-SVN: r51521
parent b8de5050
2002-03-27 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
Paolo Carlini <pcarlini@unitus.it>
* testsuite/22_locale/codecvt_members_unicode_wchar_t.cc
(test01): Protect the test with _GLIBCPP_USE_WCHAR_T;
fix i_lit_base e_lit_base arrays, making them independent
from the endianness of the platform; tweak UCS4 to UCS-4BE.
2002-03-27 Benjamin Kosnik <bkoz@redhat.com> 2002-03-27 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/ostream.tcc (ostream::operator<<(_CharT)): Always * include/bits/ostream.tcc (ostream::operator<<(_CharT)): Always
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
using namespace std; using namespace std;
#ifdef _GLIBCPP_USE___ENC_TRAITS #ifdef _GLIBCPP_USE___ENC_TRAITS
#ifdef _GLIBCPP_USE_WCHAR_T
void void
initialize_state(__enc_traits& state) initialize_state(__enc_traits& state)
...@@ -46,21 +47,27 @@ void test01() ...@@ -46,21 +47,27 @@ void test01()
bool test = true; bool test = true;
int size = 23; int size = 23;
ext_type e_lit_base[24] = char e_lit_base[96] __attribute__((aligned(__alignof__(ext_type)))) =
{ 1644167168, 1811939328, 1627389952, 1660944384, 1795162112, 536870912, {
1879048192, 1694498816, 1627389952, 1912602624, 1811939328, 536870912, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x61,
1778384896, 1627389952, 1929379840, 1828716544, 1761607680, 1845493760, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x20,
1694498816, 536870912, 1946157056, 1694498816, 1627389952, 167772160 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x61,
0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x20,
0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x73,
0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x6e,
0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x74,
0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0xa0
}; };
const ext_type* e_lit = e_lit_base; const ext_type* e_lit = reinterpret_cast<ext_type*>(e_lit_base);
int_type i_lit_base[24] = char i_lit_base[48] __attribute__((aligned(__alignof__(int_type)))) =
{ {
0x6200, 0x6c00, 0x6100, 0x6300, 0x6b00, 0x2000, 0x7000, 0x6500, 0x6100, 0x00, 0x62, 0x00, 0x6c, 0x00, 0x61, 0x00, 0x63, 0x00, 0x6b, 0x00, 0x20,
0x7200, 0x6c00, 0x2000, 0x6a00, 0x6100, 0x7300, 0x6d00, 0x6900, 0x6e00, 0x00, 0x70, 0x00, 0x65, 0x00, 0x61, 0x00, 0x72, 0x00, 0x6c, 0x00, 0x20,
0x6500, 0x2000, 0x7400, 0x6500, 0x6100, 0xa000 0x00, 0x6a, 0x00, 0x61, 0x00, 0x73, 0x00, 0x6d, 0x00, 0x69, 0x00, 0x6e,
0x00, 0x65, 0x00, 0x20, 0x00, 0x74, 0x00, 0x65, 0x00, 0x61, 0x00, 0xa0
}; };
const int_type* i_lit = i_lit_base; const int_type* i_lit = reinterpret_cast<int_type*>(i_lit_base);
const ext_type* efrom_next; const ext_type* efrom_next;
const int_type* ifrom_next; const int_type* ifrom_next;
...@@ -76,7 +83,7 @@ void test01() ...@@ -76,7 +83,7 @@ void test01()
const unicode_codecvt& cvt = use_facet<unicode_codecvt>(loc); const unicode_codecvt& cvt = use_facet<unicode_codecvt>(loc);
// in // in
unicode_codecvt::state_type state01("UCS-2BE", "UCS4", 0xfeff, 0); unicode_codecvt::state_type state01("UCS-2BE", "UCS-4BE", 0xfeff, 0);
initialize_state(state01); initialize_state(state01);
result r1 = cvt.in(state01, e_lit, e_lit + size, efrom_next, result r1 = cvt.in(state01, e_lit, e_lit + size, efrom_next,
i_arr, i_arr + size + 1, ito_next); i_arr, i_arr + size + 1, ito_next);
...@@ -86,7 +93,7 @@ void test01() ...@@ -86,7 +93,7 @@ void test01()
VERIFY( ito_next == i_arr + size ); VERIFY( ito_next == i_arr + size );
// out // out
unicode_codecvt::state_type state02("UCS-2BE", "UCS4", 0xfeff, 0); unicode_codecvt::state_type state02("UCS-2BE", "UCS-4BE", 0xfeff, 0);
initialize_state(state02); initialize_state(state02);
result r2 = cvt.out(state02, i_lit, i_lit + size, ifrom_next, result r2 = cvt.out(state02, i_lit, i_lit + size, ifrom_next,
e_arr, e_arr + size, eto_next); e_arr, e_arr + size, eto_next);
...@@ -97,7 +104,7 @@ void test01() ...@@ -97,7 +104,7 @@ void test01()
// unshift // unshift
ext_traits::copy(e_arr, e_lit, size); ext_traits::copy(e_arr, e_lit, size);
unicode_codecvt::state_type state03("UCS-2BE", "UCS4", 0xfeff, 0); unicode_codecvt::state_type state03("UCS-2BE", "UCS-4BE", 0xfeff, 0);
initialize_state(state03); initialize_state(state03);
result r3 = cvt.unshift(state03, e_arr, e_arr + size, eto_next); result r3 = cvt.unshift(state03, e_arr, e_arr + size, eto_next);
VERIFY( r3 == codecvt_base::noconv ); VERIFY( r3 == codecvt_base::noconv );
...@@ -109,7 +116,7 @@ void test01() ...@@ -109,7 +116,7 @@ void test01()
VERIFY( !cvt.always_noconv() ); VERIFY( !cvt.always_noconv() );
unicode_codecvt::state_type state04("UCS-2BE", "UCS4", 0xfeff, 0); unicode_codecvt::state_type state04("UCS-2BE", "UCS-4BE", 0xfeff, 0);
initialize_state(state04); initialize_state(state04);
int j = cvt.length(state03, e_lit, e_lit + size, 5); int j = cvt.length(state03, e_lit, e_lit + size, 5);
VERIFY( j == 5 ); VERIFY( j == 5 );
...@@ -120,14 +127,16 @@ void test01() ...@@ -120,14 +127,16 @@ void test01()
delete [] e_arr; delete [] e_arr;
delete [] i_arr; delete [] i_arr;
} }
#endif // _GLIBCPP_USE_WCHAR_T
#endif // _GLIBCPP_USE___ENC_TRAITS #endif // _GLIBCPP_USE___ENC_TRAITS
int main () int main ()
{ {
#if _GLIBCPP_USE___ENC_TRAITS #ifdef _GLIBCPP_USE___ENC_TRAITS
#ifdef _GLIBCPP_USE_WCHAR_T
test01(); test01();
#endif
#endif #endif
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment