ICU-157 add tests for endianness & charset family

X-SVN-Rev: 222
This commit is contained in:
Markus Scherer 1999-11-22 20:52:33 +00:00
parent ca34bad82b
commit b4935bd035
2 changed files with 34 additions and 0 deletions

View file

@ -23,23 +23,55 @@
#include "intltest.h"
#include "strtest.h"
void StringTest::TestEndian() {
union {
uint8_t byte;
uint16_t word;
} u;
u.word=0x0100;
if(U_IS_BIG_ENDIAN!=u.byte) {
errln("TestEndian: U_IS_BIG_ENDIAN needs to be fixed in platform.h");
}
}
void StringTest::TestSizeofWCharT() {
if(U_SIZEOF_WCHAR_T!=sizeof(wchar_t)) {
errln("TestSizeofWCharT: U_SIZEOF_WCHAR_T!=sizeof(wchar_t) - U_SIZEOF_WCHAR_T needs to be fixed in platform.h");
}
}
void StringTest::TestCharsetFamily() {
unsigned char c='A';
if( U_CHARSET_FAMILY==U_ASCII_FAMILY && c!=0x41 ||
U_CHARSET_FAMILY==U_EBCDIC_FAMILY && c!=0xc1
) {
errln("TestCharsetFamily: U_CHARSET_FAMILY needs to be fixed in platform.h");
}
}
void StringTest::runIndexedTest(int32_t index, bool_t exec, char *&name, char *par) {
if(exec) {
logln("TestSuite Character and String Test: ");
}
switch(index) {
case 0:
name="TestEndian";
if(exec) {
TestEndian();
}
break;
case 1:
name="TestSizeofWCharT";
if(exec) {
TestSizeofWCharT();
}
break;
case 2:
name="TestCharsetFamily";
if(exec) {
TestCharsetFamily();
}
break;
default:
name="";
break;

View file

@ -36,7 +36,9 @@ public:
void runIndexedTest(int32_t index, bool_t exec, char *&name, char *par=NULL);
private:
void TestEndian();
void TestSizeofWCharT();
void TestCharsetFamily();
};
#endif