1 /* 2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "utils/utf.h" 17 18 #include <cstdint> 19 20 #include <vector> 21 22 #include <gtest/gtest.h> 23 24 namespace panda::utf::test { 25 26 HWTEST(Utf, ConvertMUtf8ToUtf16_1, testing::ext::TestSize.Level0) 27 { 28 // 2-byte mutf-8 U+0000 29 { 30 const std::vector<uint8_t> in {0xc0, 0x80, 0x00}; 31 const std::vector<uint16_t> res {0x0}; 32 std::vector<uint16_t> out(res.size()); 33 ConvertMUtf8ToUtf16(in.data(), utf::Mutf8Size(in.data()), out.data()); 34 EXPECT_EQ(out, res); 35 } 36 37 // 1-byte mutf-8: 0xxxxxxx 38 { 39 const std::vector<uint8_t> in {0x7f, 0x00}; 40 const std::vector<uint16_t> res {0x7f}; 41 std::vector<uint16_t> out(res.size()); 42 ConvertMUtf8ToUtf16(in.data(), utf::Mutf8Size(in.data()), out.data()); 43 EXPECT_EQ(out, res); 44 } 45 46 // 2-byte mutf-8: 110xxxxx 10xxxxxx 47 { 48 const std::vector<uint8_t> in {0xc2, 0xa7, 0x33, 0x00}; 49 const std::vector<uint16_t> res {0xa7, 0x33}; 50 std::vector<uint16_t> out(res.size()); 51 ConvertMUtf8ToUtf16(in.data(), utf::Mutf8Size(in.data()), out.data()); 52 EXPECT_EQ(out, res); 53 } 54 55 // 3-byte mutf-8: 1110xxxx 10xxxxxx 10xxxxxx 56 { 57 const std::vector<uint8_t> in {0xef, 0xbf, 0x83, 0x33, 0x00}; 58 const std::vector<uint16_t> res {0xffc3, 0x33}; 59 std::vector<uint16_t> out(res.size()); 60 ConvertMUtf8ToUtf16(in.data(), utf::Mutf8Size(in.data()), out.data()); 61 EXPECT_EQ(out, res); 62 } 63 } 64 65 // double 3-byte mutf-8: 11101101 1010xxxx 10xxxxxx 11101101 1011xxxx 10xxxxxx 66 HWTEST(Utf, ConvertMUtf8ToUtf16_2, testing::ext::TestSize.Level0) 67 { 68 { 69 const std::vector<uint8_t> in {0xed, 0xa0, 0x81, 0xed, 0xb0, 0xb7, 0x00}; 70 const std::vector<uint16_t> res {0xd801, 0xdc37}; 71 std::vector<uint16_t> out(res.size()); 72 ConvertMUtf8ToUtf16(in.data(), utf::Mutf8Size(in.data()), out.data()); 73 EXPECT_EQ(out, res); 74 } 75 76 { 77 const std::vector<uint8_t> in {0x5b, 0x61, 0x62, 0x63, 0xed, 0xa3, 0x92, 0x5d, 0x00}; 78 const std::vector<uint16_t> res {0x5b, 0x61, 0x62, 0x63, 0xd8d2, 0x5d}; 79 std::vector<uint16_t> out(res.size()); 80 ConvertMUtf8ToUtf16(in.data(), utf::Mutf8Size(in.data()), out.data()); 81 EXPECT_EQ(out, res); 82 } 83 84 { 85 const std::vector<uint8_t> in {0xF0, 0x9F, 0x91, 0xB3, 0x00}; 86 const std::vector<uint16_t> res {0xD83D, 0xDC73}; 87 std::vector<uint16_t> out(res.size()); 88 ConvertMUtf8ToUtf16(in.data(), utf::Mutf8Size(in.data()), out.data()); 89 EXPECT_EQ(out, res); 90 } 91 } 92 93 HWTEST(Utf, Utf16ToMUtf8Size, testing::ext::TestSize.Level0) 94 { 95 // 2-byte mutf-8 U+0000 96 { 97 const std::vector<uint16_t> in {0x0}; 98 size_t res = Utf16ToMUtf8Size(in.data(), in.size()); 99 EXPECT_EQ(res, 3U); 100 } 101 102 // 1-byte mutf-8: 0xxxxxxx 103 { 104 const std::vector<uint16_t> in {0x7f}; 105 size_t res = Utf16ToMUtf8Size(in.data(), in.size()); 106 EXPECT_EQ(res, 2U); 107 } 108 109 { 110 const std::vector<uint16_t> in {0x7f}; 111 size_t res = Utf16ToMUtf8Size(in.data(), in.size()); 112 EXPECT_EQ(res, 2U); 113 } 114 115 // 2-byte mutf-8: 110xxxxx 10xxxxxx 116 { 117 const std::vector<uint16_t> in {0xa7, 0x33}; 118 size_t res = Utf16ToMUtf8Size(in.data(), in.size()); 119 EXPECT_EQ(res, 4U); 120 } 121 122 // 3-byte mutf-8: 1110xxxx 10xxxxxx 10xxxxxx 123 { 124 const std::vector<uint16_t> in {0xffc3, 0x33}; 125 size_t res = Utf16ToMUtf8Size(in.data(), in.size()); 126 EXPECT_EQ(res, 5U); 127 } 128 129 // double 3-byte mutf-8: 11101101 1010xxxx 10xxxxxx 11101101 1011xxxx 10xxxxxx 130 { 131 const std::vector<uint16_t> in {0xd801, 0xdc37}; 132 size_t res = Utf16ToMUtf8Size(in.data(), in.size()); 133 EXPECT_EQ(res, 5U); 134 } 135 } 136 137 HWTEST(Utf, ConvertRegionUtf16ToMUtf8_1, testing::ext::TestSize.Level0) 138 { 139 // 2-byte mutf-8 U+0000 140 { 141 const std::vector<uint16_t> in {0x0}; 142 const std::vector<uint8_t> res {0xc0, 0x80, 0x00}; 143 std::vector<uint8_t> out(res.size()); 144 size_t sz = ConvertRegionUtf16ToMUtf8(in.data(), out.data(), in.size(), out.size() - 1, 0); 145 EXPECT_EQ(sz, 2U); 146 out[out.size() - 1] = '\0'; 147 EXPECT_EQ(out, res); 148 } 149 150 // 1-byte mutf-8: 0xxxxxxx 151 { 152 const std::vector<uint16_t> in {0x7f}; 153 const std::vector<uint8_t> res {0x7f, 0x00}; 154 std::vector<uint8_t> out(res.size()); 155 size_t sz = ConvertRegionUtf16ToMUtf8(in.data(), out.data(), in.size(), out.size() - 1, 0); 156 EXPECT_EQ(sz, 1U); 157 out[out.size() - 1] = '\0'; 158 EXPECT_EQ(out, res); 159 } 160 161 // 2-byte mutf-8: 110xxxxx 10xxxxxx 162 { 163 const std::vector<uint16_t> in {0xa7, 0x33}; 164 const std::vector<uint8_t> res {0xc2, 0xa7, 0x33, 0x00}; 165 std::vector<uint8_t> out(res.size()); 166 size_t sz = ConvertRegionUtf16ToMUtf8(in.data(), out.data(), in.size(), out.size() - 1, 0); 167 EXPECT_EQ(sz, 3U); 168 out[out.size() - 1] = '\0'; 169 EXPECT_EQ(out, res); 170 } 171 172 // 3-byte mutf-8: 1110xxxx 10xxxxxx 10xxxxxx 173 { 174 const std::vector<uint16_t> in {0xffc3, 0x33}; 175 const std::vector<uint8_t> res {0xef, 0xbf, 0x83, 0x33, 0x00}; 176 std::vector<uint8_t> out(res.size()); 177 size_t sz = ConvertRegionUtf16ToMUtf8(in.data(), out.data(), in.size(), out.size() - 1, 0); 178 EXPECT_EQ(sz, 4U); 179 out[out.size() - 1] = '\0'; 180 EXPECT_EQ(out, res); 181 } 182 } 183 184 HWTEST(Utf, ConvertRegionUtf16ToMUtf8_2, testing::ext::TestSize.Level0) 185 { 186 // 3-byte mutf-8: 1110xxxx 10xxxxxx 10xxxxxx 187 // utf-16 data in 0xd800-0xdfff 188 { 189 const std::vector<uint16_t> in {0xd834, 0x33}; 190 const std::vector<uint8_t> res {0xed, 0xa0, 0xb4, 0x33, 0x00}; 191 std::vector<uint8_t> out(res.size()); 192 size_t sz = ConvertRegionUtf16ToMUtf8(in.data(), out.data(), in.size(), out.size() - 1, 0); 193 EXPECT_EQ(sz, 4U); 194 out[out.size() - 1] = '\0'; 195 EXPECT_EQ(out, res); 196 } 197 198 // 3-byte mutf-8: 1110xxxx 10xxxxxx 10xxxxxx 199 // utf-16 data in 0xd800-0xdfff 200 { 201 const std::vector<uint16_t> in {0xdf06, 0x33}; 202 const std::vector<uint8_t> res {0xed, 0xbc, 0x86, 0x33, 0x00}; 203 std::vector<uint8_t> out(res.size()); 204 size_t sz = ConvertRegionUtf16ToMUtf8(in.data(), out.data(), in.size(), out.size() - 1, 0); 205 EXPECT_EQ(sz, 4U); 206 out[out.size() - 1] = '\0'; 207 EXPECT_EQ(out, res); 208 } 209 210 // double 3-byte mutf-8: 11101101 1010xxxx 10xxxxxx 11101101 1011xxxx 10xxxxxx 211 { 212 const std::vector<uint16_t> in {0xd801, 0xdc37}; 213 const std::vector<uint8_t> res {0xf0, 0x90, 0x90, 0xb7, 0x00}; 214 std::vector<uint8_t> out(res.size()); 215 size_t sz = ConvertRegionUtf16ToMUtf8(in.data(), out.data(), in.size(), out.size() - 1, 0); 216 EXPECT_EQ(sz, 4U); 217 out[out.size() - 1] = '\0'; 218 EXPECT_EQ(out, res); 219 } 220 } 221 222 // 1-byte utf-8: 0xxxxxxx 223 HWTEST(Utf, CompareMUtf8ToMUtf8_1, testing::ext::TestSize.Level0) 224 { 225 { 226 const std::vector<uint8_t> v1 {0x00}; 227 const std::vector<uint8_t> v2 {0x7f, 0x00}; 228 EXPECT_TRUE(CompareMUtf8ToMUtf8(v1.data(), v2.data()) < 0); 229 } 230 231 { 232 const std::vector<uint8_t> v1 {0x02, 0x00}; 233 const std::vector<uint8_t> v2 {0x00}; 234 EXPECT_TRUE(CompareMUtf8ToMUtf8(v1.data(), v2.data()) > 0); 235 } 236 237 { 238 const std::vector<uint8_t> v1 {0x7f, 0x00}; 239 const std::vector<uint8_t> v2 {0x7f, 0x00}; 240 EXPECT_TRUE(CompareMUtf8ToMUtf8(v1.data(), v2.data()) == 0); 241 } 242 243 { 244 const std::vector<uint8_t> v1 {0x01, 0x7f, 0x00}; 245 const std::vector<uint8_t> v2 {0x01, 0x70, 0x00}; 246 EXPECT_TRUE(CompareMUtf8ToMUtf8(v1.data(), v2.data()) > 0); 247 } 248 249 { 250 const std::vector<uint8_t> v1 {0x01, 0x71, 0x00}; 251 const std::vector<uint8_t> v2 {0x01, 0x73, 0x00}; 252 EXPECT_TRUE(CompareMUtf8ToMUtf8(v1.data(), v2.data()) < 0); 253 } 254 } 255 256 // 2-byte utf-8: 110xxxxx 10xxxxxx 257 HWTEST(Utf, CompareMUtf8ToMUtf8_2, testing::ext::TestSize.Level0) 258 { 259 { 260 const std::vector<uint8_t> v1 {0xdf, 0xbf, 0x03, 0x00}; 261 const std::vector<uint8_t> v2 {0xdf, 0xbf, 0x03, 0x00}; 262 EXPECT_TRUE(CompareMUtf8ToMUtf8(v1.data(), v2.data()) == 0); 263 } 264 265 { 266 const std::vector<uint8_t> v1 {0xdf, 0xb1, 0x03, 0x00}; 267 const std::vector<uint8_t> v2 {0xd1, 0xb2, 0x03, 0x00}; 268 EXPECT_TRUE(CompareMUtf8ToMUtf8(v1.data(), v2.data()) > 0); 269 } 270 271 { 272 const std::vector<uint8_t> v1 {0xd1, 0xbf, 0x03, 0x00}; 273 const std::vector<uint8_t> v2 {0xdf, 0xb0, 0x03, 0x00}; 274 EXPECT_TRUE(CompareMUtf8ToMUtf8(v1.data(), v2.data()) < 0); 275 } 276 } 277 278 // 3-byte utf-8: 1110xxxx 10xxxxxx 10xxxxxx 279 HWTEST(Utf, CompareMUtf8ToMUtf8_3, testing::ext::TestSize.Level0) 280 { 281 { 282 const std::vector<uint8_t> v1 {0xef, 0xbf, 0x03, 0x04, 0x00}; 283 const std::vector<uint8_t> v2 {0xef, 0xbf, 0x03, 0x04, 0x00}; 284 EXPECT_TRUE(CompareMUtf8ToMUtf8(v1.data(), v2.data()) == 0); 285 } 286 287 { 288 const std::vector<uint8_t> v1 {0xef, 0xb2, 0x03, 0x04, 0x00}; 289 const std::vector<uint8_t> v2 {0xe0, 0xbf, 0x03, 0x04, 0x00}; 290 EXPECT_TRUE(CompareMUtf8ToMUtf8(v1.data(), v2.data()) > 0); 291 } 292 293 { 294 const std::vector<uint8_t> v1 {0xef, 0xb0, 0x03, 0x04, 0x00}; 295 const std::vector<uint8_t> v2 {0xef, 0xbf, 0x05, 0x04, 0x00}; 296 EXPECT_TRUE(CompareMUtf8ToMUtf8(v1.data(), v2.data()) < 0); 297 } 298 } 299 300 // 4-byte utf-8: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 301 HWTEST(Utf, CompareMUtf8ToMUtf8_4, testing::ext::TestSize.Level0) 302 { 303 { 304 const std::vector<uint8_t> v1 {0xf7, 0xbf, 0xbf, 0x04, 0x05, 0x00}; 305 const std::vector<uint8_t> v2 {0xf7, 0xbf, 0xbf, 0x04, 0x05, 0x00}; 306 EXPECT_TRUE(CompareMUtf8ToMUtf8(v1.data(), v2.data()) == 0); 307 } 308 309 { 310 const std::vector<uint8_t> v1 {0xf7, 0xbf, 0xbf, 0x0a, 0x05, 0x00}; 311 const std::vector<uint8_t> v2 {0xf7, 0xbf, 0xbf, 0x04, 0x05, 0x00}; 312 EXPECT_TRUE(CompareMUtf8ToMUtf8(v1.data(), v2.data()) > 0); 313 } 314 315 { 316 const std::vector<uint8_t> v1 {0xf7, 0xbf, 0xbf, 0x04, 0x05, 0x00}; 317 const std::vector<uint8_t> v2 {0xf8, 0xbf, 0xbf, 0x04, 0x05, 0x00}; 318 EXPECT_TRUE(CompareMUtf8ToMUtf8(v1.data(), v2.data()) < 0); 319 } 320 } 321 322 // 1-byte utf-8: 0xxxxxxx 323 HWTEST(Utf, CompareUtf8ToUtf8_1, testing::ext::TestSize.Level0) 324 { 325 { 326 const std::vector<uint8_t> v1 {0x00}; 327 const std::vector<uint8_t> v2 {0x7f, 0x00}; 328 EXPECT_TRUE(CompareUtf8ToUtf8(v1.data(), v1.size(), v2.data(), v2.size()) < 0); 329 } 330 331 { 332 const std::vector<uint8_t> v1 {0x02, 0x00}; 333 const std::vector<uint8_t> v2 {0x00}; 334 EXPECT_TRUE(CompareUtf8ToUtf8(v1.data(), v1.size(), v2.data(), v2.size()) > 0); 335 } 336 337 { 338 const std::vector<uint8_t> v1 {0x7f, 0x00}; 339 const std::vector<uint8_t> v2 {0x7f, 0x00}; 340 EXPECT_TRUE(CompareUtf8ToUtf8(v1.data(), v1.size(), v2.data(), v2.size()) == 0); 341 } 342 343 { 344 const std::vector<uint8_t> v1 {0x01, 0x7f, 0x00}; 345 const std::vector<uint8_t> v2 {0x01, 0x70, 0x00}; 346 EXPECT_TRUE(CompareUtf8ToUtf8(v1.data(), v1.size(), v2.data(), v2.size()) > 0); 347 } 348 349 { 350 const std::vector<uint8_t> v1 {0x01, 0x71, 0x00}; 351 const std::vector<uint8_t> v2 {0x01, 0x73, 0x00}; 352 EXPECT_TRUE(CompareUtf8ToUtf8(v1.data(), v1.size(), v2.data(), v2.size()) < 0); 353 } 354 } 355 356 // 2-byte utf-8: 110xxxxx 10xxxxxx 357 HWTEST(Utf, CompareUtf8ToUtf8_2, testing::ext::TestSize.Level0) 358 { 359 { 360 const std::vector<uint8_t> v1 {0xdf, 0xbf, 0x03, 0x00}; 361 const std::vector<uint8_t> v2 {0xdf, 0xbf, 0x03, 0x00}; 362 EXPECT_TRUE(CompareUtf8ToUtf8(v1.data(), v1.size(), v2.data(), v2.size()) == 0); 363 } 364 365 { 366 const std::vector<uint8_t> v1 {0xdf, 0xb1, 0x03, 0x00}; 367 const std::vector<uint8_t> v2 {0xd1, 0xb2, 0x03, 0x00}; 368 EXPECT_TRUE(CompareUtf8ToUtf8(v1.data(), v1.size(), v2.data(), v2.size()) > 0); 369 } 370 371 { 372 const std::vector<uint8_t> v1 {0xd1, 0xbf, 0x03, 0x00}; 373 const std::vector<uint8_t> v2 {0xdf, 0xb0, 0x03, 0x00}; 374 EXPECT_TRUE(CompareUtf8ToUtf8(v1.data(), v1.size(), v2.data(), v2.size()) < 0); 375 } 376 } 377 378 // 3-byte utf-8: 1110xxxx 10xxxxxx 10xxxxxx 379 HWTEST(Utf, CompareUtf8ToUtf8_3, testing::ext::TestSize.Level0) 380 { 381 { 382 const std::vector<uint8_t> v1 {0xef, 0xbf, 0x03, 0x04, 0x00}; 383 const std::vector<uint8_t> v2 {0xef, 0xbf, 0x03, 0x04, 0x00}; 384 EXPECT_TRUE(CompareUtf8ToUtf8(v1.data(), v1.size(), v2.data(), v2.size()) == 0); 385 } 386 387 { 388 const std::vector<uint8_t> v1 {0xef, 0xb2, 0x03, 0x04, 0x00}; 389 const std::vector<uint8_t> v2 {0xe0, 0xbf, 0x03, 0x04, 0x00}; 390 EXPECT_TRUE(CompareUtf8ToUtf8(v1.data(), v1.size(), v2.data(), v2.size()) > 0); 391 } 392 393 { 394 const std::vector<uint8_t> v1 {0xef, 0xb0, 0x03, 0x04, 0x00}; 395 const std::vector<uint8_t> v2 {0xef, 0xbf, 0x05, 0x04, 0x00}; 396 EXPECT_TRUE(CompareUtf8ToUtf8(v1.data(), v1.size(), v2.data(), v2.size()) < 0); 397 } 398 } 399 400 // 4-byte utf-8: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 401 HWTEST(Utf, CompareUtf8ToUtf8_4, testing::ext::TestSize.Level0) 402 { 403 { 404 const std::vector<uint8_t> v1 {0xf7, 0xbf, 0xbf, 0x04, 0x05, 0x00}; 405 const std::vector<uint8_t> v2 {0xf7, 0xbf, 0xbf, 0x04, 0x05, 0x00}; 406 EXPECT_TRUE(CompareUtf8ToUtf8(v1.data(), v1.size(), v2.data(), v2.size()) == 0); 407 } 408 409 { 410 const std::vector<uint8_t> v1 {0xf7, 0xbf, 0xbf, 0x0a, 0x05, 0x00}; 411 const std::vector<uint8_t> v2 {0xf7, 0xbf, 0xbf, 0x04, 0x05, 0x00}; 412 EXPECT_TRUE(CompareUtf8ToUtf8(v1.data(), v1.size(), v2.data(), v2.size()) > 0); 413 } 414 415 { 416 const std::vector<uint8_t> v1 {0xf7, 0xbf, 0xbf, 0x04, 0x05, 0x00}; 417 const std::vector<uint8_t> v2 {0xf8, 0xbf, 0xbf, 0x04, 0x05, 0x00}; 418 EXPECT_TRUE(CompareUtf8ToUtf8(v1.data(), v1.size(), v2.data(), v2.size()) < 0); 419 } 420 } 421 422 HWTEST(Utf, IsMUtf8OnlySingleBytes, testing::ext::TestSize.Level0) 423 { 424 const std::vector<uint8_t> v1 {0x02, 0x00}; 425 EXPECT_TRUE(IsMUtf8OnlySingleBytes(v1.data())); 426 427 const std::vector<uint8_t> v2 {0x90, 0x00}; 428 EXPECT_FALSE(IsMUtf8OnlySingleBytes(v2.data())); 429 } 430 431 HWTEST(Utf, IsValidModifiedUTF8, testing::ext::TestSize.Level0) 432 { 433 const std::vector<uint8_t> v1 {0x31, 0x00}; 434 EXPECT_TRUE(IsValidModifiedUTF8(v1.data())); 435 436 const std::vector<uint8_t> v2 {0x9f, 0x00}; 437 EXPECT_FALSE(IsValidModifiedUTF8(v2.data())); 438 439 const std::vector<uint8_t> v3 {0xf7, 0x00}; 440 EXPECT_FALSE(IsValidModifiedUTF8(v3.data())); 441 442 const std::vector<uint8_t> v4 {0xe0, 0x00}; 443 EXPECT_FALSE(IsValidModifiedUTF8(v4.data())); 444 445 const std::vector<uint8_t> v5 {0xd4, 0x00}; 446 EXPECT_FALSE(IsValidModifiedUTF8(v5.data())); 447 448 const std::vector<uint8_t> v6 {0x11, 0x31, 0x00}; 449 EXPECT_TRUE(IsValidModifiedUTF8(v6.data())); 450 451 const std::vector<uint8_t> v7 {0xf8, 0x00}; 452 EXPECT_FALSE(IsValidModifiedUTF8(v7.data())); 453 } 454 455 HWTEST(Utf, ConvertMUtf8ToUtf16Pair, testing::ext::TestSize.Level0) 456 { 457 const uint8_t data = 0x11; 458 std::pair<uint32_t, size_t> p1 = ConvertMUtf8ToUtf16Pair(&data, 2U); 459 ASSERT_EQ(17U, p1.first); 460 ASSERT_EQ(1U, p1.second); 461 462 std::pair<uint32_t, size_t> p2 = ConvertMUtf8ToUtf16Pair(&data, 3U); 463 ASSERT_EQ(17U, p2.first); 464 ASSERT_EQ(1U, p2.second); 465 } 466 467 HWTEST(Utf, IsEqualTest, testing::ext::TestSize.Level0) 468 { 469 { 470 const std::vector<uint8_t> v1 {0x7f, 0x00}; 471 const std::vector<uint8_t> v2 {0x7f, 0x00}; 472 Span<const uint8_t> utf8_1(v1.data(), v1.size()); 473 Span<const uint8_t> utf8_2(v2.data(), v2.size()); 474 ASSERT_TRUE(IsEqual(utf8_1, utf8_2)); 475 } 476 477 { 478 const std::vector<uint8_t> v1 {0x7f, 0x7f, 0x00}; 479 const std::vector<uint8_t> v2 {0x7f, 0x00}; 480 Span<const uint8_t> utf8_1(v1.data(), v1.size()); 481 Span<const uint8_t> utf8_2(v2.data(), v2.size()); 482 ASSERT_FALSE(IsEqual(utf8_1, utf8_2)); 483 } 484 485 { 486 const std::vector<uint8_t> v1 {0xdf, 0xbf, 0x03, 0x00}; 487 const std::vector<uint8_t> v2 {0xdf, 0xbf, 0x03, 0x00}; 488 EXPECT_TRUE(IsEqual(v1.data(), v2.data())); 489 } 490 } 491 492 } // namespace panda::utf::test 493