Added tests for null strings and strings with length 0.

X-SVN-Rev: 5705
This commit is contained in:
Syn Wee Quek 2001-09-06 16:32:54 +00:00
parent 3e6cbc182f
commit 77ebb43324
2 changed files with 26 additions and 6 deletions

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/lang/UTF16Test.java,v $
* $Date: 2001/09/01 00:59:03 $
* $Revision: 1.7 $
* $Date: 2001/09/06 16:32:54 $
* $Revision: 1.8 $
*
*******************************************************************************
*/
@ -215,11 +215,21 @@ public final class UTF16Test extends TestFmwk
*/
public void TestCountCodePoint()
{
StringBuffer strbuff = new StringBuffer("this is a string ");
StringBuffer strbuff = new StringBuffer("");
if (UTF16.countCodePoint(strbuff) != 0 ||
UTF16.countCodePoint("") != 0) {
errln("FAIL Counting code points for empty strings");
}
strbuff = new StringBuffer("this is a string ");
String str = strbuff.toString();
char array[] = str.toCharArray();
int size = str.length();
if (UTF16.countCodePoint(array, 0, 0) != 0) {
errln("FAIL Counting code points for 0 offset array");
}
if (UTF16.countCodePoint(str) != size ||
UTF16.countCodePoint(strbuff) != size ||
UTF16.countCodePoint(array, 0, size) != size) {

View File

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/test/text/Attic/UTF16Test.java,v $
* $Date: 2001/09/01 00:59:03 $
* $Revision: 1.7 $
* $Date: 2001/09/06 16:32:54 $
* $Revision: 1.8 $
*
*******************************************************************************
*/
@ -215,11 +215,21 @@ public final class UTF16Test extends TestFmwk
*/
public void TestCountCodePoint()
{
StringBuffer strbuff = new StringBuffer("this is a string ");
StringBuffer strbuff = new StringBuffer("");
if (UTF16.countCodePoint(strbuff) != 0 ||
UTF16.countCodePoint("") != 0) {
errln("FAIL Counting code points for empty strings");
}
strbuff = new StringBuffer("this is a string ");
String str = strbuff.toString();
char array[] = str.toCharArray();
int size = str.length();
if (UTF16.countCodePoint(array, 0, 0) != 0) {
errln("FAIL Counting code points for 0 offset array");
}
if (UTF16.countCodePoint(str) != size ||
UTF16.countCodePoint(strbuff) != size ||
UTF16.countCodePoint(array, 0, size) != size) {