Use basic_string<char> for the UTF-8 test string
authorDavid Neto <dneto@google.com>
Tue, 27 Oct 2015 15:10:29 +0000 (11:10 -0400)
committerDavid Neto <dneto@google.com>
Mon, 2 Nov 2015 18:51:57 +0000 (13:51 -0500)
This is an attempt to fix the unit tests on DeveloperStudio 2013.
Currently, the size of the earth_africa string is reported as 2
on Windows.  But I think that may be 2 16-bit characters.

test/UnitSPIRV.h

index d0c6757..aca53f8 100644 (file)
@@ -196,8 +196,13 @@ class EnumCase {
 // each of which has a 4-byte UTF-8 encoding.
 inline std::string MakeLongUTF8String(size_t num_4_byte_chars) {
   // An example of a longest valid UTF-8 character.
-  const std::string earth_africa("\xF0\x9F\x8C\x8D");
+  // Be explicit about the character type becuase Microsoft compilers can
+  // otherwise interpret the character string as being over wide (16-bit)
+  // characters.  Ideally, we would just use a C++11 UTF-8 string literal,
+  // but we want to support older Microsoft compilers.
+  const std::basic_string<char> earth_africa("\xF0\x9F\x8C\x8D");
   EXPECT_EQ(4, earth_africa.size());
+
   std::string result;
   result.reserve(num_4_byte_chars * 4);
   for (size_t i = 0; i < num_4_byte_chars; i++ ) {