Add U0 case to Utf8ToUtf32 16/142316/3
authorHeeyong Song <heeyong.song@samsung.com>
Thu, 3 Aug 2017 10:57:35 +0000 (19:57 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Fri, 4 Aug 2017 09:10:07 +0000 (18:10 +0900)
Change-Id: I9507be62ec8239b39fdd94035233c2b88f4d47c3

automated-tests/src/dali-toolkit-internal/utc-Dali-Text-CharacterSetConversion.cpp [changed mode: 0644->0755]
dali-toolkit/internal/text/character-set-conversion.cpp

old mode 100644 (file)
new mode 100755 (executable)
index 2ec5233..3175baf
@@ -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 )
   {
index bd72dc1..d79fbc3 100644 (file)
@@ -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;
+      }
     }
   }