Returns a string with num_4_byte_chars Unicode characters, each of which has a 4-byte UTF-8 encoding.
| 166 | // Returns a string with num_4_byte_chars Unicode characters, |
| 167 | // each of which has a 4-byte UTF-8 encoding. |
| 168 | inline std::string MakeLongUTF8String(size_t num_4_byte_chars) { |
| 169 | // An example of a longest valid UTF-8 character. |
| 170 | // Be explicit about the character type because Microsoft compilers can |
| 171 | // otherwise interpret the character string as being over wide (16-bit) |
| 172 | // characters. Ideally, we would just use a C++11 UTF-8 string literal, |
| 173 | // but we want to support older Microsoft compilers. |
| 174 | const std::basic_string<char> earth_africa("\xF0\x9F\x8C\x8D"); |
| 175 | EXPECT_EQ(4u, earth_africa.size()); |
| 176 | |
| 177 | std::string result; |
| 178 | result.reserve(num_4_byte_chars * 4); |
| 179 | for (size_t i = 0; i < num_4_byte_chars; i++) { |
| 180 | result += earth_africa; |
| 181 | } |
| 182 | EXPECT_EQ(4 * num_4_byte_chars, result.size()); |
| 183 | return result; |
| 184 | } |
| 185 | |
| 186 | // Returns a vector of all valid target environment enums. |
| 187 | inline std::vector<spv_target_env> AllTargetEnvironments() { |