From: Heeyong Song Date: Thu, 3 Aug 2017 10:57:35 +0000 (+0900) Subject: Add U0 case to Utf8ToUtf32 X-Git-Tag: dali_1.2.52~4^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=21f60153d688233c47b7e86dfe1d6e06450ed3a0;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Add U0 case to Utf8ToUtf32 Change-Id: I9507be62ec8239b39fdd94035233c2b88f4d47c3 --- diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-CharacterSetConversion.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-CharacterSetConversion.cpp old mode 100644 new mode 100755 index 2ec5233..3175baf --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-CharacterSetConversion.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-CharacterSetConversion.cpp @@ -282,11 +282,14 @@ int UtcDaliTextCharacterSetConversionUtf8ToUtf32(void) ToolkitTestApplication application; tet_infoline(" UtcDaliTextCharacterSetConversionGetNumberOfUtf8Bytes"); + char utf8_06[] = { -8, -7, -6, -5, -4, -3, -2, -1 }; // Invalid string + unsigned int utf32_01[] = { 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 }; // Hello World unsigned int utf32_02[] = { 0xA, 0x20, 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0xA, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64 }; // Hello World + CR and CR+LF unsigned int utf32_03[] = { 0x645, 0x631, 0x62D, 0x628, 0x627, 0x20, 0x628, 0x627, 0x644, 0x639, 0x627, 0x644, 0x645 }; // مرحبا بالعالم unsigned int utf32_04[] = { 0x939, 0x948, 0x932, 0x94B, 0x20, 0x935, 0x930, 0x94D, 0x932, 0x94D, 0x921 }; // हैलो वर्ल्ड unsigned int utf32_05[] = { 0x1F601, 0x20, 0x1F602, 0x20, 0x1F603, 0x20, 0x1F604 }; // Emojis + unsigned int utf32_06[] = { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; // Invalid string const Utf8ToUtf32Data data[] = { @@ -315,8 +318,13 @@ int UtcDaliTextCharacterSetConversionUtf8ToUtf32(void) "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84", utf32_05, }, + { + "Invalid text", + utf8_06, + utf32_06, + }, }; - const unsigned int numberOfTests = 5u; + const unsigned int numberOfTests = 6u; for( unsigned int index = 0u; index < numberOfTests; ++index ) { diff --git a/dali-toolkit/internal/text/character-set-conversion.cpp b/dali-toolkit/internal/text/character-set-conversion.cpp index bd72dc1..d79fbc3 100644 --- a/dali-toolkit/internal/text/character-set-conversion.cpp +++ b/dali-toolkit/internal/text/character-set-conversion.cpp @@ -196,6 +196,13 @@ uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length, uint32_t* utf3 code |= *begin++ & 0x3fu; break; } + + case U0: // Invalid case + { + begin++; + *utf32++ = 0x20; // Use white space + break; + } } }