MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / MakeLongUTF8String

Function MakeLongUTF8String

test/unit_spirv.h:168–184  ·  view source on GitHub ↗

Returns a string with num_4_byte_chars Unicode characters, each of which has a 4-byte UTF-8 encoding.

Source from the content-addressed store, hash-verified

166// Returns a string with num_4_byte_chars Unicode characters,
167// each of which has a 4-byte UTF-8 encoding.
168inline 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.
187inline std::vector<spv_target_env> AllTargetEnvironments() {

Callers 2

TESTFunction · 0.85
TEST_FFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by 2

TESTFunction · 0.68
TEST_FFunction · 0.68