Test for utf-7 enc.

This commit is contained in:
cata%netscape.com 1999-07-06 22:40:17 +00:00
parent ed2a234d32
commit 19f4e1e396

View File

@ -1066,6 +1066,43 @@ nsresult testMUTF7Encoder()
}
}
/**
* Test the UTF-7 encoder.
*/
nsresult testUTF7Encoder()
{
char * testName = "T206";
printf("\n[%s] Unicode -> UTF-7\n", testName);
// create converter
CREATE_ENCODER("utf-7");
enc->SetOutputErrorBehavior(enc->kOnError_Replace, NULL, 0x00cc);
// test data
PRUnichar src[] = {'e','t','i','r','a',0x0a};
char exp[] = {"etira\x0a"};
// test converter - easy test
res = testEncoder(enc, src, ARRAY_SIZE(src), exp, ARRAY_SIZE(exp)-1, testName);
// reset converter
if (NS_SUCCEEDED(res)) res = resetEncoder(enc, testName);
// test converter - stress test
if (NS_SUCCEEDED(res))
res = testStressEncoder(enc, src, ARRAY_SIZE(src), exp, ARRAY_SIZE(exp)-1, testName);
// release converter
NS_RELEASE(enc);
if (NS_FAILED(res)) {
return res;
} else {
printf("Test Passed.\n");
return NS_OK;
}
}
nsresult testPlatformCharset()
{
nsIPlatformCharset * cinfo;
@ -1120,6 +1157,7 @@ nsresult testAll()
testEUCJPEncoder();
testISO2022JPEncoder();
testMUTF7Encoder();
testUTF7Encoder();
// return
return NS_OK;