1/* 2 * Copyright (c) 2023 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/* 17 * @tc.name:String 18 * @tc.desc:test String 19 * @tc.type: FUNC 20 * @tc.require: issueI5NO8G 21 */ 22let tmp = '今天吃什么:告诉了会晤今天吃什么促“让今天吃什么下来好起来”今天吃今天吃什么于6月1日于北京今天吃什么面。大杂烩中国都五年来首位访华\ 23的今天吃什么王刚说,你吵的菜今天吃什么了赞不绝口,但是今天吃什么吃,他接到一个快递单号为#nsExpress3SF#123456789的包裹'; 24let flag = tmp; 25let str1 = tmp.substring(0, 111) + ',,,,,,,,,,,,,,,,,,,,,,,' + tmp.substring(111 + 23); 26let str2 = tmp.substring(0, 111) + 'nsExpress3SF#123456789的' + tmp.substring(111 + 23,111 + 24) + '需'; 27let str3 = tmp.substring(0, 111) + 'nsExpress3SF#123456789的' + tmp.substring(111 + 23); 28print((flag === str1).toString()); 29print((flag === str2).toString()); 30print((flag === str3).toString()); 31 32let utf81 = '12312463347659634287446568765344234356798653455678899865746435323456709876543679334675235523463756875153764736256\ 33235252537585734523759078945623465357867096834523523765868'; 34let utf82 = utf81.substring(0, 169) + '8'; 35let utf83 = utf81.substring(0, 169) + '0'; 36print((utf81 === utf82).toString()); 37print((utf81 === utf83).toString()); 38 39function foo(a) { 40 return a; 41} 42try { 43 for (let i = 0; i < 25; i++) { 44 foo += foo; 45 } 46} catch (e) { 47 print(e.message); 48} 49let string1 = "fdjDJSAjkdfalDDGETG"; 50let string2 = string1.substring(1); 51print(str1.charAt()); 52print(str2.charCodeAt()); 53print(str1.substr(2, 4)); 54print(string2.toLowerCase(2, 4)); 55 56 57let tmp1 = '今天吃什么:哈哈哈会晤美国phonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatform国务卿促“让今天吃什么下来好起来”今天吃今天吃什么于6月1日于北京今天吃什么面。大杂烩中国都五年来首位访华\ 58的今天吃什么王刚说,你吵的菜今天吃什么了赞不绝口,但是今天吃什么吃,他接到一个快递单号为#nsExpress3SF#123456789的包裹'; 59let flag1 = tmp1; 60let str = tmp1.substring(13, 143); 61let str4 = tmp1.substring(13, 26); 62let str5 = "phonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatform"; 63let str6 = "phonePlatform"; 64var obj = {phonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatformphonePlatform: "wode", 65phonePlatform: "wode1"}; 66 67print(obj[str]); 68print(obj[str4]); 69print((str === str5).toString()); 70print((str4 == str6).toString()); 71 72var s0 = String.fromCharCode(); 73var s1 = String.fromCharCode(65); 74var s2 = String.fromCharCode(65, 66.678); 75var s3 = String.fromCharCode(0x12014); 76var s4 = String.fromCharCode(true); 77print(s0); 78print(s1); 79print(s2); 80print(s3); 81print(s4); 82 83let name1 = 'testfiles就发(2).png'; 84let filename1 = name1.substring(0, 14); 85let kk1 = filename1.toLowerCase(); 86print(kk1); 87 88let name2 = 'testfileswodetwwwpng'; 89let filename2 = name2.substring(0, 14); 90let kk2 = filename2.toLowerCase(); 91print(kk2); 92 93var strA = name2 + name1; 94for (let i = 0; i < 100; i++) { 95strA.toLocaleString(); 96} 97print("true"); 98 99var a = ""; 100var b = a.split(""); 101var c = a.split("1"); 102print(b.length); 103print(c.length); 104var a1 = "123_352_42342_483297538927943872943_12i2"; 105var a2 = "12哈哈3尼352尼42好呀342_4832975389279你们43872943尼12i2"; 106var a3 = a2.substring(1); 107var b1 = a1.split(); 108var c1 = a1.split(""); 109var d1 = a1.split(" "); 110var e1 = a1.split("_"); 111var f1 = a1.split("_", 2); 112var g1 = a2.split("尼", 3); 113var r1 = a3.split("尼", 44); 114var k1 = a3.split("尼", 0); 115var k2 = a3.split("4", 5); 116print(b1); 117print(c1); 118print(d1); 119print(e1); 120print(f1); 121print(g1); 122print(r1); 123print(k1.length); 124print(k2); 125try { 126 var sym = Symbol(); 127 a2.split(sym, 0); 128} catch (e) { 129 print(e.message); 130} 131 132var test1 = "fun123ctionManualChapter123Tip1_352_42342_483297538927943872943_12i2哈哈哈"; 133var test2 = test1.split("_"); 134var test3 = test2[0]; 135var test4 = "1111fun123ctionManualChapter123Tip1" 136let pos = test4.indexOf(test3); 137print(pos); 138 139Object.defineProperty(Array.prototype, "1", { 140 value:37, 141 writable:false, 142}); 143var test5 = "123_wode2222222222222222_fast_哈哈哈"; 144var test6 = "123_wode2222222222222222_fast_hhh"; 145var test7 = test5.split("_"); 146var test8 = test6.split("_"); 147print(test7); 148print(test8); 149 150var test9 = "abc" 151var test10 = new Number(4); 152test10[Symbol.split] = RegExp.prototype[Symbol.split]; 153print(test9.split(test10)); 154var test11 = test1.substring(0, 31); 155var test12 = "1111fun123ctionManualChapter123Tip12222" 156var test13 = test12.split(test11); 157var test14 = test12.lastIndexOf(test11); 158print(test13); 159print(test14); 160 161let s = "abaddbdc" 162s.split("") 163let split = s.split("") 164split[0] = "0" 165print(split) 166print(s.split("")) 167s.split("b") 168split = s.split("b") 169split[2] = 1 170print(split) 171print(s.split("b")) 172s = "d的發的給的点点滴滴多" 173s.split("的") 174split = s.split("的") 175split[2] = 1 176print(split) 177print(s.split("的")) 178 179let newStr = new String("adcdcdccda") 180newStr.split("d") 181split = newStr.split("d") 182split[0] = "0" 183print(split) 184print(newStr.split("d")) 185 186var Tag = { 187 t82 : "82" 188} 189var tag1 = "823".substring(0, 2) 190var val = "val"; 191var m = new Map(); 192m.set(tag1, val); 193m.forEach((a, b)=>{ 194 print("Tag.t82 == b : ", Tag.t82 == b); 195}) 196 197try { 198 "123".padEnd(Math.pow(2, 40)) 199} catch (e) { 200 print(e) 201} 202 203print("abc".startsWith("a", Infinity)) 204print("abc".startsWith("a", -Infinity)) 205print("abc".endsWith("c", Infinity)) 206