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:fromCharCode 18 * @tc.desc:test String.fromCharCode and charat 19 * @tc.type: FUNC 20 * @tc.require: issueI5NO8G 21 */ 22 23var str = String.fromCharCode(0); 24var str1 = String.fromCharCode(56); 25var str2 = String.fromCharCode(90); 26var str3 = String.fromCharCode(113); 27assert_equal(str1,"8"); 28assert_equal(str2,"Z"); 29assert_equal(str3,"q"); 30var obj = {}; 31obj[str1] = 'jjj1'; 32obj[str2] = 'jjj2'; 33obj[str3] = 'jjj3'; 34assert_equal(obj[8],"jjj1"); 35assert_equal(obj.Z,"jjj2"); 36assert_equal(obj.q,"jjj3"); 37 38var str4 = "wode每一天"; 39var str5 = "wodekk"; 40assert_equal(str4.charAt(4),"每"); 41assert_equal(str5.charAt(4),"k"); 42obj[str5.charAt(4)] = 'jjj4'; 43assert_equal(obj.k,"jjj4"); 44 45 46var str6 = "wojjj*432$@#$"; 47var str7 = "Π我的gljds&(%怕jfd" 48assert_equal(str6.codePointAt(3),106); 49assert_equal(str6.codePointAt(9),36); 50assert_equal(str6.codePointAt(12),36); 51assert_equal(str6.codePointAt(28),undefined); 52assert_equal(str7.codePointAt(0),928); 53assert_equal(str6.codePointAt(1),111); 54assert_equal(str6.codePointAt(12),36); 55assert_equal(str6.codePointAt(284),undefined); 56 57var str8 = "meiyou"; 58var str9 = "haodeha"; 59var str10 = "wodeyisishi"; 60assert_equal(str8.concat(str9),"meiyouhaodeha"); 61assert_equal(str8.concat(str9, str10),"meiyouhaodehawodeyisishi"); 62assert_equal(str8.concat(str9, ' hh ', str10),"meiyouhaodeha hh wodeyisishi"); 63 64var str11 = "djfaDJKLAD"; 65var str12 = "djfaDJKLADf大家发"; 66var str13 = "DJKLAD"; 67 68assert_equal(str11.toLowerCase(),"djfadjklad"); 69assert_equal(str12.toLowerCase(),"djfadjkladf大家发"); 70assert_equal(str13.toLowerCase(),"djklad"); 71 72test_end();