llvm.org GIT mirror llvm / 58234c1 unittests / Support / ConvertUTFTest.cpp
58234c1

Tree @58234c1 (Download .tar.gz)

ConvertUTFTest.cpp @58234c1raw · history · blame

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
//===- llvm/unittest/Support/ConvertUTFTest.cpp - ConvertUTF tests --------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "llvm/Support/ConvertUTF.h"
#include "llvm/ADT/ArrayRef.h"
#include "gtest/gtest.h"
#include <string>
#include <vector>

using namespace llvm;

TEST(ConvertUTFTest, ConvertUTF16LittleEndianToUTF8String) {
  // Src is the look of disapproval.
  static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
  ArrayRef<char> Ref(Src, sizeof(Src) - 1);
  std::string Result;
  bool Success = convertUTF16ToUTF8String(Ref, Result);
  EXPECT_TRUE(Success);
  std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
  EXPECT_EQ(Expected, Result);
}

TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) {
  // Src is the look of disapproval.
  static const char Src[] = "\xfe\xff\x0c\xa0\x00_\x0c\xa0";
  ArrayRef<char> Ref(Src, sizeof(Src) - 1);
  std::string Result;
  bool Success = convertUTF16ToUTF8String(Ref, Result);
  EXPECT_TRUE(Success);
  std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
  EXPECT_EQ(Expected, Result);
}

TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
  // Src is the look of disapproval.
  static const char Src[] = "\xe0\xb2\xa0_\xe0\xb2\xa0";
  StringRef Ref(Src, sizeof(Src) - 1);
  SmallVector<UTF16, 5> Result;
  bool Success = convertUTF8ToUTF16String(Ref, Result);
  EXPECT_TRUE(Success);
  static const UTF16 Expected[] = {0x0CA0, 0x005f, 0x0CA0, 0};
  ASSERT_EQ(3u, Result.size());
  for (int I = 0, E = 3; I != E; ++I)
    EXPECT_EQ(Expected[I], Result[I]);
}

TEST(ConvertUTFTest, OddLengthInput) {
  std::string Result;
  bool Success = convertUTF16ToUTF8String(makeArrayRef("xxxxx", 5), Result);
  EXPECT_FALSE(Success);
}

TEST(ConvertUTFTest, Empty) {
  std::string Result;
  bool Success = convertUTF16ToUTF8String(llvm::ArrayRef<char>(None), Result);
  EXPECT_TRUE(Success);
  EXPECT_TRUE(Result.empty());
}

TEST(ConvertUTFTest, HasUTF16BOM) {
  bool HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xff\xfe", 2));
  EXPECT_TRUE(HasBOM);
  HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xfe\xff", 2));
  EXPECT_TRUE(HasBOM);
  HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xfe\xff ", 3));
  EXPECT_TRUE(HasBOM); // Don't care about odd lengths.
  HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xfe\xff\x00asdf", 6));
  EXPECT_TRUE(HasBOM);

  HasBOM = hasUTF16ByteOrderMark(None);
  EXPECT_FALSE(HasBOM);
  HasBOM = hasUTF16ByteOrderMark(makeArrayRef("\xfe", 1));
  EXPECT_FALSE(HasBOM);
}

TEST(ConvertUTFTest, UTF16WrappersForConvertUTF16ToUTF8String) {
  // Src is the look of disapproval.
  static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
  ArrayRef<UTF16> SrcRef = makeArrayRef((const UTF16 *)Src, 4);
  std::string Result;
  bool Success = convertUTF16ToUTF8String(SrcRef, Result);
  EXPECT_TRUE(Success);
  std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
  EXPECT_EQ(Expected, Result);
}

TEST(ConvertUTFTest, ConvertUTF8toWide) {
  // Src is the look of disapproval.
  static const char Src[] = "\xe0\xb2\xa0_\xe0\xb2\xa0";
  std::wstring Result;
  bool Success = ConvertUTF8toWide((const char*)Src, Result);
  EXPECT_TRUE(Success);
  std::wstring Expected(L"\x0ca0_\x0ca0");
  EXPECT_EQ(Expected, Result);
  Result.clear();
  Success = ConvertUTF8toWide(StringRef(Src, 7), Result);
  EXPECT_TRUE(Success);
  EXPECT_EQ(Expected, Result);
}

TEST(ConvertUTFTest, convertWideToUTF8) {
  // Src is the look of disapproval.
  static const wchar_t Src[] = L"\x0ca0_\x0ca0";
  std::string Result;
  bool Success = convertWideToUTF8(Src, Result);
  EXPECT_TRUE(Success);
  std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
  EXPECT_EQ(Expected, Result);
}

struct ConvertUTFResultContainer {
  ConversionResult ErrorCode;
  std::vector<unsigned> UnicodeScalars;

  ConvertUTFResultContainer(ConversionResult ErrorCode)
      : ErrorCode(ErrorCode) {}

  ConvertUTFResultContainer
  withScalars(unsigned US0 = 0x110000, unsigned US1 = 0x110000,
              unsigned US2 = 0x110000, unsigned US3 = 0x110000,
              unsigned US4 = 0x110000, unsigned US5 = 0x110000,
              unsigned US6 = 0x110000, unsigned US7 = 0x110000) {
    ConvertUTFResultContainer Result(*this);
    if (US0 != 0x110000)
      Result.UnicodeScalars.push_back(US0);
    if (US1 != 0x110000)
      Result.UnicodeScalars.push_back(US1);
    if (US2 != 0x110000)
      Result.UnicodeScalars.push_back(US2);
    if (US3 != 0x110000)
      Result.UnicodeScalars.push_back(US3);
    if (US4 != 0x110000)
      Result.UnicodeScalars.push_back(US4);
    if (US5 != 0x110000)
      Result.UnicodeScalars.push_back(US5);
    if (US6 != 0x110000)
      Result.UnicodeScalars.push_back(US6);
    if (US7 != 0x110000)
      Result.UnicodeScalars.push_back(US7);
    return Result;
  }
};

std::pair<ConversionResult, std::vector<unsigned>>
ConvertUTF8ToUnicodeScalarsLenient(StringRef S) {
  const UTF8 *SourceStart = reinterpret_cast<const UTF8 *>(S.data());

  const UTF8 *SourceNext = SourceStart;
  std::vector<UTF32> Decoded(S.size(), 0);
  UTF32 *TargetStart = Decoded.data();

  auto ErrorCode =
      ConvertUTF8toUTF32(&SourceNext, SourceStart + S.size(), &TargetStart,
                         Decoded.data() + Decoded.size(), lenientConversion);

  Decoded.resize(TargetStart - Decoded.data());

  return std::make_pair(ErrorCode, Decoded);
}

std::pair<ConversionResult, std::vector<unsigned>>
ConvertUTF8ToUnicodeScalarsPartialLenient(StringRef S) {
  const UTF8 *SourceStart = reinterpret_cast<const UTF8 *>(S.data());

  const UTF8 *SourceNext = SourceStart;
  std::vector<UTF32> Decoded(S.size(), 0);
  UTF32 *TargetStart = Decoded.data();

  auto ErrorCode = ConvertUTF8toUTF32Partial(
      &SourceNext, SourceStart + S.size(), &TargetStart,
      Decoded.data() + Decoded.size(), lenientConversion);

  Decoded.resize(TargetStart - Decoded.data());

  return std::make_pair(ErrorCode, Decoded);
}

::testing::AssertionResult
CheckConvertUTF8ToUnicodeScalars(ConvertUTFResultContainer Expected,
                                 StringRef S, bool Partial = false) {
  ConversionResult ErrorCode;
  std::vector<unsigned> Decoded;
  if (!Partial)
    std::tie(ErrorCode, Decoded) = ConvertUTF8ToUnicodeScalarsLenient(S);
  else
    std::tie(ErrorCode, Decoded) = ConvertUTF8ToUnicodeScalarsPartialLenient(S);

  if (Expected.ErrorCode != ErrorCode)
    return ::testing::AssertionFailure() << "Expected error code "
                                         << Expected.ErrorCode << ", actual "
                                         << ErrorCode;

  if (Expected.UnicodeScalars != Decoded)
    return ::testing::AssertionFailure()
           << "Expected lenient decoded result:\n"
           << ::testing::PrintToString(Expected.UnicodeScalars) << "\n"
           << "Actual result:\n" << ::testing::PrintToString(Decoded);

  return ::testing::AssertionSuccess();
}

TEST(ConvertUTFTest, UTF8ToUTF32Lenient) {

  //
  // 1-byte sequences
  //

  // U+0041 LATIN CAPITAL LETTER A
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x0041), "\x41"));

  //
  // 2-byte sequences
  //

  // U+0283 LATIN SMALL LETTER ESH
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x0283),
      "\xca\x83"));

  // U+03BA GREEK SMALL LETTER KAPPA
  // U+1F79 GREEK SMALL LETTER OMICRON WITH OXIA
  // U+03C3 GREEK SMALL LETTER SIGMA
  // U+03BC GREEK SMALL LETTER MU
  // U+03B5 GREEK SMALL LETTER EPSILON
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK)
          .withScalars(0x03ba, 0x1f79, 0x03c3, 0x03bc, 0x03b5),
      "\xce\xba\xe1\xbd\xb9\xcf\x83\xce\xbc\xce\xb5"));

  //
  // 3-byte sequences
  //

  // U+4F8B CJK UNIFIED IDEOGRAPH-4F8B
  // U+6587 CJK UNIFIED IDEOGRAPH-6587
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x4f8b, 0x6587),
      "\xe4\xbe\x8b\xe6\x96\x87"));

  // U+D55C HANGUL SYLLABLE HAN
  // U+AE00 HANGUL SYLLABLE GEUL
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xd55c, 0xae00),
      "\xed\x95\x9c\xea\xb8\x80"));

  // U+1112 HANGUL CHOSEONG HIEUH
  // U+1161 HANGUL JUNGSEONG A
  // U+11AB HANGUL JONGSEONG NIEUN
  // U+1100 HANGUL CHOSEONG KIYEOK
  // U+1173 HANGUL JUNGSEONG EU
  // U+11AF HANGUL JONGSEONG RIEUL
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK)
          .withScalars(0x1112, 0x1161, 0x11ab, 0x1100, 0x1173, 0x11af),
      "\xe1\x84\x92\xe1\x85\xa1\xe1\x86\xab\xe1\x84\x80\xe1\x85\xb3"
      "\xe1\x86\xaf"));

  //
  // 4-byte sequences
  //

  // U+E0100 VARIATION SELECTOR-17
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x000E0100),
      "\xf3\xa0\x84\x80"));

  //
  // First possible sequence of a certain length
  //

  // U+0000 NULL
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x0000),
      StringRef("\x00", 1)));

  // U+0080 PADDING CHARACTER
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x0080),
      "\xc2\x80"));

  // U+0800 SAMARITAN LETTER ALAF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x0800),
      "\xe0\xa0\x80"));

  // U+10000 LINEAR B SYLLABLE B008 A
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x10000),
      "\xf0\x90\x80\x80"));

  // U+200000 (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf8\x88\x80\x80\x80"));

  // U+4000000 (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfc\x84\x80\x80\x80\x80"));

  //
  // Last possible sequence of a certain length
  //

  // U+007F DELETE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x007f), "\x7f"));

  // U+07FF (unassigned)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x07ff),
      "\xdf\xbf"));

  // U+FFFF (noncharacter)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xffff),
      "\xef\xbf\xbf"));

  // U+1FFFFF (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf7\xbf\xbf\xbf"));

  // U+3FFFFFF (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfb\xbf\xbf\xbf\xbf"));

  // U+7FFFFFFF (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfd\xbf\xbf\xbf\xbf\xbf"));

  //
  // Other boundary conditions
  //

  // U+D7FF (unassigned)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xd7ff),
      "\xed\x9f\xbf"));

  // U+E000 (private use)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xe000),
      "\xee\x80\x80"));

  // U+FFFD REPLACEMENT CHARACTER
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfffd),
      "\xef\xbf\xbd"));

  // U+10FFFF (noncharacter)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x10ffff),
      "\xf4\x8f\xbf\xbf"));

  // U+110000 (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf4\x90\x80\x80"));

  //
  // Unexpected continuation bytes
  //

  // A sequence of unexpected continuation bytes that don't follow a first
  // byte, every byte is a maximal subpart.

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\x80\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xbf\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\x80\xbf\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\x80\xbf\x80\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\x80\xbf\x82\xbf\xaa"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xaa\xb0\xbb\xbf\xaa\xa0"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xaa\xb0\xbb\xbf\xaa\xa0\x8f"));

  // All continuation bytes (0x80--0xbf).
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
      "\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
      "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
      "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"));

  //
  // Lonely start bytes
  //

  // Start bytes of 2-byte sequences (0xc0--0xdf).
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
      "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"));

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020),
      "\xc0\x20\xc1\x20\xc2\x20\xc3\x20\xc4\x20\xc5\x20\xc6\x20\xc7\x20"
      "\xc8\x20\xc9\x20\xca\x20\xcb\x20\xcc\x20\xcd\x20\xce\x20\xcf\x20"
      "\xd0\x20\xd1\x20\xd2\x20\xd3\x20\xd4\x20\xd5\x20\xd6\x20\xd7\x20"
      "\xd8\x20\xd9\x20\xda\x20\xdb\x20\xdc\x20\xdd\x20\xde\x20\xdf\x20"));

  // Start bytes of 3-byte sequences (0xe0--0xef).
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"));

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020),
      "\xe0\x20\xe1\x20\xe2\x20\xe3\x20\xe4\x20\xe5\x20\xe6\x20\xe7\x20"
      "\xe8\x20\xe9\x20\xea\x20\xeb\x20\xec\x20\xed\x20\xee\x20\xef\x20"));

  // Start bytes of 4-byte sequences (0xf0--0xf7).
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd,
                       0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"));

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020),
      "\xf0\x20\xf1\x20\xf2\x20\xf3\x20\xf4\x20\xf5\x20\xf6\x20\xf7\x20"));

  // Start bytes of 5-byte sequences (0xf8--0xfb).
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf8\xf9\xfa\xfb"));

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020),
      "\xf8\x20\xf9\x20\xfa\x20\xfb\x20"));

  // Start bytes of 6-byte sequences (0xfc--0xfd).
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xfc\xfd"));

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020),
      "\xfc\x20\xfd\x20"));

  //
  // Other bytes (0xc0--0xc1, 0xfe--0xff).
  //

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xc0"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xc1"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xfe"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xff"));

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xc0\xc1\xfe\xff"));

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfe\xfe\xff\xff"));

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfe\x80\x80\x80\x80\x80"));

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xff\x80\x80\x80\x80\x80"));

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0x0020, 0xfffd, 0x0020,
                       0xfffd, 0x0020, 0xfffd, 0x0020),
      "\xc0\x20\xc1\x20\xfe\x20\xff\x20"));

  //
  // Sequences with one continuation byte missing
  //

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xc2"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xdf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xe0\xa0"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xe0\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xe1\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xec\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xed\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xed\x9f"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xee\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xef\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xf0\x90\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xf0\xbf\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xf1\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xf3\xbf\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xf4\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xf4\x8f\xbf"));

  // Overlong sequences with one trailing byte missing.
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xc0"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xc1"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xe0\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xe0\x9f"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xf0\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xf0\x8f\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf8\x80\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfc\x80\x80\x80\x80"));

  // Sequences that represent surrogates with one trailing byte missing.
  // High surrogates
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xed\xa0"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xed\xac"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xed\xaf"));
  // Low surrogates
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xed\xb0"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xed\xb4"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xed\xbf"));

  // Ill-formed 4-byte sequences.
  // 11110zzz 10zzyyyy 10yyyyxx 10xxxxxx
  // U+1100xx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xf4\x90\x80"));
  // U+13FBxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xf4\xbf\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xf5\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xf6\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xf7\x80\x80"));
  // U+1FFBxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xf7\xbf\xbf"));

  // Ill-formed 5-byte sequences.
  // 111110uu 10zzzzzz 10zzyyyy 10yyyyxx 10xxxxxx
  // U+2000xx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf8\x88\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf8\xbf\xbf\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf9\x80\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfa\x80\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfb\x80\x80\x80"));
  // U+3FFFFxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfb\xbf\xbf\xbf"));

  // Ill-formed 6-byte sequences.
  // 1111110u 10uuuuuu 10uzzzzz 10zzzyyyy 10yyyyxx 10xxxxxx
  // U+40000xx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfc\x84\x80\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfc\xbf\xbf\xbf\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfd\x80\x80\x80\x80"));
  // U+7FFFFFxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfd\xbf\xbf\xbf\xbf"));

  //
  // Sequences with two continuation bytes missing
  //

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xf0\x90"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xf0\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xf1\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xf3\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xf4\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd),
      "\xf4\x8f"));

  // Overlong sequences with two trailing byte missing.
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xe0"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xf0\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xf0\x8f"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xf8\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfc\x80\x80\x80"));

  // Sequences that represent surrogates with two trailing bytes missing.
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xed"));

  // Ill-formed 4-byte sequences.
  // 11110zzz 10zzyyyy 10yyyyxx 10xxxxxx
  // U+110yxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xf4\x90"));
  // U+13Fyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xf4\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xf5\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xf6\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xf7\x80"));
  // U+1FFyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xf7\xbf"));

  // Ill-formed 5-byte sequences.
  // 111110uu 10zzzzzz 10zzyyyy 10yyyyxx 10xxxxxx
  // U+200yxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xf8\x88\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xf8\xbf\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xf9\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xfa\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xfb\x80\x80"));
  // U+3FFFyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xfb\xbf\xbf"));

  // Ill-formed 6-byte sequences.
  // 1111110u 10uuuuuu 10zzzzzz 10zzyyyy 10yyyyxx 10xxxxxx
  // U+4000yxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfc\x84\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfc\xbf\xbf\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfd\x80\x80\x80"));
  // U+7FFFFyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfd\xbf\xbf\xbf"));

  //
  // Sequences with three continuation bytes missing
  //

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xf0"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xf1"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xf2"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xf3"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xf4"));

  // Broken overlong sequences.
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xf0"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xf8\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xfc\x80\x80"));

  // Ill-formed 4-byte sequences.
  // 11110zzz 10zzyyyy 10yyyyxx 10xxxxxx
  // U+14yyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xf5"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xf6"));
  // U+1Cyyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xf7"));

  // Ill-formed 5-byte sequences.
  // 111110uu 10zzzzzz 10zzyyyy 10yyyyxx 10xxxxxx
  // U+20yyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xf8\x88"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xf8\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xf9\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xfa\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xfb\x80"));
  // U+3FCyyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xfb\xbf"));

  // Ill-formed 6-byte sequences.
  // 1111110u 10uuuuuu 10zzzzzz 10zzyyyy 10yyyyxx 10xxxxxx
  // U+400yyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xfc\x84\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xfc\xbf\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xfd\x80\x80"));
  // U+7FFCyyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xfd\xbf\xbf"));

  //
  // Sequences with four continuation bytes missing
  //

  // Ill-formed 5-byte sequences.
  // 111110uu 10zzzzzz 10zzyyyy 10yyyyxx 10xxxxxx
  // U+uzyyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xf8"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xf9"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xfa"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xfb"));
  // U+3zyyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xfb"));

  // Broken overlong sequences.
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xf8"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xfc\x80"));

  // Ill-formed 6-byte sequences.
  // 1111110u 10uuuuuu 10zzzzzz 10zzyyyy 10yyyyxx 10xxxxxx
  // U+uzzyyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xfc\x84"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xfc\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xfd\x80"));
  // U+7Fzzyyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xfd\xbf"));

  //
  // Sequences with five continuation bytes missing
  //

  // Ill-formed 6-byte sequences.
  // 1111110u 10uuuuuu 10zzzzzz 10zzyyyy 10yyyyxx 10xxxxxx
  // U+uzzyyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xfc"));
  // U+uuzzyyxx (invalid)
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd), "\xfd"));

  //
  // Consecutive sequences with trailing bytes missing
  //

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, /**/ 0xfffd, 0xfffd, /**/ 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, /**/ 0xfffd, /**/ 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xc0" "\xe0\x80" "\xf0\x80\x80"
      "\xf8\x80\x80\x80"
      "\xfc\x80\x80\x80\x80"
      "\xdf" "\xef\xbf" "\xf7\xbf\xbf"
      "\xfb\xbf\xbf\xbf"
      "\xfd\xbf\xbf\xbf\xbf"));

  //
  // Overlong UTF-8 sequences
  //

  // U+002F SOLIDUS
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x002f), "\x2f"));

  // Overlong sequences of the above.
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xc0\xaf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xe0\x80\xaf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf0\x80\x80\xaf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf8\x80\x80\x80\xaf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfc\x80\x80\x80\x80\xaf"));

  // U+0000 NULL
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x0000),
      StringRef("\x00", 1)));

  // Overlong sequences of the above.
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xc0\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xe0\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf0\x80\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf8\x80\x80\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfc\x80\x80\x80\x80\x80"));

  // Other overlong sequences.
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xc0\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xc1\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal).withScalars(0xfffd, 0xfffd),
      "\xc1\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xe0\x9f\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xed\xa0\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xed\xbf\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf0\x8f\x80\x80"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf0\x8f\xbf\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xf8\x87\xbf\xbf\xbf"));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xfc\x83\xbf\xbf\xbf\xbf"));

  //
  // Isolated surrogates
  //

  // Unicode 6.3.0:
  //
  //    D71.  High-surrogate code point: A Unicode code point in the range
  //    U+D800 to U+DBFF.
  //
  //    D73.  Low-surrogate code point: A Unicode code point in the range
  //    U+DC00 to U+DFFF.

  // Note: U+E0100 is <DB40 DD00> in UTF16.

  // High surrogates

  // U+D800
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xed\xa0\x80"));

  // U+DB40
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xed\xac\xa0"));

  // U+DBFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xed\xaf\xbf"));

  // Low surrogates

  // U+DC00
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xed\xb0\x80"));

  // U+DD00
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xed\xb4\x80"));

  // U+DFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd),
      "\xed\xbf\xbf"));

  // Surrogate pairs

  // U+D800 U+DC00
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xed\xa0\x80\xed\xb0\x80"));

  // U+D800 U+DD00
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xed\xa0\x80\xed\xb4\x80"));

  // U+D800 U+DFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xed\xa0\x80\xed\xbf\xbf"));

  // U+DB40 U+DC00
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xed\xac\xa0\xed\xb0\x80"));

  // U+DB40 U+DD00
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xed\xac\xa0\xed\xb4\x80"));

  // U+DB40 U+DFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xed\xac\xa0\xed\xbf\xbf"));

  // U+DBFF U+DC00
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xed\xaf\xbf\xed\xb0\x80"));

  // U+DBFF U+DD00
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xed\xaf\xbf\xed\xb4\x80"));

  // U+DBFF U+DFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceIllegal)
          .withScalars(0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd),
      "\xed\xaf\xbf\xed\xbf\xbf"));

  //
  // Noncharacters
  //

  // Unicode 6.3.0:
  //
  //    D14.  Noncharacter: A code point that is permanently reserved for
  //    internal use and that should never be interchanged. Noncharacters
  //    consist of the values U+nFFFE and U+nFFFF (where n is from 0 to 1016)
  //    and the values U+FDD0..U+FDEF.

  // U+FFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfffe),
      "\xef\xbf\xbe"));

  // U+FFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xffff),
      "\xef\xbf\xbf"));

  // U+1FFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x1fffe),
      "\xf0\x9f\xbf\xbe"));

  // U+1FFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x1ffff),
      "\xf0\x9f\xbf\xbf"));

  // U+2FFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x2fffe),
      "\xf0\xaf\xbf\xbe"));

  // U+2FFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x2ffff),
      "\xf0\xaf\xbf\xbf"));

  // U+3FFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x3fffe),
      "\xf0\xbf\xbf\xbe"));

  // U+3FFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x3ffff),
      "\xf0\xbf\xbf\xbf"));

  // U+4FFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x4fffe),
      "\xf1\x8f\xbf\xbe"));

  // U+4FFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x4ffff),
      "\xf1\x8f\xbf\xbf"));

  // U+5FFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x5fffe),
      "\xf1\x9f\xbf\xbe"));

  // U+5FFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x5ffff),
      "\xf1\x9f\xbf\xbf"));

  // U+6FFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x6fffe),
      "\xf1\xaf\xbf\xbe"));

  // U+6FFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x6ffff),
      "\xf1\xaf\xbf\xbf"));

  // U+7FFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x7fffe),
      "\xf1\xbf\xbf\xbe"));

  // U+7FFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x7ffff),
      "\xf1\xbf\xbf\xbf"));

  // U+8FFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x8fffe),
      "\xf2\x8f\xbf\xbe"));

  // U+8FFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x8ffff),
      "\xf2\x8f\xbf\xbf"));

  // U+9FFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x9fffe),
      "\xf2\x9f\xbf\xbe"));

  // U+9FFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x9ffff),
      "\xf2\x9f\xbf\xbf"));

  // U+AFFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xafffe),
      "\xf2\xaf\xbf\xbe"));

  // U+AFFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xaffff),
      "\xf2\xaf\xbf\xbf"));

  // U+BFFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xbfffe),
      "\xf2\xbf\xbf\xbe"));

  // U+BFFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xbffff),
      "\xf2\xbf\xbf\xbf"));

  // U+CFFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xcfffe),
      "\xf3\x8f\xbf\xbe"));

  // U+CFFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xcfffF),
      "\xf3\x8f\xbf\xbf"));

  // U+DFFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xdfffe),
      "\xf3\x9f\xbf\xbe"));

  // U+DFFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xdffff),
      "\xf3\x9f\xbf\xbf"));

  // U+EFFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xefffe),
      "\xf3\xaf\xbf\xbe"));

  // U+EFFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xeffff),
      "\xf3\xaf\xbf\xbf"));

  // U+FFFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xffffe),
      "\xf3\xbf\xbf\xbe"));

  // U+FFFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfffff),
      "\xf3\xbf\xbf\xbf"));

  // U+10FFFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x10fffe),
      "\xf4\x8f\xbf\xbe"));

  // U+10FFFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x10ffff),
      "\xf4\x8f\xbf\xbf"));

  // U+FDD0
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdd0),
      "\xef\xb7\x90"));

  // U+FDD1
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdd1),
      "\xef\xb7\x91"));

  // U+FDD2
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdd2),
      "\xef\xb7\x92"));

  // U+FDD3
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdd3),
      "\xef\xb7\x93"));

  // U+FDD4
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdd4),
      "\xef\xb7\x94"));

  // U+FDD5
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdd5),
      "\xef\xb7\x95"));

  // U+FDD6
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdd6),
      "\xef\xb7\x96"));

  // U+FDD7
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdd7),
      "\xef\xb7\x97"));

  // U+FDD8
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdd8),
      "\xef\xb7\x98"));

  // U+FDD9
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdd9),
      "\xef\xb7\x99"));

  // U+FDDA
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdda),
      "\xef\xb7\x9a"));

  // U+FDDB
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfddb),
      "\xef\xb7\x9b"));

  // U+FDDC
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfddc),
      "\xef\xb7\x9c"));

  // U+FDDD
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfddd),
      "\xef\xb7\x9d"));

  // U+FDDE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdde),
      "\xef\xb7\x9e"));

  // U+FDDF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfddf),
      "\xef\xb7\x9f"));

  // U+FDE0
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfde0),
      "\xef\xb7\xa0"));

  // U+FDE1
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfde1),
      "\xef\xb7\xa1"));

  // U+FDE2
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfde2),
      "\xef\xb7\xa2"));

  // U+FDE3
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfde3),
      "\xef\xb7\xa3"));

  // U+FDE4
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfde4),
      "\xef\xb7\xa4"));

  // U+FDE5
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfde5),
      "\xef\xb7\xa5"));

  // U+FDE6
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfde6),
      "\xef\xb7\xa6"));

  // U+FDE7
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfde7),
      "\xef\xb7\xa7"));

  // U+FDE8
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfde8),
      "\xef\xb7\xa8"));

  // U+FDE9
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfde9),
      "\xef\xb7\xa9"));

  // U+FDEA
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdea),
      "\xef\xb7\xaa"));

  // U+FDEB
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdeb),
      "\xef\xb7\xab"));

  // U+FDEC
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdec),
      "\xef\xb7\xac"));

  // U+FDED
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfded),
      "\xef\xb7\xad"));

  // U+FDEE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdee),
      "\xef\xb7\xae"));

  // U+FDEF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdef),
      "\xef\xb7\xaf"));

  // U+FDF0
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdf0),
      "\xef\xb7\xb0"));

  // U+FDF1
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdf1),
      "\xef\xb7\xb1"));

  // U+FDF2
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdf2),
      "\xef\xb7\xb2"));

  // U+FDF3
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdf3),
      "\xef\xb7\xb3"));

  // U+FDF4
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdf4),
      "\xef\xb7\xb4"));

  // U+FDF5
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdf5),
      "\xef\xb7\xb5"));

  // U+FDF6
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdf6),
      "\xef\xb7\xb6"));

  // U+FDF7
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdf7),
      "\xef\xb7\xb7"));

  // U+FDF8
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdf8),
      "\xef\xb7\xb8"));

  // U+FDF9
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdf9),
      "\xef\xb7\xb9"));

  // U+FDFA
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdfa),
      "\xef\xb7\xba"));

  // U+FDFB
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdfb),
      "\xef\xb7\xbb"));

  // U+FDFC
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdfc),
      "\xef\xb7\xbc"));

  // U+FDFD
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdfd),
      "\xef\xb7\xbd"));

  // U+FDFE
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdfe),
      "\xef\xb7\xbe"));

  // U+FDFF
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0xfdff),
      "\xef\xb7\xbf"));
}

TEST(ConvertUTFTest, UTF8ToUTF32PartialLenient) {
  // U+0041 LATIN CAPITAL LETTER A
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(conversionOK).withScalars(0x0041),
      "\x41", true));

  //
  // Sequences with one continuation byte missing
  //

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xc2", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xdf", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xe0\xa0", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xe0\xbf", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xe1\x80", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xec\xbf", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xed\x80", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xed\x9f", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xee\x80", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xef\xbf", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xf0\x90\x80", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xf0\xbf\xbf", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xf1\x80\x80", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xf3\xbf\xbf", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xf4\x80\x80", true));
  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted),
      "\xf4\x8f\xbf", true));

  EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
      ConvertUTFResultContainer(sourceExhausted).withScalars(0x0041),
      "\x41\xc2", true));
}