11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// Testing api calls for string 61cb0ef41Sopenharmony_ciconst test_string = require(`./build/${common.buildType}/test_string`); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst empty = ''; 91cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1(empty), empty); 101cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8(empty), empty); 111cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16(empty), empty); 121cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1AutoLength(empty), empty); 131cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8AutoLength(empty), empty); 141cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16AutoLength(empty), empty); 151cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1External(empty), empty); 161cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16External(empty), empty); 171cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1ExternalAutoLength(empty), empty); 181cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16ExternalAutoLength(empty), empty); 191cb0ef41Sopenharmony_ciassert.strictEqual(test_string.Utf16Length(empty), 0); 201cb0ef41Sopenharmony_ciassert.strictEqual(test_string.Utf8Length(empty), 0); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciconst str1 = 'hello world'; 231cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1(str1), str1); 241cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8(str1), str1); 251cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16(str1), str1); 261cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1AutoLength(str1), str1); 271cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8AutoLength(str1), str1); 281cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16AutoLength(str1), str1); 291cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1External(str1), str1); 301cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16External(str1), str1); 311cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1ExternalAutoLength(str1), str1); 321cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16ExternalAutoLength(str1), str1); 331cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1Insufficient(str1), str1.slice(0, 3)); 341cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8Insufficient(str1), str1.slice(0, 3)); 351cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16Insufficient(str1), str1.slice(0, 3)); 361cb0ef41Sopenharmony_ciassert.strictEqual(test_string.Utf16Length(str1), 11); 371cb0ef41Sopenharmony_ciassert.strictEqual(test_string.Utf8Length(str1), 11); 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ciconst str2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; 401cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1(str2), str2); 411cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8(str2), str2); 421cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16(str2), str2); 431cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1AutoLength(str2), str2); 441cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8AutoLength(str2), str2); 451cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16AutoLength(str2), str2); 461cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1External(str2), str2); 471cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16External(str2), str2); 481cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1ExternalAutoLength(str2), str2); 491cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16ExternalAutoLength(str2), str2); 501cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1Insufficient(str2), str2.slice(0, 3)); 511cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8Insufficient(str2), str2.slice(0, 3)); 521cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16Insufficient(str2), str2.slice(0, 3)); 531cb0ef41Sopenharmony_ciassert.strictEqual(test_string.Utf16Length(str2), 62); 541cb0ef41Sopenharmony_ciassert.strictEqual(test_string.Utf8Length(str2), 62); 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ciconst str3 = '?!@#$%^&*()_+-=[]{}/.,<>\'"\\'; 571cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1(str3), str3); 581cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8(str3), str3); 591cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16(str3), str3); 601cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1AutoLength(str3), str3); 611cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8AutoLength(str3), str3); 621cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16AutoLength(str3), str3); 631cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1External(str3), str3); 641cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16External(str3), str3); 651cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1ExternalAutoLength(str3), str3); 661cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16ExternalAutoLength(str3), str3); 671cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1Insufficient(str3), str3.slice(0, 3)); 681cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8Insufficient(str3), str3.slice(0, 3)); 691cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16Insufficient(str3), str3.slice(0, 3)); 701cb0ef41Sopenharmony_ciassert.strictEqual(test_string.Utf16Length(str3), 27); 711cb0ef41Sopenharmony_ciassert.strictEqual(test_string.Utf8Length(str3), 27); 721cb0ef41Sopenharmony_ci 731cb0ef41Sopenharmony_ciconst str4 = '¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿'; 741cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1(str4), str4); 751cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8(str4), str4); 761cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16(str4), str4); 771cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1AutoLength(str4), str4); 781cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8AutoLength(str4), str4); 791cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16AutoLength(str4), str4); 801cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1External(str4), str4); 811cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16External(str4), str4); 821cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1ExternalAutoLength(str4), str4); 831cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16ExternalAutoLength(str4), str4); 841cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1Insufficient(str4), str4.slice(0, 3)); 851cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8Insufficient(str4), str4.slice(0, 1)); 861cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16Insufficient(str4), str4.slice(0, 3)); 871cb0ef41Sopenharmony_ciassert.strictEqual(test_string.Utf16Length(str4), 31); 881cb0ef41Sopenharmony_ciassert.strictEqual(test_string.Utf8Length(str4), 62); 891cb0ef41Sopenharmony_ci 901cb0ef41Sopenharmony_ciconst str5 = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ'; 911cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1(str5), str5); 921cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8(str5), str5); 931cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16(str5), str5); 941cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1AutoLength(str5), str5); 951cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8AutoLength(str5), str5); 961cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16AutoLength(str5), str5); 971cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1External(str5), str5); 981cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16External(str5), str5); 991cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1ExternalAutoLength(str5), str5); 1001cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16ExternalAutoLength(str5), str5); 1011cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestLatin1Insufficient(str5), str5.slice(0, 3)); 1021cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8Insufficient(str5), str5.slice(0, 1)); 1031cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16Insufficient(str5), str5.slice(0, 3)); 1041cb0ef41Sopenharmony_ciassert.strictEqual(test_string.Utf16Length(str5), 63); 1051cb0ef41Sopenharmony_ciassert.strictEqual(test_string.Utf8Length(str5), 126); 1061cb0ef41Sopenharmony_ci 1071cb0ef41Sopenharmony_ciconst str6 = '\u{2003}\u{2101}\u{2001}\u{202}\u{2011}'; 1081cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8(str6), str6); 1091cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16(str6), str6); 1101cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8AutoLength(str6), str6); 1111cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16AutoLength(str6), str6); 1121cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16External(str6), str6); 1131cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16ExternalAutoLength(str6), str6); 1141cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf8Insufficient(str6), str6.slice(0, 1)); 1151cb0ef41Sopenharmony_ciassert.strictEqual(test_string.TestUtf16Insufficient(str6), str6.slice(0, 3)); 1161cb0ef41Sopenharmony_ciassert.strictEqual(test_string.Utf16Length(str6), 5); 1171cb0ef41Sopenharmony_ciassert.strictEqual(test_string.Utf8Length(str6), 14); 1181cb0ef41Sopenharmony_ci 1191cb0ef41Sopenharmony_ciassert.throws(() => { 1201cb0ef41Sopenharmony_ci test_string.TestLargeUtf8(); 1211cb0ef41Sopenharmony_ci}, /^Error: Invalid argument$/); 1221cb0ef41Sopenharmony_ci 1231cb0ef41Sopenharmony_ciassert.throws(() => { 1241cb0ef41Sopenharmony_ci test_string.TestLargeLatin1(); 1251cb0ef41Sopenharmony_ci}, /^Error: Invalid argument$/); 1261cb0ef41Sopenharmony_ci 1271cb0ef41Sopenharmony_ciassert.throws(() => { 1281cb0ef41Sopenharmony_ci test_string.TestLargeUtf16(); 1291cb0ef41Sopenharmony_ci}, /^Error: Invalid argument$/); 1301cb0ef41Sopenharmony_ci 1311cb0ef41Sopenharmony_citest_string.TestMemoryCorruption(' '.repeat(64 * 1024)); 132