From 1be173845b23f2296e2effc5225c722b81f5f5c1 Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Fri, 19 Jun 2009 19:20:55 +0000 Subject: [PATCH] ICU-6955 Improve code coverage for charset SCSU. Fix some errors in CharsetSCSU. X-SVN-Rev: 26133 --- icu4c/source/test/testdata/conversion.txt | 16 ++++++++++++++++ .../src/com/ibm/icu/charset/CharsetSCSU.java | 8 ++++---- icu4j/main/shared/data/testdata.jar | 4 ++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/icu4c/source/test/testdata/conversion.txt b/icu4c/source/test/testdata/conversion.txt index 0c0978d7141..5ce93ffe3a6 100644 --- a/icu4c/source/test/testdata/conversion.txt +++ b/icu4c/source/test/testdata/conversion.txt @@ -834,6 +834,14 @@ conversion:table(nofallback) { :intvector{}, :int{1}, :int{0}, "", "0", :bin{""} } + //Improve code coverage for SCSU + { + "SCSU", + :bin{ 0fd899dc7fd888dc99e041424361 }, + "\ud899\udc7f\ud888\udc99\u0041\u0042\u0043\u0061", + :intvector{}, + :int{1}, :int{0}, "", "0", :bin{""} + } } } @@ -1610,6 +1618,14 @@ conversion:table(nofallback) { :intvector{}, :int{1}, :int{0}, "", ".", "" } + // Improve code coverage for SCSU + { + "SCSU", + "\ud899\udc7f\ud977\ud888\udc99\ud888\u0041", + :bin{ 0fd899dc7fd888dc99e041 }, + :intvector{}, + :int{1}, :int{0}, "", "0", "" + } } } diff --git a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetSCSU.java b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetSCSU.java index 2f7e83b8cf2..354722406c8 100644 --- a/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetSCSU.java +++ b/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetSCSU.java @@ -513,15 +513,15 @@ class CharsetSCSU extends CharsetICU{ LabelLoop = false; return label; } - b = source.get(); + b = (short)(source.get() & UConverterConstants.UNSIGNED_BYTE_MASK); ++nextSourceIndex; switch(state){ case readCommand: - if((byte)(b -UC0)>(Urs - UC0)){ + if((short)((b -UC0)&UConverterConstants.UNSIGNED_BYTE_MASK)>(Urs - UC0)){ byteOne = b; toUBytesArray[0] = (byte)b; toULength = 1; - state = quotePairOne; + state = quotePairTwo; }else if((b&UConverterConstants.UNSIGNED_BYTE_MASK) <= UC7){ dynamicWindow = (byte)(b - UC0); sourceIndex = nextSourceIndex; @@ -1026,7 +1026,7 @@ class CharsetSCSU extends CharsetICU{ } else if(c<0xe000 && !AfterGetTrailUnicode){ label = GetTrailUnicode; return label; - } else { + } else if (!AfterGetTrailUnicode){ /*quote to avoid SCSU tags*/ c|=UQU<<16; length = 3; diff --git a/icu4j/main/shared/data/testdata.jar b/icu4j/main/shared/data/testdata.jar index c1dd078c698..7b5927abd8e 100755 --- a/icu4j/main/shared/data/testdata.jar +++ b/icu4j/main/shared/data/testdata.jar @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e45a334fc1a57269c5a6365b5a074a3d3f41d7824cd9fa2900acda7377a1f182 -size 772209 +oid sha256:7519a822ce8a3697adbad3fe85f070e8663b1fde3b8f310cac0243345f13b902 +size 772303