]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/strtest.cpp
1 /********************************************************************
3 * Copyright (c) 1997-2003, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6 /* file name: strtest.cpp
8 * tab size: 8 (not used)
11 * created on: 1999nov22
12 * created by: Markus W. Scherer
15 #include "unicode/utypes.h"
16 #include "unicode/putil.h"
19 #include "unicode/ustring.h"
21 void StringTest::TestEndian(void) {
27 if(U_IS_BIG_ENDIAN
!=u
.byte
) {
28 errln("TestEndian: U_IS_BIG_ENDIAN needs to be fixed in platform.h");
32 void StringTest::TestSizeofWCharT(void) {
33 if(U_SIZEOF_WCHAR_T
!=sizeof(wchar_t)) {
34 errln("TestSizeofWCharT: U_SIZEOF_WCHAR_T!=sizeof(wchar_t) - U_SIZEOF_WCHAR_T needs to be fixed in platform.h");
38 void StringTest::TestSizeofInt64(void) {
39 #ifdef U_INT64_T_UNAVAILABLE
40 errln("int64_t and uint64_t are undefined.");
42 if(8!=sizeof(int64_t)) {
43 errln("TestSizeofInt64: 8!=sizeof(int64_t) - int64_t needs to be fixed in platform.h");
45 if(8!=sizeof(uint64_t)) {
46 errln("TestSizeofInt64: 8!=sizeof(uint64_t) - uint64_t needs to be fixed in platform.h");
49 if(8!=sizeof(double)) {
50 errln("8!=sizeof(double) - putil.c code may not work");
54 void StringTest::TestCharsetFamily(void) {
56 if( U_CHARSET_FAMILY
==U_ASCII_FAMILY
&& c
!=0x41 ||
57 U_CHARSET_FAMILY
==U_EBCDIC_FAMILY
&& c
!=0xc1
59 errln("TestCharsetFamily: U_CHARSET_FAMILY needs to be fixed in platform.h");
63 U_STRING_DECL(ustringVar
, "aZ0 -", 5);
65 void StringTest::runIndexedTest(int32_t index
, UBool exec
, const char *&name
, char * /*par*/) {
67 logln("TestSuite Character and String Test: ");
77 name
="TestSizeofWCharT";
83 name
="TestSizeofInt64";
89 name
="TestCharsetFamily";
97 U_STRING_INIT(ustringVar
, "aZ0 -", 5);
98 if( sizeof(ustringVar
)/sizeof(*ustringVar
)!=6 ||
99 ustringVar
[0]!=0x61 ||
100 ustringVar
[1]!=0x5a ||
101 ustringVar
[2]!=0x30 ||
102 ustringVar
[3]!=0x20 ||
103 ustringVar
[4]!=0x2d ||
106 errln("Test_U_STRING: U_STRING_DECL with U_STRING_INIT does not work right! "
107 "See putil.h and utypes.h with platform.h.");
112 name
="Test_UNICODE_STRING";
114 UnicodeString ustringVar
=UNICODE_STRING("aZ0 -", 5);
115 if( ustringVar
.length()!=5 ||
116 ustringVar
[0]!=0x61 ||
117 ustringVar
[1]!=0x5a ||
118 ustringVar
[2]!=0x30 ||
119 ustringVar
[3]!=0x20 ||
122 errln("Test_UNICODE_STRING: UNICODE_STRING does not work right! "
123 "See unistr.h and utypes.h with platform.h.");
128 name
="Test_UNICODE_STRING_SIMPLE";
130 UnicodeString ustringVar
=UNICODE_STRING_SIMPLE("aZ0 -");
131 if( ustringVar
.length()!=5 ||
132 ustringVar
[0]!=0x61 ||
133 ustringVar
[1]!=0x5a ||
134 ustringVar
[2]!=0x30 ||
135 ustringVar
[3]!=0x20 ||
138 errln("Test_UNICODE_STRING_SIMPLE: UNICODE_STRING_SIMPLE does not work right! "
139 "See unistr.h and utypes.h with platform.h.");
144 name
="Test_UTF8_COUNT_TRAIL_BYTES";
146 if(UTF8_COUNT_TRAIL_BYTES(0x7F) != 0
147 || UTF8_COUNT_TRAIL_BYTES(0xC0) != 1
148 || UTF8_COUNT_TRAIL_BYTES(0xE0) != 2
149 || UTF8_COUNT_TRAIL_BYTES(0xF0) != 3)
151 errln("Test_UTF8_COUNT_TRAIL_BYTES: UTF8_COUNT_TRAIL_BYTES does not work right! "