diff --git a/compileruntime/BUILD.gn b/compileruntime/BUILD.gn index 5fbd3642ba1d79c335e3708b32fbc206ca56f532..429d7ad4959e5336c7b43337fc1ce4cdf0439040 100644 --- a/compileruntime/BUILD.gn +++ b/compileruntime/BUILD.gn @@ -16,10 +16,14 @@ group("compileruntime") { testonly = true if (is_standard_system) { deps = [ + "convertxml_lib_standard:convertxml_js_test", "process_lib_standard:process_js_test", + "uri_lib_standard:uri_js_test", "url_lib_standard:url_js_test", "util_lib_standard:util_js_test", - "worker_lib_standard:worker_js_hap", + "xml_lib_standard:xml_js_test", + + # "worker_lib_standard:worker_js_hap", ] } } diff --git a/compileruntime/convertxml_lib_standard/BUILD.gn b/compileruntime/convertxml_lib_standard/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1f38fb7e646f3c1da04b930528e40f25701729bd --- /dev/null +++ b/compileruntime/convertxml_lib_standard/BUILD.gn @@ -0,0 +1,39 @@ +# Copyright (C) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") +ohos_js_hap_suite("convertxml_js_test") { + hap_profile = "./src/main/config.json" + js2abc = true + deps = [ + ":convertxml_js_assets", + ":convertxml_resources", + ] + + # shared_libraries = [ + # "//third_party/giflib:libgif", + # "//third_party/libpng:libpng", + # ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ConvertxmlJSApiTest" + + # part_name = "prebuilt_hap" + # subsystem_name = "xts" +} +ohos_js_assets("convertxml_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("convertxml_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/compileruntime/convertxml_lib_standard/Test.json b/compileruntime/convertxml_lib_standard/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..c7e9266d87b298625f7e433cf8da6c98b4a064a6 --- /dev/null +++ b/compileruntime/convertxml_lib_standard/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for startup convertxml js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.convertxml", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ConvertxmlJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/compileruntime/convertxml_lib_standard/signature/openharmony_sx.p7b b/compileruntime/convertxml_lib_standard/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/compileruntime/convertxml_lib_standard/signature/openharmony_sx.p7b differ diff --git a/compileruntime/convertxml_lib_standard/src/main/config.json b/compileruntime/convertxml_lib_standard/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..5b143431283839244d59ce414d968f90c1a17e5c --- /dev/null +++ b/compileruntime/convertxml_lib_standard/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "com.example.convertxml", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.convertxml", + "name": ".MyApplication", + "mainAbility": "com.example.convertxml.MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.convertxml.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": true + } + } + ] + } +} \ No newline at end of file diff --git a/compileruntime/process_lib_standard/src/ohosTest/js/default/app.js b/compileruntime/convertxml_lib_standard/src/main/js/default/app.js similarity index 70% rename from compileruntime/process_lib_standard/src/ohosTest/js/default/app.js rename to compileruntime/convertxml_lib_standard/src/main/js/default/app.js index 4952e62fd96d8dcf3eb348d293249c2a18176c85..e423f4bce4698ec1d7dc86c3eea3990a5e7b1085 100644 --- a/compileruntime/process_lib_standard/src/ohosTest/js/default/app.js +++ b/compileruntime/convertxml_lib_standard/src/main/js/default/app.js @@ -1,22 +1,23 @@ /* * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, + * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ + export default { onCreate() { - console.info('TestApplication onCreate'); + console.info('AceApplication onCreate'); }, onDestroy() { - console.info('TestApplication onDestroy'); + console.info('AceApplication onDestroy'); } }; diff --git a/compileruntime/process_lib_standard/src/ohosTest/js/default/i18n/en-US.json b/compileruntime/convertxml_lib_standard/src/main/js/default/i18n/en-US.json similarity index 77% rename from compileruntime/process_lib_standard/src/ohosTest/js/default/i18n/en-US.json rename to compileruntime/convertxml_lib_standard/src/main/js/default/i18n/en-US.json index 55561b83737c3c31d082fbfa11e5fc987a351104..e63c70d978a3a53be988388c87182f81785e170c 100644 --- a/compileruntime/process_lib_standard/src/ohosTest/js/default/i18n/en-US.json +++ b/compileruntime/convertxml_lib_standard/src/main/js/default/i18n/en-US.json @@ -2,7 +2,5 @@ "strings": { "hello": "Hello", "world": "World" - }, - "Files": { } } \ No newline at end of file diff --git a/compileruntime/util_lib_standard/src/ohosTest/js/default/i18n/zh-CN.json b/compileruntime/convertxml_lib_standard/src/main/js/default/i18n/zh-CN.json similarity index 77% rename from compileruntime/util_lib_standard/src/ohosTest/js/default/i18n/zh-CN.json rename to compileruntime/convertxml_lib_standard/src/main/js/default/i18n/zh-CN.json index cce1af06761a42add0cac1a0567aa3237eda8cb4..de6ee5748322f44942c1b003319d8e66c837675f 100644 --- a/compileruntime/util_lib_standard/src/ohosTest/js/default/i18n/zh-CN.json +++ b/compileruntime/convertxml_lib_standard/src/main/js/default/i18n/zh-CN.json @@ -2,7 +2,5 @@ "strings": { "hello": "您好", "world": "世界" - }, - "Files": { } } \ No newline at end of file diff --git a/compileruntime/convertxml_lib_standard/src/main/js/default/pages/index/index.css b/compileruntime/convertxml_lib_standard/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2b1965821483f4f8c8b97c86ef07fe87ea767d01 --- /dev/null +++ b/compileruntime/convertxml_lib_standard/src/main/js/default/pages/index/index.css @@ -0,0 +1,44 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 40px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #FFFFFF; + } +} + +@media screen and (device-type: tv) { + .container { + background-image: url("../../common/images/Wallpaper.png"); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + + .title { + font-size: 100px; + color: #FFFFFF; + } +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} diff --git a/compileruntime/process_lib_standard/src/ohosTest/js/default/pages/index/index.hml b/compileruntime/convertxml_lib_standard/src/main/js/default/pages/index/index.hml similarity index 67% rename from compileruntime/process_lib_standard/src/ohosTest/js/default/pages/index/index.hml rename to compileruntime/convertxml_lib_standard/src/main/js/default/pages/index/index.hml index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..abeadefb6faa934b6dc51d6bbcf66b765485e5ad 100644 --- a/compileruntime/process_lib_standard/src/ohosTest/js/default/pages/index/index.hml +++ b/compileruntime/convertxml_lib_standard/src/main/js/default/pages/index/index.hml @@ -1,4 +1,4 @@ -
+
{{ $t('strings.hello') }} {{ title }} diff --git a/compileruntime/util_lib_standard/src/ohosTest/js/test/ExampleJsunit.test.js b/compileruntime/convertxml_lib_standard/src/main/js/default/pages/index/index.js similarity index 57% rename from compileruntime/util_lib_standard/src/ohosTest/js/test/ExampleJsunit.test.js rename to compileruntime/convertxml_lib_standard/src/main/js/default/pages/index/index.js index d043e7e9479ed2a8e2751397c67d43c2ee8f7a08..eff21d421cc56ef14e78acefcc6a8ff275f60551 100644 --- a/compileruntime/util_lib_standard/src/ohosTest/js/test/ExampleJsunit.test.js +++ b/compileruntime/convertxml_lib_standard/src/main/js/default/pages/index/index.js @@ -13,13 +13,26 @@ * limitations under the License. */ +import file from '@system.file' import app from '@system.app' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import device from '@system.device' +import router from '@system.router' +import {Core} from 'deccjsunit/lite' -describe('appInfoTest', function () { - it('app_info_test_001', 0, function () { - var info = app.getInfo() - expect(info.versionName).assertEqual('1.0') - expect(info.versionCode).assertEqual('3') - }) -}) \ No newline at end of file +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + core.init() + require('../../../test/List.test') + core.execute() + }, + onReady() { + }, +} \ No newline at end of file diff --git a/compileruntime/process_lib_standard/src/ohosTest/js/test/List.test.js b/compileruntime/convertxml_lib_standard/src/main/js/test/List.test.js similarity index 94% rename from compileruntime/process_lib_standard/src/ohosTest/js/test/List.test.js rename to compileruntime/convertxml_lib_standard/src/main/js/test/List.test.js index 86ae9fa262b8d3fa27e4ac734dbd529d37d0b7cd..7db366a6f5705c134b5bc61ddf6c865c656dd9d5 100644 --- a/compileruntime/process_lib_standard/src/ohosTest/js/test/List.test.js +++ b/compileruntime/convertxml_lib_standard/src/main/js/test/List.test.js @@ -13,4 +13,4 @@ * limitations under the License. */ -require('./ExampleJsunit.test.js') \ No newline at end of file +require('./convertxml.test.js') \ No newline at end of file diff --git a/compileruntime/convertxml_lib_standard/src/main/js/test/convertxml.test.js b/compileruntime/convertxml_lib_standard/src/main/js/test/convertxml.test.js new file mode 100644 index 0000000000000000000000000000000000000000..43f2e870a09d1ed724a27445ada3f4a0b66bcb40 --- /dev/null +++ b/compileruntime/convertxml_lib_standard/src/main/js/test/convertxml.test.js @@ -0,0 +1,1138 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite' +import convertXml from '@ohos.convertxml' +describe('XmlTest', function () { + + /** + * @tc.name: testConvert001 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert001', 0, function () { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, spaces: 0}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert002 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert002', 0, function () { + var xml = + '' + + '' + + ' Happy ' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false,trim :true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert003 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert003', 0, function () { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreDeclaration: true}); + var str1 = '{"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert004 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert004', 0, function () { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreInstruction: true}); + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":['+ + '{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert005 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert005', 0, function () { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreAttributes: true}); + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert006 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert006', 0, function () { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreComment: true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert007 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert007', 0, function () { + var xml = + '' + + ''+ + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreComment: true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert008 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert008', 0, function () { + var xml = + '' + + '' + + ' ]]>'+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreCdata: true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert009 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert009', 0, function () { + var xml = + '' + + '' + + ' Happy' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, spaces: 4}) + var str = '{\n'+ + ' "_declaration": {\n'+ + ' "_attributes": {\n'+ + ' "version": "1.0",\n'+ + ' "encoding": "utf-8"\n'+ + ' }\n'+ + ' },\n'+ + ' "_elements": [\n'+ + ' {\n'+ + ' "_type": "element",\n'+ + ' "_name": "note",\n'+ + ' "_attributes": {\n'+ + ' "importance": "high",\n'+ + ' "logged": "true"\n'+ + ' },\n'+ + ' "_elements": [\n'+ + ' {\n'+ + ' "_type": "element",\n'+ + ' "_name": "title",\n'+ + ' "_elements": [\n'+ + ' {\n'+ + ' "_type": "text",\n'+ + ' "_text": "Happy"\n'+ + ' }\n'+ + ' ]\n'+ + ' }\n'+ + ' ]\n'+ + ' }\n'+ + ' ]\n'+ + '}' + expect(result1).assertEqual(str); + }) + + /** + * @tc.name: testConvert010 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert010', 0, function () { + var xml = + '' + + ''+ + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreDoctype: true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert011 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert011', 0, function () { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, ignoreText: true}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title"},'+ + '{"_type":"element",'+ + '"_name":"todo"},'+ + '{"_type":"element",'+ + '"_name":"todo"}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert012 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert012', 0, function () { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, declarationKey: "123"}) + var str1 = '{"123":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert013 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert013', 0, function () { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, instructionKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"123":"there",'+ + '"_type":"instruction",'+ + '"_name":"go"},'+ + '{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert014 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert014', 0, function () { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, attributesKey: "123"}) + var str1 = '{"_declaration":{"123":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"123":{"importance":"high",'+ + '"logged":"true"},'+ + '"_type":"element",'+ + '"_name":"note",'+ + '"_elements":[{"_type":"instruction",'+ + '"_name":"go",'+ + '"_instruction":"there"},'+ + '{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert015 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert015', 0, function () { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, textKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"123":"Happy",'+ + '"_type":"text"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"123":"Work",'+ + '"_type":"text"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"123":"Play",'+ + '"_type":"text"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert016 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert016', 0, function () { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, cdataKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"123":"1 is < 2",'+ + '"_type":"cdata"},'+ + '{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert017 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert017', 0, function () { + var xml = + '' + + ''+ + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, commentKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"123":"note",'+ + '"_type":"comment"},'+ + '{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert018 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert018', 0, function () { + var xml = + '' + + '' + + ' '+ + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, parentKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"_type":"element",'+ + '"_name":"a",'+ + '"_elements":[{"_type":"element",'+ + '"_name":"b"}]},'+ + '{"_type":"element",'+ + '"_name":"title",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"_type":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert019 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert019', 0, function () { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, typeKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"123":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"123":"element",'+ + '"_name":"title",'+ + '"_elements":[{"123":"text",'+ + '"_text":"Happy"}]},'+ + '{"123":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"123":"text",'+ + '"_text":"Work"}]},'+ + '{"123":"element",'+ + '"_name":"todo",'+ + '"_elements":[{"123":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert020 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert020', 0, function () { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, nameKey: "123"}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}},'+ + '"_elements":[{"123":"note",'+ + '"_type":"element",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"},'+ + '"_elements":[{"123":"title",'+ + '"_type":"element",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Happy"}]},'+ + '{"123":"todo",'+ + '"_type":"element",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Work"}]},'+ + '{"123":"todo",'+ + '"_type":"element",'+ + '"_elements":[{"_type":"text",'+ + '"_text":"Play"}]}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert021 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert021', 0, function () { + var xml = + '' + + '' + + ' Happy' + + ' Work' + + ' Play' + + ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false, elementsKey: "123"}) + var str1 = '{"123":[{"123":[{"123":[{"_type":"text",'+ + '"_text":"Happy"}],'+ + '"_type":"element",'+ + '"_name":"title"},'+ + '{"123":[{"_type":"text",'+ + '"_text":"Work"}],'+ + '"_type":"element",'+ + '"_name":"todo"},'+ + '{"123":[{"_type":"text",'+ + '"_text":"Play"}],'+ + '"_type":"element",'+ + '"_name":"todo"}],'+ + '"_type":"element",'+ + '"_name":"note",'+ + '"_attributes":{"importance":"high",'+ + '"logged":"true"}}],'+ + '"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}}}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert022 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert022', 0, function () { + var xml = ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_declaration":{}}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert023 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert023', 0, function () { + var xml = ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_declaration":{"_attributes":{"version":"1.0",'+ + '"encoding":"utf-8"}}}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert024 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert024', 0, function () { + var xml = '\n'; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_declaration":{},"_elements":[{"_type":"element","_name":"a"}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert025 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert025', 0, function () { + var xml = ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_elements":[{"_type":"instruction",'+ + '"_name":"go",'+ + '"_instruction":"there"}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert026 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert026', 0, function () { + var xml = ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_elements":[{"_type":"instruction",'+ + '"_name":"go",'+ + '"_instruction":"there"},'+ + '{"_type":"instruction",'+ + '"_name":"come",'+ + '"_instruction":"here"}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert027 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert027', 0, function () { + var xml = ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_elements":[{"_type":"comment","_comment":"'+ + ' \t'+ + ' Hello '+ + 'World! '+ + '\t '+ + '"}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert028 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert028', 0, function () { + var xml = '\n'; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_elements":[{"_type":"comment","_comment":"'+ + ' \t'+ + ' Hello '+ + '\t '+ + '"},{"_type":"comment","_comment":"'+ + ' \t'+ + ' World '+ + '\t '+ + '"}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert029 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert029', 0, function () { + var xml = ' \t ]]>'; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_elements":[{"_type":"cdata","_cdata":"'+ + ' \t'+ + ' '+ + '\t '+ + '"}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert030 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert030', 0, function () { + var xml = ' " and & \t ]]>'; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_elements":[{"_type":"cdata","_cdata":"'+ + ' \t'+ + ' data"},{"_type":"cdata","_cdata":"< '+ + '> '+ + '"'+ + ' and'+ + ' & '+ + '\t '+ + '"}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert031 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert031', 0, function () { + var xml = ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_elements":[{"_type":"element",'+ + '"_name":"a"}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert032 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert032', 0, function () { + var xml = '\n'; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact : false}) + var str1 = '{"_elements":[{"_type":"element",'+ + '"_name":"a"},'+ + '{"_type":"element",'+ + '"_name":"a"}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert033 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert033', 0, function () { + var xml = '\n'; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_elements":[{"_type":"element",'+ + '"_name":"a"},'+ + '{"_type":"element",'+ + '"_name":"b"}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert034 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert034', 0, function () { + var xml = ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_elements":[{"_type":"element",'+ + '"_name":"a",'+ + '"_attributes":{"x":"hello"}}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert035 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert035', 0, function () { + var xml = ''; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_elements":[{"_type":"element",'+ + '"_name":"a",'+ + '"_attributes":{"x":"1.234",'+ + '"y":"It\'s"}}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert036 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert036', 0, function () { + var xml = ' \t Hi \t '; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_elements":[{"_type":"element","_name":"a","_elements":[{"_type":"text","_text":"'+ + ' \t'+ + ' Hi '+ + '\t '+ + '"}]}]}'; + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert037 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert037', 0, function () { + var xml = ' Hi There \t '; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_elements":[{"_type":"element","_name":"a","_elements":[{"_type":"text","_text":"'+ + ' Hi '+ + ' There '+ + '\t '+ + '"}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert038 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert038', 0, function () { + var xml = '\n\v\n'; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_elements":[{"_type":"element",'+ + '"_name":"a",'+ + '"_elements":[{"_type":"element",'+ + '"_name":"b"}]}]}' + expect(result1).assertEqual(str1); + }) + + /** + * @tc.name: testConvert039 + * @tc.desc: To convert XML text to JavaScript object. + * @tc.require: AR000GFB5B + * @tc.author: lihucheng + */ + it('testConvert039', 0, function () { + var xml = '\n\v\n\v\v\n\v\n'; + var convertml = new convertXml.ConvertXML(); + var result1 = convertml.convert(xml, {compact: false}) + var str1 = '{"_elements":[{"_type":"element",'+ + '"_name":"a",'+ + '"_elements":[{"_type":"element",'+ + '"_name":"b",'+ + '"_elements":[{"_type":"element",'+ + '"_name":"c"}]}]}]}' + expect(result1).assertEqual(str1); + }) +}) + + + + + diff --git a/compileruntime/convertxml_lib_standard/src/main/resources/base/element/string.json b/compileruntime/convertxml_lib_standard/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0bae6bd40f7360d5d818998221b199d3ec0f69c0 --- /dev/null +++ b/compileruntime/convertxml_lib_standard/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/compileruntime/convertxml_lib_standard/src/main/resources/base/media/icon.png b/compileruntime/convertxml_lib_standard/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/compileruntime/convertxml_lib_standard/src/main/resources/base/media/icon.png differ diff --git a/compileruntime/process_lib_standard/BUILD.gn b/compileruntime/process_lib_standard/BUILD.gn index 101287b11b830e124182667d9fd266141270f46f..775d20038d210f66bf320f1ca1b2778d77bc106c 100644 --- a/compileruntime/process_lib_standard/BUILD.gn +++ b/compileruntime/process_lib_standard/BUILD.gn @@ -12,16 +12,25 @@ # limitations under the License. import("//test/xts/tools/build/suite.gni") - ohos_js_hap_suite("process_js_test") { hap_profile = "./src/main/config.json" + js2abc = true deps = [ ":process_js_assets", ":process_resources", ] + + # shared_libraries = [ + # "//third_party/giflib:libgif", + # "//third_party/libpng:libpng", + # ] certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsProcessJSApiTest" + hap_name = "ProcessJSApiTest" + + # part_name = "prebuilt_hap" + # subsystem_name = "xts" } + ohos_js_assets("process_js_assets") { source_dir = "./src/main/js/default" } diff --git a/compileruntime/process_lib_standard/Test.json b/compileruntime/process_lib_standard/Test.json index a16a95a3396de3d5a4008b42e48ae9491d338e91..58980316e8915f8eea5c050347c26b97f1ab9773 100644 --- a/compileruntime/process_lib_standard/Test.json +++ b/compileruntime/process_lib_standard/Test.json @@ -9,7 +9,7 @@ "kits": [ { "test-file-name": [ - "ActsProcessJSApiTest.hap" + "ProcessJSApiTest.hap" ], "type": "AppInstallKit", "cleanup-apps": true diff --git a/compileruntime/process_lib_standard/src/main/config.json b/compileruntime/process_lib_standard/src/main/config.json index 75d1ac14458c1ede210bf40739cb9c9fc80e74b4..ea64f225527c8679e6fc21b969b83ba2b045115a 100644 --- a/compileruntime/process_lib_standard/src/main/config.json +++ b/compileruntime/process_lib_standard/src/main/config.json @@ -5,6 +5,10 @@ "version": { "code": 1000000, "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 } }, "deviceConfig": {}, diff --git a/compileruntime/process_lib_standard/src/main/java/com/example/childprocess/MainAbility.java b/compileruntime/process_lib_standard/src/main/java/com/example/childprocess/MainAbility.java deleted file mode 100644 index dbdddf742e23f2568178756f1cea558603671535..0000000000000000000000000000000000000000 --- a/compileruntime/process_lib_standard/src/main/java/com/example/childprocess/MainAbility.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.childprocess; - -import ohos.ace.ability.AceAbility; -import ohos.aafwk.content.Intent; - -public class MainAbility extends AceAbility { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - } - - @Override - public void onStop() { - super.onStop(); - } -} diff --git a/compileruntime/process_lib_standard/src/main/java/com/example/childprocess/MyApplication.java b/compileruntime/process_lib_standard/src/main/java/com/example/childprocess/MyApplication.java deleted file mode 100644 index bf24a9676c68a8c8fe00508525160c66d0378e80..0000000000000000000000000000000000000000 --- a/compileruntime/process_lib_standard/src/main/java/com/example/childprocess/MyApplication.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.childprocess; - -import ohos.aafwk.ability.AbilityPackage; - -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/compileruntime/process_lib_standard/src/main/js/default/pages/index/index.hml b/compileruntime/process_lib_standard/src/main/js/default/pages/index/index.hml index 9f0aae944b86533183d4307b741c7c237e6457a1..20a4e40d9a4ee698bf8e485840457dd43233a376 100644 --- a/compileruntime/process_lib_standard/src/main/js/default/pages/index/index.hml +++ b/compileruntime/process_lib_standard/src/main/js/default/pages/index/index.hml @@ -2,5 +2,4 @@ {{ $t('strings.hello') }} {{title}} -
\ No newline at end of file diff --git a/compileruntime/process_lib_standard/src/main/js/test/ExampleJsunit.test.js b/compileruntime/process_lib_standard/src/main/js/test/ExampleJsunit.test.js deleted file mode 100644 index 426966658ed8171651ffdf61b361c24fc0c90b60..0000000000000000000000000000000000000000 --- a/compileruntime/process_lib_standard/src/main/js/test/ExampleJsunit.test.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import app from '@system.app' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite' - -describe('appInfoTest', function () { - it('app_info_test_001', 0, function () { - var info = app.getInfo() - expect(info.versionCode).assertEqual('1000000') - }) -}) \ No newline at end of file diff --git a/compileruntime/process_lib_standard/src/main/js/test/List.test.js b/compileruntime/process_lib_standard/src/main/js/test/List.test.js index ccd2b4ce70fe504d549a4bae9286c851ba3a04e2..8999be239e22f86496965016a9715bc9b599319f 100644 --- a/compileruntime/process_lib_standard/src/main/js/test/List.test.js +++ b/compileruntime/process_lib_standard/src/main/js/test/List.test.js @@ -13,5 +13,4 @@ * limitations under the License. */ -require('./ExampleJsunit.test.js') require('./Process.test.js') \ No newline at end of file diff --git a/compileruntime/process_lib_standard/src/main/js/test/Process.test.js b/compileruntime/process_lib_standard/src/main/js/test/Process.test.js index 9c24724ad7989cb06c8d7a6e055048b118cd81b7..b46aebca4fef6d667b630cdc7b5b3c2b0ea7cd85 100644 --- a/compileruntime/process_lib_standard/src/main/js/test/Process.test.js +++ b/compileruntime/process_lib_standard/src/main/js/test/Process.test.js @@ -12,1780 +12,1611 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite' import process from '@ohos.process' +describe('ChildProcessTest', function () { + + /** + * @tc.name: testRunCmd001 + * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testRunCmd001', 0, async function () { + var child = process.runCmd('echo abc') + child.wait() + var array = new Uint8Array([97, 98, 99, 10, 0]) + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testRunCmd002 + * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testRunCmd002', 0, async function () { + var child = process.runCmd('echo abc;', { maxBuffer : 2 }) + child.wait() + var array = new Uint8Array([97, 98, 0]) + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testRunCmd003 + * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testRunCmd003', 0, async function () { + var child = process.runCmd('sleep 5; echo abc;', { timeout : 1, killSignal : 9 }) + child.wait() + var array = new Uint8Array([0]) + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + expect(child.exitCode).assertEqual(0) + }) + + /** + * @tc.name: testRunCmd004 + * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testRunCmd004', 0, async function ( ) { + var child = process.runCmd('sleep 2; echo abc;', { timeout : 9000, killSignal : 9 }) + child.wait() + var array = new Uint8Array([97, 98, 99, 10, 0]) + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + expect(child.exitCode).assertEqual(0) + }) + + /** + * @tc.name: testRunCmd005 + * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testRunCmd005', 0, async function ( ) { + var child = process.runCmd('echo abc', { maxBuffer : 1000 }) + child.wait() + var array = new Uint8Array([97, 98, 99, 10, 0]) + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testGetOutput001 + * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetOutput001', 0, async function () { + var child = process.runCmd('echo bcd;') + var array = new Uint8Array([98, 99, 100, 10, 0]) + child.wait(); + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testGetOutput002 + * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetOutput002', 0, async function () { + var child = process.runCmd('echo 123;'); + var array = new Uint8Array([49, 50, 51, 10, 0]); + child.wait(); + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]); + } + }) + }) + + /** + * @tc.name: testGetOutput003 + * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetOutput003', 0, async function () { + var child = process.runCmd('echo helloWorld;'); + var array = new Uint8Array([104, 101, 108, 108, 111, 87, 111, 114, 108, 100, 10, 0]); + child.wait(); + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]); + } + }) + }) + + /** + * @tc.name: testGetOutput004 + * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetOutput004', 0, async function () { + var child = process.runCmd('echo 浣犲?'); + var array = new Uint8Array([228, 189, 160, 229, 165, 189, 10, 0]); + child.wait(); + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]); + } + }) + }) + + /** + * @tc.name: testGetOutput005 + * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetOutput005', 0, async function () { + var child = process.runCmd('echo ~_~;'); + var array = new Uint8Array([126, 95, 126, 10, 0]); + child.wait(); + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]); + } + }) + }) + + /** + * @tc.name: testGetErrorOutput001 + * @tc.desc: return it as 'Uint8Array of the stderr until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetErrorOutput001', 0, async function () { + var child = process.runCmd('makdir 1.txt') + child.wait() + var array = new Uint8Array([115, 104, 58, 32, 109, 97, 107, 100, 105, 114, 58, 32, 105, 110, 97, 99, 99, + 101, 115, 115, 105, 98, 108, 101, 32, 111, 114, 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 10, 0]) + child.getErrorOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testGetErrorOutput002 + * @tc.desc: return it as 'Uint8Array of the stderr until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetErrorOutput002', 0, async function () { + var child = process.runCmd('echo "error" 1>&2') + child.wait() + var array = new Uint8Array([101, 114, 111, 114, 10, 0]) + child.getErrorOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testGetErrorOutput003 + * @tc.desc: return it as 'Uint8Array of the stderr until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetErrorOutput003', 0, async function () { + var child = process.runCmd('1') + child.wait() + var array = new Uint8Array([115, 104, 58, 32, 49, 58, 32, 105, 110, 97, 99, 99, 101, 115, 115, 105, 98, + 108, 101, 32, 111, 114, 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 10, 0]) + child.getErrorOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testGetErrorOutput004 + * @tc.desc: return it as 'Uint8Array of the stderr until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetErrorOutput004', 0, async function () { + var child = process.runCmd('chmod 777 123') + var array = new Uint8Array([99, 104, 109, 111, 100, 58, 32, 49, 50, 51, 58, 32, 78, 111, 32, 115, 117, 99, + 104, 32, 102, 105, 108, 101, 32, 111, 114, 32, 100, 105, 114, 101, 99, 116, 111, 114, 121, 10, 0]); + child.wait(); + child.getErrorOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testGetErrorOutput005 + * @tc.desc: return it as 'Uint8Array of the stderr until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetErrorOutput005', 0, async function () { + var child = process.runCmd('cp ./1 ./2') + var array = new Uint8Array([99, 112, 58, 32, 98, 97, 100, 32, 39, 46, 47, 49, 39, 58, 32, 78, 111, 32, 115, + 117, 99, 104, 32, 102, 105, 108, 101, 32, 111, 114, 32, 100, 105, 114, 101, 99, 116, 111, 114, 121, 10, 0]) + child.wait(); + child.getErrorOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testWait001 + * @tc.desc: return 'number' is the targer process exit code. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testWait001', 0, async function () { + var child = process.runCmd('ls') + var status = child.wait() + status.then(val=>{ + expect(val).assertEqual(0) + }) + }) + + /** + * @tc.name: testWait002 + * @tc.desc: return 'number' is the targer process exit code. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testWait002', 0, async function () { + var child = process.runCmd('ls; sleep 5;') + child.kill(9); + var status = child.wait() + status.then(val=>{ + expect(val).assertEqual(9) + }) + }) + + /** + * @tc.name: testWait003 + * @tc.desc: return 'number' is the targer process exit code. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testWait003', 0, async function () { + var child = process.runCmd('echo helloWorld'); + var status = child.wait(); + status.then(val=>{ + expect(val).assertEqual(0); + }) + }) + + /** + * @tc.name: testWait004 + * @tc.desc: return 'number' is the targer process exit code. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testWait004', 0, async function () { + var child = process.runCmd('mkdir 123'); + var status = child.wait(); + status.then(val=>{ + expect(val).assertEqual(256); + }) + }) + + /** + * @tc.name: testWait005 + * @tc.desc: return 'number' is the targer process exit code. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testWait005', 0, async function () { + var child = process.runCmd('sleep 5; echo abc;', { timeout : 1, killSignal : 9 }); + var status = child.wait(); + status.then(val=>{ + expect(val).assertEqual(9); + }) + }) + + /** + * @tc.name: testchildPid001 + * @tc.desc: return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testchildPid001', 0, function () { + var child = process.runCmd('ls; sleep 5;') + child.wait() + var pid_ = child.pid + expect(pid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPid002 + * @tc.desc: return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid002', 0, function () { + var child = process.runCmd('mkdir test.cpp') + child.wait() + var pid_ = child.pid + expect(pid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPid003 + * @tc.desc: return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid003', 0, function () { + var child = process.runCmd('each abc') + child.wait() + var pid_ = child.pid + expect(pid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPid004 + * @tc.desc: return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid004', 0, function () { + var child = process.runCmd('cd ..') + child.wait() + var pid_ = child.pid + expect(pid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPid005 + * @tc.desc: return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid005', 0, function () { + var child = process.runCmd('adc') + child.wait() + var pid_ = child.pid + expect(pid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPpid001 + * @tc.desc: return ppid is the pid of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid001', 0, function () { + var child = process.runCmd('ls; sleep 5;') + var status = child.wait() + var ppid_ = child.ppid + expect(ppid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPpid002 + * @tc.desc: return ppid is the pid of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid002', 0, function () { + var child = process.runCmd('mkdir test.cpp') + child.wait() + var ppid_ = child.ppid + expect(ppid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPpid003 + * @tc.desc: return ppid is the pid of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid003', 0, function () { + var child = process.runCmd('each abc') + child.wait() + var ppid_ = child.ppid + expect(ppid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPpid004 + * @tc.desc: return ppid is the pid of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid004', 0, function () { + var child = process.runCmd('cd ..') + child.wait() + var ppid_ = child.ppid + expect(ppid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPpid005 + * @tc.desc: return ppid is the pid of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid005', 0, function () { + var child = process.runCmd('adc') + child.wait() + var ppid_ = child.ppid + expect(ppid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testKill001 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill001', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var result = child.kill(13) + var temp = child.killed + expect(temp).assertEqual(true) + }) + + /** + * @tc.name: testKill002 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill002', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var result = child.kill(1) + var temp = child.killed + expect(temp).assertEqual(true) + }) + + /** + * @tc.name: testKill003 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill003', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var result = child.kill('SIGHUP') + var temp = child.killed + expect(temp).assertEqual(true) + }) + + /** + * @tc.name: testKill004 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill004', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var result = child.kill('ABC') + var temp = child.killed + expect(temp).assertEqual(true) + }) + + /** + * @tc.name: testKill005 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill005', 0, function () { + var child = process.runCmd('ls') + child.wait() + var result = child.kill(9) + var temp = child.killed + expect(temp).assertEqual(false) + }) + + /** + * @tc.name: testClose001 + * @tc.desc: close the target process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testClose001', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var result = child.close() + expect(child.exitCode).assertEqual(9) + }) + + /** + * @tc.name: testClose002 + * @tc.desc: close the target process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testClose002', 0, function () { + var child = process.runCmd('ls') + function sleep(ms, callback) { + setTimeout(callback, ms) + } + sleep(1000, () => {} ) + var result = child.close() + expect(child.exitCode === 0).assertEqual(false) + }) + + /** + * @tc.name: testClose003 + * @tc.desc: close the target process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testClose003', 0, function () { + var child = process.runCmd('ls;') + var status = child.wait() + var result = child.close() + expect(child.exitCode).assertEqual(0) + }) + + /** + * @tc.name: testClose004 + * @tc.desc: close the target process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testClose004', 0, function () { + var child = process.runCmd('ls') + var result = child.close() + expect(child.exitCode).assertEqual(9) + }) + + /** + * @tc.name: testClose005 + * @tc.desc: close the target process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testClose005', 0, function () { + var child = process.runCmd('sleep 5; echo A') + var result = child.close() + var status = child.wait() + expect(child.exitCode).assertEqual(9) + }) + + /** + * @tc.name: testKilled001 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKilled001', 0, function () { + var child = process.runCmd('ls; sleep 1s;') + var result = child.kill(3) + var temp = child.killed + expect(temp).assertEqual(true) + }) + + /** + * @tc.name: testKilled002 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKilled002', 0, function () { + var child = process.runCmd('ls; sleep 1s;') + var result = child.close() + var temp = child.killed + expect(temp).assertEqual(false) + }) + + /** + * @tc.name: testKilled003 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKilled003', 0, function () { + var child = process.runCmd('ls; sleep 1s;') + var status = child.wait() + var result = child.kill(9) + var temp = child.killed + expect(temp).assertEqual(false) + }) + + /** + * @tc.name: testKilled004 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKilled004', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var result = child.kill('SIGHUP') + var temp = child.killed + expect(temp).assertEqual(true) + }) + + /** + * @tc.name: testKilled005 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKilled005', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var result = child.kill('1') + var temp = child.killed + expect(temp).assertEqual(true) + }) + + /** + * @tc.name: testExitCode001 + * @tc.desc: return exitCode is the exit code of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testExitCode001', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var temp = child.kill(9) + child.wait() + var result = child.exitCode + expect(result).assertEqual(9) + }) + + /** + * @tc.name: testExitCode002 + * @tc.desc: return exitCode is the exit code of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testExitCode002', 0, function () { + var child = process.runCmd('ls;') + child.wait() + var result = child.exitCode + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testExitCode003 + * @tc.desc: return exitCode is the exit code of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testExitCode003', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + child.close() + child.wait() + var result = child.exitCode + expect(result).assertEqual(9) + }) + + /** + * @tc.name: testExitCode004 + * @tc.desc: return exitCode is the exit code of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testExitCode004', 0, function () { + var child = process.runCmd('ls') + var temp = child.kill('ABCD') + child.close() + var result = child.exitCode + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testExitCode005 + * @tc.desc: return exitCode is the exit code of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testExitCode005', 0, function () { + var child = process.runCmd('echo A') + var result= child.wait() + var status = child.close() + expect(child.exitCode).assertEqual(0) + }) + + /** + * @tc.name: testGetUid001 + * @tc.desc: returns the digital user id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetUid001', 0, function () { + var result = process.uid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetUid002 + * @tc.desc: returns the digital user id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetUid002', 0, function () { + for(var i = 0; i < 3; i++){ + var result = process.uid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetUid003 + * @tc.desc: returns the digital user id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetUid003', 0, function () { + for(var i = 0; i < 6; i++){ + var result = process.uid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetUid004 + * @tc.desc: returns the digital user id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetUid004', 0, function () { + for(var i = 0; i < 10; i++){ + var result = process.uid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetUid005 + * @tc.desc: returns the digital user id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetUid005', 0, function () { + for(var i = 0; i < 25; i++){ + var result = process.uid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGid001 + * @tc.desc: returns the numeric group id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGid001', 0, function () { + var result = process.gid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetGid002 + * @tc.desc: returns the numeric group id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGid002', 0, function () { + for(var i = 0; i < 3; i++){ + var result = process.gid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGid003 + * @tc.desc: returns the numeric group id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGid003', 0, function () { + for(var i = 0; i < 5; i++){ + var result = process.gid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGid004 + * @tc.desc: returns the numeric group id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGid004', 0, function () { + for(var i = 0; i < 10; i++){ + var result = process.gid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGid005 + * @tc.desc: returns the numeric group id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGid005', 0, function () { + for(var i = 0; i < 9; i++){ + var result = process.gid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEuid001 + * @tc.desc: return the numeric valid user identity of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEuid001', 0, function () { + var result = process.euid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetEuid002 + * @tc.desc: return the numeric valid user identity of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEuid002', 0, function () { + for(var i = 0; i < 3; i++){ + var result = process.euid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEuid003 + * @tc.desc: return the numeric valid user identity of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEuid003', 0, function () { + for(var i = 0; i < 5; i++){ + var result = process.euid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEuid004 + * @tc.desc: return the numeric valid user identity of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEuid004', 0, function () { + for(var i = 0; i < 8; i++){ + var result = process.euid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEuid005 + * @tc.desc: return the numeric valid user identity of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEuid005', 0, function () { + for(var i = 0; i < 15; i++){ + var result = process.euid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) -describe('ChildProcessTest', function () { + /** + * @tc.name: testGetEgid001 + * @tc.desc: returns the numeric valid group ID of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEgid001', 0, function () { + var result = process.egid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + }) - /** - * @tc.name: testRunCmd001 - * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testRunCmd001', 0, async function (done) { - console.log("test start +++") - var child = process.runCmd('echo abc') - console.log("test start +++ 11111") - child.wait() - console.log("test start +++ 2222") - var res = new Uint8Array([97, 98, 99, 10, 0]) - console.log("test start +++ 333") - await child.getOutput().then(val=>{ - console.log("test_runCmd_00" + val) - for (var i = 0; i < res.length; i++) { - console.log("test then array [i]= " + res[i]); - console.log("test then val [i]= " + val[i]); - expect(val[i]).assertEqual(res[i]) - } - }) - done(); - }) - - /** - * @tc.name: testRunCmd002 - * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testRunCmd002', 0, async function (done) { - var child = process.runCmd('echo abc;', { maxBuffer : 2 }) - child.wait() - var array = new Uint8Array([97, 98, 0]) - await child.getOutput().then(val=>{ - for (var i = 0; i < array.length; i++) { - expect(val[i]).assertEqual(array[i]) - } - }) - done() - }) - - /** - * @tc.name: testRunCmd003 - * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testRunCmd003', 0, async function () { - var child = process.runCmd('sleep 5; echo abc;', { timeout : 1, killSignal : 9 }) - child.wait() - var array = new Uint8Array([0]) - child.getOutput().then(val=>{ - for (var i = 0; i < array.length; i++) { - expect(val[i]).assertEqual(array[i]) - } - }) - expect(child.exitCode).assertEqual(9) - }) - - /** - * @tc.name: testRunCmd004 - * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testRunCmd004', 0, async function ( ) { - var child = process.runCmd('sleep 2; echo abc;', { timeout : 9000, killSignal : 9 }) - child.wait() - var array = new Uint8Array([97, 98, 99, 10, 0]) - child.getOutput().then(val=>{ - for (var i = 0; i < array.length; i++) { - expect(val[i]).assertEqual(array[i]) - } - }) - expect(child.exitCode).assertEqual(0) - }) - - /** - * @tc.name: testRunCmd005 - * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testRunCmd005', 0, async function ( ) { - var child = process.runCmd('echo abc', { maxBuffer : 1000 }) - child.wait() - var array = new Uint8Array([97, 98, 99, 10, 0]) - child.getOutput().then(val=>{ - for (var i = 0; i < array.length; i++) { - expect(val[i]).assertEqual(array[i]) - } - }) - }) - - /** - * @tc.name: testGetOutput001 - * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetOutput001', 0, async function () { - var child = process.runCmd('echo bcd;') - var array = new Uint8Array([98, 99, 100, 10, 0]) - child.wait(); - child.getOutput().then(val=>{ - for (var i = 0; i < array.length; i++) { - expect(val[i]).assertEqual(array[i]) - } - }) - }) - - /** - * @tc.name: testGetOutput002 - * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetOutput002', 0, async function () { - var child = process.runCmd('echo 123;'); - var array = new Uint8Array([49, 50, 51, 10, 0]); - child.wait(); - child.getOutput().then(val=>{ - for (var i = 0; i < array.length; i++) { - expect(val[i]).assertEqual(array[i]); - } - }) - }) - - /** - * @tc.name: testGetOutput003 - * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetOutput003', 0, async function () { - var child = process.runCmd('echo helloWorld;'); - var array = new Uint8Array([104, 101, 108, 108, 111, 87, 111, 114, 108, 100, 10, 0]); - child.wait(); - child.getOutput().then(val=>{ - for (var i = 0; i < array.length; i++) { - expect(val[i]).assertEqual(array[i]); - } - }) - }) - - /** - * @tc.name: testGetOutput004 - * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetOutput004', 0, async function () { - var child = process.runCmd('echo 你好;'); - var array = new Uint8Array([228, 189, 160, 229, 165, 189, 10, 0]); - child.wait(); - child.getOutput().then(val=>{ - for (var i = 0; i < array.length; i++) { - expect(val[i]).assertEqual(array[i]); - } - }) - }) - - /** - * @tc.name: testGetOutput005 - * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetOutput005', 0, async function () { - var child = process.runCmd('echo ~_~;'); - var array = new Uint8Array([126, 95, 126, 10, 0]); - child.wait(); - child.getOutput().then(val=>{ - for (var i = 0; i < array.length; i++) { - expect(val[i]).assertEqual(array[i]); - } - }) - }) - - /** - * @tc.name: testGetErrorOutput001 - * @tc.desc: return it as 'Uint8Array of the stderr until EOF. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetErrorOutput001', 0, async function () { - var child = process.runCmd('makdir 1.txt') - child.wait() - var array = new Uint8Array([115, 104, 58, 32, 109, 97, 107, 100, 105, 114, 58, 32, 105, 110, 97, 99, 99, - 101, 115, 115, 105, 98, 108, 101, 32, 111, 114, 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 10, 0]) - child.getErrorOutput().then(val=>{ - for (var i = 0; i < array.length; i++) { - expect(val[i]).assertEqual(array[i]) - } - }) - }) - - /** - * @tc.name: testGetErrorOutput002 - * @tc.desc: return it as 'Uint8Array of the stderr until EOF. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetErrorOutput002', 0, async function () { - var child = process.runCmd('echo "error" 1>&2') - child.wait() - var array = new Uint8Array([101, 114, 111, 114, 10, 0]) - child.getErrorOutput().then(val=>{ - for (var i = 0; i < array.length; i++) { - expect(val[i]).assertEqual(array[i]) - } - }) - }) - - /** - * @tc.name: testGetErrorOutput003 - * @tc.desc: return it as 'Uint8Array of the stderr until EOF. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetErrorOutput003', 0, async function () { - var child = process.runCmd('1') - child.wait() - var array = new Uint8Array([115, 104, 58, 32, 49, 58, 32, 105, 110, 97, 99, 99, 101, 115, 115, 105, 98, - 108, 101, 32, 111, 114, 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 10, 0]) - child.getErrorOutput().then(val=>{ - for (var i = 0; i < array.length; i++) { - expect(val[i]).assertEqual(array[i]) - } - }) - }) - - /** - * @tc.name: testGetErrorOutput004 - * @tc.desc: return it as 'Uint8Array of the stderr until EOF. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetErrorOutput004', 0, async function () { - var child = process.runCmd('chmod 777 123') - var array = new Uint8Array([99, 104, 109, 111, 100, 58, 32, 49, 50, 51, 58, 32, 78, 111, 32, 115, 117, 99, - 104, 32, 102, 105, 108, 101, 32, 111, 114, 32, 100, 105, 114, 101, 99, 116, 111, 114, 121, 10, 0]); - child.wait(); - child.getErrorOutput().then(val=>{ - for (var i = 0; i < array.length; i++) { - expect(val[i]).assertEqual(array[i]) - } - }) - }) - - /** - * @tc.name: testGetErrorOutput005 - * @tc.desc: return it as 'Uint8Array of the stderr until EOF. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetErrorOutput005', 0, async function () { - var child = process.runCmd('cp ./1 ./2') - var array = new Uint8Array([99, 112, 58, 32, 98, 97, 100, 32, 39, 46, 47, 49, 39, 58, 32, 78, 111, 32, 115, - 117, 99, 104, 32, 102, 105, 108, 101, 32, 111, 114, 32, 100, 105, 114, 101, 99, 116, 111, 114, 121, 10, 0]) - child.wait(); - child.getErrorOutput().then(val=>{ - for (var i = 0; i < array.length; i++) { - expect(val[i]).assertEqual(array[i]) - } - }) - }) - - /** - * @tc.name: testWait001 - * @tc.desc: return 'number' is the targer process exit code. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testWait001', 0, async function () { - var child = process.runCmd('ls') - var status = child.wait() - status.then(val=>{ - expect(val).assertEqual(0) - }) - }) - - /** - * @tc.name: testWait002 - * @tc.desc: return 'number' is the targer process exit code. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testWait002', 0, async function () { - var child = process.runCmd('ls; sleep 5;') - child.kill(9); - var status = child.wait() - status.then(val=>{ - expect(val).assertEqual(9) - }) - }) - - /** - * @tc.name: testWait003 - * @tc.desc: return 'number' is the targer process exit code. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testWait003', 0, async function () { - var child = process.runCmd('echo helloWorld'); - var status = child.wait(); - status.then(val=>{ - console.log('---CJX---' + val); - expect(val).assertEqual(0); - }) - }) - - /** - * @tc.name: testWait004 - * @tc.desc: return 'number' is the targer process exit code. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testWait004', 0, async function () { - var child = process.runCmd('mkdir 123'); - var status = child.wait(); - status.then(val=>{ - console.log('---CJX---' + val); - expect(val).assertEqual(256); - }) - }) - - /** - * @tc.name: testWait005 - * @tc.desc: return 'number' is the targer process exit code. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testWait005', 0, async function () { - var child = process.runCmd('sleep 5; echo abc;', { timeout : 1, killSignal : 9 }); - var status = child.wait(); - status.then(val=>{ - console.log('---CJX---' + val); - expect(val).assertEqual(9); - }) - }) - - /** - * @tc.name: testPid001 - * @tc.desc: return pid is the pid of the current process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPid001', 0, function () { - var child = process.runCmd('ls; sleep 5;') - child.wait() - var pid_ = child.pid - expect(pid_ > 0).assertEqual(true) - }) - - /** - * @tc.name: testPid002 - * @tc.desc: return pid is the pid of the current process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPid002', 0, function () { - var child = process.runCmd('mkdir test.cpp') - child.wait() - var pid_ = child.pid - expect(pid_ > 0).assertEqual(true) - }) - - /** - * @tc.name: testPid003 - * @tc.desc: return pid is the pid of the current process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPid003', 0, function () { - var child = process.runCmd('each abc') - child.wait() - var pid_ = child.pid - expect(pid_ > 0).assertEqual(true) - }) - - /** - * @tc.name: testPid004 - * @tc.desc: return pid is the pid of the current process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPid004', 0, function () { - var child = process.runCmd('cd ..') - child.wait() - var pid_ = child.pid - expect(pid_ > 0).assertEqual(true) - }) - - /** - * @tc.name: testPid005 - * @tc.desc: return pid is the pid of the current process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPid005', 0, function () { - var child = process.runCmd('adc') - child.wait() - var pid_ = child.pid - expect(pid_ > 0).assertEqual(true) - }) - - /** - * @tc.name: testPpid001 - * @tc.desc: return ppid is the pid of the current child process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPpid001', 0, function () { - var child = process.runCmd('ls; sleep 5;') - var status = child.wait() - var ppid_ = child.ppid - expect(ppid_ > 0).assertEqual(true) - }) - - /** - * @tc.name: testPpid002 - * @tc.desc: return ppid is the pid of the current child process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPpid002', 0, function () { - var child = process.runCmd('mkdir test.cpp') - child.wait() - var ppid_ = child.ppid - expect(ppid_ > 0).assertEqual(true) - }) - - /** - * @tc.name: testPpid003 - * @tc.desc: return ppid is the pid of the current child process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPpid003', 0, function () { - var child = process.runCmd('each abc') - child.wait() - var ppid_ = child.ppid - expect(ppid_ > 0).assertEqual(true) - }) - - /** - * @tc.name: testPpid004 - * @tc.desc: return ppid is the pid of the current child process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPpid004', 0, function () { - var child = process.runCmd('cd ..') - child.wait() - var ppid_ = child.ppid - expect(ppid_ > 0).assertEqual(true) - }) - - /** - * @tc.name: testPpid005 - * @tc.desc: return ppid is the pid of the current child process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPpid005', 0, function () { - var child = process.runCmd('adc') - child.wait() - var ppid_ = child.ppid - expect(ppid_ > 0).assertEqual(true) - }) - - /** - * @tc.name: testKill001 - * @tc.desc: return boolean is whether the current process signal is sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKill001', 0, function () { - var child = process.runCmd('ls; sleep 5s;') - var result = child.kill(13) - var temp = child.killed - expect(temp).assertEqual(true) - }) - - /** - * @tc.name: testKill002 - * @tc.desc: return boolean is whether the current process signal is sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKill002', 0, function () { - var child = process.runCmd('ls; sleep 5s;') - var result = child.kill(1) - var temp = child.killed - expect(temp).assertEqual(true) - }) - - /** - * @tc.name: testKill003 - * @tc.desc: return boolean is whether the current process signal is sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKill003', 0, function () { - var child = process.runCmd('ls; sleep 5s;') - var result = child.kill('SIGHUP') - var temp = child.killed - expect(temp).assertEqual(true) - }) - - /** - * @tc.name: testKill004 - * @tc.desc: return boolean is whether the current process signal is sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKill004', 0, function () { - var child = process.runCmd('ls; sleep 5s;') - var result = child.kill('ABC') - var temp = child.killed - expect(temp).assertEqual(true) - }) - - /** - * @tc.name: testKill005 - * @tc.desc: return boolean is whether the current process signal is sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKill005', 0, function () { - var child = process.runCmd('ls') - child.wait() - var result = child.kill(9) - var temp = child.killed - expect(temp).assertEqual(false) - }) - - /** - * @tc.name: testClose001 - * @tc.desc: close the target process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testClose001', 0, function () { - var child = process.runCmd('ls; sleep 5s;') - var result = child.close() - expect(child.exitCode).assertEqual(9) - }) - - /** - * @tc.name: testClose002 - * @tc.desc: close the target process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testClose002', 0, function () { - var child = process.runCmd('ls') - function sleep(ms, callback) { - setTimeout(callback, ms) - } - sleep(1000, () => {} ) - var result = child.close() - expect(child.exitCode === 0).assertEqual(false) - }) - - /** - * @tc.name: testClose003 - * @tc.desc: close the target process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testClose003', 0, function () { - var child = process.runCmd('ls;') - var status = child.wait() - var result = child.close() - expect(child.exitCode).assertEqual(0) - }) - - /** - * @tc.name: testClose004 - * @tc.desc: close the target process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testClose004', 0, function () { - var child = process.runCmd('ls') - var result = child.close() - expect(child.exitCode).assertEqual(9) - }) - - /** - * @tc.name: testClose005 - * @tc.desc: close the target process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testClose005', 0, function () { - var child = process.runCmd('sleep 5; echo A') - var result = child.close() - var status = child.wait() - expect(child.exitCode).assertEqual(9) - }) - - /** - * @tc.name: testKilled001 - * @tc.desc: return boolean is whether the current process signal is sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKilled001', 0, function () { - var child = process.runCmd('ls; sleep 1s;') - var result = child.kill(3) - var temp = child.killed - expect(temp).assertEqual(true) - }) - - /** - * @tc.name: testKilled002 - * @tc.desc: return boolean is whether the current process signal is sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKilled002', 0, function () { - var child = process.runCmd('ls; sleep 1s;') - var result = child.close() - var temp = child.killed - expect(temp).assertEqual(false) - }) - - /** - * @tc.name: testKilled003 - * @tc.desc: return boolean is whether the current process signal is sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKilled003', 0, function () { - var child = process.runCmd('ls; sleep 1s;') - var status = child.wait() - var result = child.kill(9) - var temp = child.killed - expect(temp).assertEqual(false) - }) - - /** - * @tc.name: testKilled004 - * @tc.desc: return boolean is whether the current process signal is sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKilled004', 0, function () { - var child = process.runCmd('ls; sleep 5s;') - var result = child.kill('SIGHUP') - var temp = child.killed - expect(temp).assertEqual(true) - }) - - /** - * @tc.name: testKilled005 - * @tc.desc: return boolean is whether the current process signal is sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKilled005', 0, function () { - var child = process.runCmd('ls; sleep 5s;') - var result = child.kill('1') - var temp = child.killed - expect(temp).assertEqual(true) - }) - - /** - * @tc.name: testExitCode001 - * @tc.desc: return exitCode is the exit code of the current child process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testExitCode001', 0, function () { - var child = process.runCmd('ls; sleep 5s;') - var temp = child.kill(9) - child.wait() - var result = child.exitCode - expect(result).assertEqual(9) - }) - - /** - * @tc.name: testExitCode002 - * @tc.desc: return exitCode is the exit code of the current child process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testExitCode002', 0, function () { - var child = process.runCmd('ls;') - child.wait() - var result = child.exitCode - expect(result).assertEqual(0) - }) - - /** - * @tc.name: testExitCode003 - * @tc.desc: return exitCode is the exit code of the current child process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testExitCode003', 0, function () { - var child = process.runCmd('ls; sleep 5s;') - child.close() - child.wait() - var result = child.exitCode - expect(result).assertEqual(9) - }) - - /** - * @tc.name: testExitCode004 - * @tc.desc: return exitCode is the exit code of the current child process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testExitCode004', 0, function () { - var child = process.runCmd('ls') - var temp = child.kill('ABCD') - child.close() - var result = child.exitCode - expect(result).assertEqual(0) - }) - - /** - * @tc.name: testExitCode005 - * @tc.desc: return exitCode is the exit code of the current child process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testExitCode005', 0, function () { - var child = process.runCmd('echo A') - var result= child.wait() - var status = child.close() - expect(child.exitCode).assertEqual(0) - }) - - /** - * @tc.name: testGetUid001 - * @tc.desc: returns the digital user id of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetUid001', 0, function () { - var result = process.uid - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - }) - - /** - * @tc.name: testGetUid002 - * @tc.desc: returns the digital user id of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetUid002', 0, function () { - for(var i = 0; i < 3; i++){ - var result = process.uid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetUid003 - * @tc.desc: returns the digital user id of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetUid003', 0, function () { - for(var i = 0; i < 6; i++){ - var result = process.uid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetUid004 - * @tc.desc: returns the digital user id of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetUid004', 0, function () { - for(var i = 0; i < 10; i++){ - var result = process.uid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetUid005 - * @tc.desc: returns the digital user id of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetUid005', 0, function () { - for(var i = 0; i < 25; i++){ - var result = process.uid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetGid001 - * @tc.desc: returns the numeric group id of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetGid001', 0, function () { - var result = process.gid - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - }) - - /** - * @tc.name: testGetGid002 - * @tc.desc: returns the numeric group id of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetGid002', 0, function () { - for(var i = 0; i < 3; i++){ - var result = process.gid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetGid003 - * @tc.desc: returns the numeric group id of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetGid003', 0, function () { - for(var i = 0; i < 5; i++){ - var result = process.gid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetGid004 - * @tc.desc: returns the numeric group id of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetGid004', 0, function () { - for(var i = 0; i < 10; i++){ - var result = process.gid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetGid005 - * @tc.desc: returns the numeric group id of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetGid005', 0, function () { - for(var i = 0; i < 9; i++){ - var result = process.gid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetEuid001 - * @tc.desc: return the numeric valid user identity of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetEuid001', 0, function () { - var result = process.euid - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - }) - - /** - * @tc.name: testGetEuid002 - * @tc.desc: return the numeric valid user identity of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetEuid002', 0, function () { - for(var i = 0; i < 3; i++){ - var result = process.euid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetEuid003 - * @tc.desc: return the numeric valid user identity of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetEuid003', 0, function () { - for(var i = 0; i < 5; i++){ - var result = process.euid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetEuid004 - * @tc.desc: return the numeric valid user identity of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetEuid004', 0, function () { - for(var i = 0; i < 8; i++){ - var result = process.euid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetEuid005 - * @tc.desc: return the numeric valid user identity of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetEuid005', 0, function () { - for(var i = 0; i < 15; i++){ - var result = process.euid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetEgid001 - * @tc.desc: returns the numeric valid group ID of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetEgid001', 0, function () { - var result = process.egid - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - }) - - /** - * @tc.name: testGetEgid002 - * @tc.desc: returns the numeric valid group ID of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetEgid002', 0, function () { - for(var i = 0; i < 3; i++){ - var result = process.egid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetEgid003 - * @tc.desc: returns the numeric valid group ID of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetEgid003', 0, function () { - for(var i = 0; i < 5; i++){ - var result = process.egid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetEgid004 - * @tc.desc: returns the numeric valid group ID of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetEgid004', 0, function () { - for(var i = 0; i < 15; i++){ - var result = process.egid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetEgid005 - * @tc.desc: returns the numeric valid group ID of the process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetEgid005', 0, function () { - for(var i = 0; i < 26; i++){ - var result = process.egid - if(result != null) { - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetGroups001 - * @tc.desc: return an array with supplementary group id. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetGroups001', 0, function () { - var result = process.groups - var len = result.length - if(len > 0) { - var flag = true - } - expect(flag).assertEqual(true) - }) - - /** - * @tc.name: testGetGroups002 - * @tc.desc: return an array with supplementary group id. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetGroups002', 0, function () { - for(var i = 0; i < 3; i++){ - var result = process.groups - if(result != null) { - var len = result.length - if(len > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetGroups003 - * @tc.desc: return an array with supplementary group id. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetGroups003', 0, function () { - for(var i = 0; i < 5; i++){ - var result = process.groups - if(result != null) { - var len = result.length - if(len > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetGroups004 - * @tc.desc: return an array with supplementary group id. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetGroups004', 0, function () { - for(var i = 0; i < 18; i++){ - var result = process.groups - if(result != null) { - var len = result.length - if(len > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetGroups005 - * @tc.desc: return an array with supplementary group id. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testGetGroups005', 0, function () { - for(var i = 0; i < 28; i++){ - var result = process.groups - if(result != null) { - var len = result.length - if(len > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testChdir001 - * @tc.desc: Change current directory. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testChdir001', 0, function () { - var result = process.chdir('/system') - var result1 = process.cwd() - expect(result1).assertEqual('/system') - }) - - /** - * @tc.name: testChdir002 - * @tc.desc: Change current directory. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testChdir002', 0, function () { - var result = process.chdir('/system/lib') - var result1 = process.cwd() - expect(result1).assertEqual('/system/lib') - }) - - /** - * @tc.name: testChdir003 - * @tc.desc: Change current directory. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testChdir003', 0, function () { - var result = process.chdir('/..') - var result1 = process.cwd() - expect(result1).assertEqual('/') - console.log("test-----testChdir003-----" + result1) - }) - - /** - * @tc.name: testChdir004 - * @tc.desc: Change current directory. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testChdir004', 0, function () { - var result = process.chdir('/system/bin') - var result1 = process.cwd() - expect(result1).assertEqual('/system/bin') - }) - - /** - * @tc.name: testChdir005 - * @tc.desc: Change current directory. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testChdir005', 0, function () { - var result = process.chdir('/system/app') - var result1 = process.cwd() - expect(result1).assertEqual('/system/app') - }) - - /** - * @tc.name: testKill001 - * @tc.desc: Return whether the signal was sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKill001', 0, function () { - var result = process.kill(123, 3) - expect(result).assertEqual(false) - }) - - /** - * @tc.name: testKill002 - * @tc.desc: Return whether the signal was sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKill002', 0, function () { - var pres = process.pid - var result = process.kill(pres, 23) - expect(result).assertEqual(true) - }) - - /** - * @tc.name: testKill003 - * @tc.desc: Return whether the signal was sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKill003', 0, function () { - var pres = process.pid - var result = process.kill(pres, 28) - expect(result).assertEqual(true) - }) - - /** - * @tc.name: testKill004 - * @tc.desc: Return whether the signal was sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKill004', 0, function () { - var pres = process.pid - var result = process.kill(pres, 17) - expect(result).assertEqual(true) - }) - - /** - * @tc.name: testKill005 - * @tc.desc: Return whether the signal was sent successfully. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testKill005', 0, function () { - var result = process.kill(113, 3) - expect(result).assertEqual(false) - }) - - /** - * @tc.name: testUptime001 - * @tc.desc: Returns the running time of the system. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testUptime001', 0, function () { - var result1 = process.uptime() - function sleep(d){ - while(process.uptime() - result1 <= d); - } - sleep(5); - var result2 = process.uptime() - 6 - expect(result1).assertEqual(result2) - }) - - /** - * @tc.name: testUptime002 - * @tc.desc: Returns the running time of the system. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testUptime002', 0, function () { - var result1 = process.uptime() - function sleep(d){ - while(process.uptime() - result1 <= d); - } - sleep(8); - var result2 = process.uptime() - 9 - expect(result1).assertEqual(result2) - }) - - /** - * @tc.name: testUptime003 - * @tc.desc: Returns the running time of the system. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testUptime003', 0, function () { - var result1 = process.uptime() - function sleep(d){ - while(process.uptime() - result1 <= d); - } - sleep(10); - var result2 = process.uptime() - 11 - expect(result1).assertEqual(result2) - }) - - /** - * @tc.name: testUptime004 - * @tc.desc: Returns the running time of the system. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testUptime004', 0, function () { - var result1 = process.uptime() - function sleep(d){ - while(process.uptime() - result1 <= d); - } - sleep(7); - var result2 = process.uptime() - 8 - expect(result1).assertEqual(result2) - }) - - /** - * @tc.name: testUptime005 - * @tc.desc: Returns the running time of the system. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testUptime005', 0, function () { - var result1 = process.uptime() - function sleep(d){ - while(process.uptime() - result1 <= d); - } - sleep(11); - var result2 = process.uptime() - 12 - expect(result1).assertEqual(result2) - }) - - /** - * @tc.name: testPid001 - * @tc.desc: Return pid is the pid of the current process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPid001', 0, function () { - var result = process.pid - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - }) - - /** - * @tc.name: testPid002 - * @tc.desc: Return pid is the pid of the current process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPid002', 0, function () { - for(var i = 0; i < 3; i++) - { - var result = process.pid - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - }) - - /** - * @tc.name: testPid003 - * @tc.desc: Return pid is the pid of the current process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPid003', 0, function () { - for(var i = 0; i < 5; i++) - { - var result = process.pid - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - }) - - /** - * @tc.name: testPid004 - * @tc.desc: Return pid is the pid of the current process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPid004', 0, function () { - for(var i = 0; i < 10; i++) - { - var result = process.pid - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - }) - - /** - * @tc.name: testPid005 - * @tc.desc: Return pid is the pid of the current process. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPid005', 0, function () { - for(var i = 0; i < 28; i++) - { - var result = process.pid - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - }) - - /** - * @tc.name: testPpid001 - * @tc.desc: Return ppid is the pid of the current child process - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPpid001', 0, function () { - var result = process.ppid - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - }) - - /** - * @tc.name: testPpid002 - * @tc.desc: Return ppid is the pid of the current child process - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPpid002', 0, function () { - for(var i = 0; i < 3; i++) - { - var result = process.ppid - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - }) - - /** - * @tc.name: testPpid003 - * @tc.desc: Return ppid is the pid of the current child process - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPpid003', 0, function () { - for(var i = 0; i < 5; i++) - { - var result = process.ppid - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - }) - - /** - * @tc.name: testPpid004 - * @tc.desc: Return ppid is the pid of the current child process - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPpid004', 0, function () { - for(var i = 0; i < 16; i++) - { - var result = process.ppid - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - }) - - /** - * @tc.name: testPpid005 - * @tc.desc: Return ppid is the pid of the current child process - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testPpid005', 0, function () { - for(var i = 0; i < 28; i++) - { - var result = process.ppid - if(result > 0) { - var flag = true - } - expect(flag).assertEqual(true) - } - }) - - /** - * @tc.name: testCwd001 - * @tc.desc: Return the current work directory. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testCwd001', 0, function () { - var cwd = process.cwd() - expect(cwd).assertEqual('/') - }) - - /** - * @tc.name: testCwd002 - * @tc.desc: Return the current work directory. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testCwd002', 0, function () { - for(var i = 0; i < 3; i++) - { - var cwd = process.cwd() - expect(cwd).assertEqual('/') - } - }) - - /** - * @tc.name: testCwd003 - * @tc.desc: Return the current work directory. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testCwd003', 0, function () { - for(var i = 0; i < 10; i++) - { - var cwd = process.cwd() - expect(cwd).assertEqual('/') - } - }) - - /** - * @tc.name: testCwd004 - * @tc.desc: Return the current work directory. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testCwd004', 0, function () { - for(var i = 0; i < 18; i++) - { - var cwd = process.cwd() - expect(cwd).assertEqual('/') - } - }) - - /** - * @tc.name: testCwd005 - * @tc.desc: Return the current work directory. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testCwd005', 0, function () { - for(var i = 0; i < 29; i++) - { - var cwd = process.cwd() - expect(cwd).assertEqual('/') - } - }) - - /** - * @tc.name: testOn001 - * @tc.desc: Register for an event. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testOn001', 0, function () { - function add(){ - var value = 3 + 2 - } - var ontest = process.on(1, add) - expect(ontest).assertEqual(false) - }) - - /** - * @tc.name: testOn002 - * @tc.desc: Register for an event. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testOn002', 0, function () { - function add1(num){ - var value = num + 3 - } - var on = process.on("add123", add1) - }) - - /** - * @tc.name: testOn003 - * @tc.desc: Register for an event. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testOn003', 0, function () { - function add2(num0, num1){ - var value = num0 + num1 - } - var ontest = process.on(879, add2) - expect(ontest).assertEqual(false) - }) - - /** - * @tc.name: testOn004 - * @tc.desc: Register for an event. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testOn004', 0, function () { - function add3(num0, num1){ - var value = num0 + num1 - } - var ontest = process.on(12345, add3) - expect(ontest).assertEqual(false) - }) - - /** - * @tc.name: testOn005 - * @tc.desc: Register for an event. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testOn005', 0, function () { - function add4(num0, num1){ - var value = num0 + num1 - } - var ontest = process.on(1000, add4) - expect(ontest).assertEqual(false) - }) - - /** - * @tc.name: testOff001 - * @tc.desc: Remove registered event. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testOff001', 0, function () { - function add1(num){ - var value = num + 3 - } - var on = process.on("add123", add1) - var offtest = process.off("add123") - expect(offtest).assertEqual(true) - }) - - /** - * @tc.name: testOff002 - * @tc.desc: Remove registered event. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testOff002', 0, function () { - var offtest = process.off("123") - expect(offtest).assertEqual(false) - }) - - /** - * @tc.name: testOff003 - * @tc.desc: Remove registered event. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testOff003', 0, function () { - var offtest = process.off("456") - expect(offtest).assertEqual(false) - }) - - /** - * @tc.name: testOff004 - * @tc.desc: Remove registered event. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testOff004', 0, function () { - function add1(num){ - var value = num + 3 - } - var on = process.on("function_add1", add1) - var offtest = process.off("function_add1") - expect(offtest).assertEqual(true) - }) - - /** - * @tc.name: testOff005 - * @tc.desc: Remove registered event. - * @tc.require: AR000GFB2S - * @tc.author: wangben - */ - it('testOff005', 0, function () { - function add1(num){ - var value = num + 3 - } - var on = process.on("add", add1) - var offtest = process.off("add") - expect(offtest).assertEqual(true) - }) - - /** - * @tc.name: testTid001 - * @tc.desc: Returns the tid of the current thread. - * @tc.require: AR000GFB04 - * @tc.author: liwenqiang + /** + * @tc.name: testGetEgid002 + * @tc.desc: returns the numeric valid group ID of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben */ - it('testTid001', 0, function () { - var pres = Process.tid - console.info('test press value:' + pres) - if(pres > 0) + it('testGetEgid002', 0, function () { + for(var i = 0; i < 3; i++){ + var result = process.egid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEgid003 + * @tc.desc: returns the numeric valid group ID of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEgid003', 0, function () { + for(var i = 0; i < 5; i++){ + var result = process.egid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEgid004 + * @tc.desc: returns the numeric valid group ID of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEgid004', 0, function () { + for(var i = 0; i < 15; i++){ + var result = process.egid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEgid005 + * @tc.desc: returns the numeric valid group ID of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEgid005', 0, function () { + for(var i = 0; i < 26; i++){ + var result = process.egid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGroups001 + * @tc.desc: return an array with supplementary group id. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGroups001', 0, function () { + var result = process.groups + var len = result.length + if(len > 0) { + var flag = true + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetGroups002 + * @tc.desc: return an array with supplementary group id. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGroups002', 0, function () { + for(var i = 0; i < 3; i++){ + var result = process.groups + if(result != null) { + var len = result.length + if(len > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGroups003 + * @tc.desc: return an array with supplementary group id. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGroups003', 0, function () { + for(var i = 0; i < 5; i++){ + var result = process.groups + if(result != null) { + var len = result.length + if(len > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGroups004 + * @tc.desc: return an array with supplementary group id. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGroups004', 0, function () { + for(var i = 0; i < 18; i++){ + var result = process.groups + if(result != null) { + var len = result.length + if(len > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGroups005 + * @tc.desc: return an array with supplementary group id. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGroups005', 0, function () { + for(var i = 0; i < 28; i++){ + var result = process.groups + if(result != null) { + var len = result.length + if(len > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testChdir001 + * @tc.desc: Change current directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testChdir001', 0, function () { + var result = process.chdir('/system') + var result1 = process.cwd() + expect(result1).assertEqual('/system') + }) + + /** + * @tc.name: testChdir002 + * @tc.desc: Change current directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testChdir002', 0, function () { + var result = process.chdir('/system/lib') + var result1 = process.cwd() + expect(result1).assertEqual('/system/lib') + }) + + /** + * @tc.name: testChdir003 + * @tc.desc: Change current directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testChdir003', 0, function () { + var result = process.chdir('/..') + var result1 = process.cwd() + expect(result1).assertEqual('/') + }) + + /** + * @tc.name: testChdir004 + * @tc.desc: Change current directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testChdir004', 0, function () { + var result = process.chdir('/system/app') + var result1 = process.cwd() + expect(result1).assertEqual('/system/app') + }) + + /** + * @tc.name: testChdir005 + * @tc.desc: Change current directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testChdir005', 0, function () { + var result = process.chdir('/data') + var result1 = process.cwd() + expect(result1).assertEqual('/data') + }) + + /** + * @tc.name: testKill001 + * @tc.desc: Return whether the signal was sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill001', 0, function () { + var result = process.kill(123, 3) + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testKill002 + * @tc.desc: Return whether the signal was sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill002', 0, function () { + var pres = process.pid + var result = process.kill(pres, 23) + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testKill003 + * @tc.desc: Return whether the signal was sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill003', 0, function () { + var pres = process.pid + var result = process.kill(pres, 28) + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testKill004 + * @tc.desc: Return whether the signal was sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill004', 0, function () { + var pres = process.pid + var result = process.kill(pres, 17) + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testKill005 + * @tc.desc: Return whether the signal was sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill005', 0, function () { + var result = process.kill(113, 3) + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testUptime001 + * @tc.desc: Returns the running time of the system. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testUptime001', 0, function () { + var result1 = process.uptime() + function sleep(d){ + while(process.uptime() - result1 <= d); + } + sleep(5); + var result2 = process.uptime() - 6 + expect(result1).assertEqual(result2) + }) + + /** + * @tc.name: testUptime002 + * @tc.desc: Returns the running time of the system. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testUptime002', 0, function () { + var result1 = process.uptime() + function sleep(d){ + while(process.uptime() - result1 <= d); + } + sleep(8); + var result2 = process.uptime() - 9 + expect(result1).assertEqual(result2) + }) + + /** + * @tc.name: testUptime003 + * @tc.desc: Returns the running time of the system. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testUptime003', 0, function () { + var result1 = process.uptime() + function sleep(d){ + while(process.uptime() - result1 <= d); + } + sleep(10); + var result2 = process.uptime() - 11 + expect(result1).assertEqual(result2) + }) + + /** + * @tc.name: testUptime004 + * @tc.desc: Returns the running time of the system. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testUptime004', 0, function () { + var result1 = process.uptime() + function sleep(d){ + while(process.uptime() - result1 <= d); + } + sleep(7); + var result2 = process.uptime() - 8 + expect(result1).assertEqual(result2) + }) + + /** + * @tc.name: testUptime005 + * @tc.desc: Returns the running time of the system. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testUptime005', 0, function () { + var result1 = process.uptime() + function sleep(d){ + while(process.uptime() - result1 <= d); + } + sleep(11); + var result2 = process.uptime() - 12 + expect(result1).assertEqual(result2) + }) + + /** + * @tc.name: testPid001 + * @tc.desc: Return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid001', 0, function () { + var result = process.pid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testPid002 + * @tc.desc: Return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid002', 0, function () { + for(var i = 0; i < 3; i++) + { + var result = process.pid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testPid003 + * @tc.desc: Return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid003', 0, function () { + for(var i = 0; i < 5; i++) + { + var result = process.pid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testPid004 + * @tc.desc: Return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid004', 0, function () { + for(var i = 0; i < 10; i++) + { + var result = process.pid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testPid005 + * @tc.desc: Return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid005', 0, function () { + for(var i = 0; i < 28; i++) + { + var result = process.pid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testPpid001 + * @tc.desc: Return ppid is the pid of the current child process + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid001', 0, function () { + var result = process.ppid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testPpid002 + * @tc.desc: Return ppid is the pid of the current child process + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid002', 0, function () { + for(var i = 0; i < 3; i++) + { + var result = process.ppid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testPpid003 + * @tc.desc: Return ppid is the pid of the current child process + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid003', 0, function () { + for(var i = 0; i < 5; i++) + { + var result = process.ppid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testPpid004 + * @tc.desc: Return ppid is the pid of the current child process + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid004', 0, function () { + for(var i = 0; i < 16; i++) + { + var result = process.ppid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testPpid005 + * @tc.desc: Return ppid is the pid of the current child process + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid005', 0, function () { + for(var i = 0; i < 28; i++) { + var result = process.ppid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testCwd001 + * @tc.desc: Return the current work directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testCwd001', 0, function () { + var cwdir = process.cwd() + if(cwdir){ var flag = true } expect(flag).assertEqual(true) }) /** - * @tc.name: testTid002 - * @tc.desc: Returns the tid of the current thread. - * @tc.require: AR000GFB04 - * @tc.author: liwenqiang + * @tc.name: testCwd002 + * @tc.desc: Return the current work directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testCwd002', 0, function () { + for(var i = 0; i < 3; i++) + { + var cwdir = process.cwd() + if(cwdir){ + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testCwd003 + * @tc.desc: Return the current work directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testCwd003', 0, function () { + for(var i = 0; i < 10; i++) + { + var cwdir = process.cwd() + if(cwdir){ + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testCwd004 + * @tc.desc: Return the current work directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testCwd004', 0, function () { + for(var i = 0; i < 18; i++) + { + var cwdir = process.cwd() + if(cwdir){ + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testCwd005 + * @tc.desc: Return the current work directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben */ - it('testTid002', 0, function () { - for(var i=0; i<3; i++) + it('testCwd005', 0, function () { + for(var i = 0; i < 29; i++) { - var pres = Process.tid - if(pres > 0) - { + var cwdir = process.cwd() + if(cwdir){ var flag = true } expect(flag).assertEqual(true) @@ -1793,59 +1624,193 @@ describe('ChildProcessTest', function () { }) /** - * @tc.name: testTid003 + * @tc.name: testOn001 + * @tc.desc: Register for an event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOn001', 0, function () { + function add(){ + var value = 3 + 2 + } + var ontest = process.on(1, add) + expect(ontest).assertEqual(false) + }) + + /** + * @tc.name: testOn002 + * @tc.desc: Register for an event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOn002', 0, function () { + function add1(num){ + var value = num + 3 + } + var on = process.on("add123", add1) + }) + + /** + * @tc.name: testOn003 + * @tc.desc: Register for an event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOn003', 0, function () { + function add2(num0, num1){ + var value = num0 + num1 + } + var ontest = process.on(879, add2) + expect(ontest).assertEqual(false) + }) + + /** + * @tc.name: testOn004 + * @tc.desc: Register for an event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOn004', 0, function () { + function add3(num0, num1){ + var value = num0 + num1 + } + var ontest = process.on(12345, add3) + expect(ontest).assertEqual(false) + }) + + /** + * @tc.name: testOn005 + * @tc.desc: Register for an event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOn005', 0, function () { + function add4(num0, num1){ + var value = num0 + num1 + } + var ontest = process.on(1000, add4) + expect(ontest).assertEqual(false) + }) + + /** + * @tc.name: testOff001 + * @tc.desc: Remove registered event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOff001', 0, function () { + function add1(num){ + var value = num + 3 + } + var on = process.on("add123", add1) + var offtest = process.off("add123") + expect(offtest).assertEqual(true) + }) + + /** + * @tc.name: testOff002 + * @tc.desc: Remove registered event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOff002', 0, function () { + var offtest = process.off("123") + expect(offtest).assertEqual(false) + }) + + /** + * @tc.name: testOff003 + * @tc.desc: Remove registered event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOff003', 0, function () { + var offtest = process.off("456") + expect(offtest).assertEqual(false) + }) + + /** + * @tc.name: testOff004 + * @tc.desc: Remove registered event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOff004', 0, function () { + function add1(num){ + var value = num + 3 + } + var on = process.on("function_add1", add1) + var offtest = process.off("function_add1") + expect(offtest).assertEqual(true) + }) + + /** + * @tc.name: testOff005 + * @tc.desc: Remove registered event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOff005', 0, function () { + function add1(num){ + var value = num + 3 + } + var on = process.on("add", add1) + var offtest = process.off("add") + expect(offtest).assertEqual(true) + }) + + /** + * @tc.name: testTid001 * @tc.desc: Returns the tid of the current thread. * @tc.require: AR000GFB04 * @tc.author: liwenqiang */ - it('testTid003', 0, function () { - for(var i=0; i<8; i++) + it('testTid001', 0, function () { + var pres = process.tid + if(pres > 0) { - var pres = Process.tid - if(pres > 0) - { - var flag = true - } - expect(flag).assertEqual(true) + var flag = new Boolean(true) } + expect(flag).assertEqual(true) }) /** - * @tc.name: testTid004 + * @tc.name: testTid002 * @tc.desc: Returns the tid of the current thread. * @tc.require: AR000GFB04 * @tc.author: liwenqiang */ - it('testTid004', 0, function () { - for(var i=0; i<18; i++) + it('testTid002', 0, function () { + for(var i=0; i<10; i++) { - var pres = Process.tid + var pres = process.tid if(pres > 0) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) } }) /** - * @tc.name: testTid005 + * @tc.name: testTid003 * @tc.desc: Returns the tid of the current thread. * @tc.require: AR000GFB04 * @tc.author: liwenqiang */ - it('testTid005', 0, function () { - for(var i=0; i<26; i++) + it('testTid003', 0, function () { + for(var i=0; i<1000; i++) { - var pres = Process.tid + var pres = process.tid if(pres > 0) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) } }) + /** * @tc.name: testIsisolatedProcess001 * @tc.desc: Returns a boolean whether the process is isolated. @@ -1853,8 +1818,8 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testIsisolatedProcess001', 0, function () { - var pres = Process.isIsolatedProcess() - expect(pres).assertEqual(true) + var pres = process.isIsolatedProcess() + expect(pres).assertEqual(false) }) /** @@ -1864,10 +1829,10 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testIsisolatedProcess002', 0, function () { - for(var i=0; i<3; i++) + for(var i=0; i<10; i++) { - var pres =Process.isIsolatedProcess() - expect(pres).assertEqual(true) + var pres =process.isIsolatedProcess() + expect(pres).assertEqual(false) } }) @@ -1878,40 +1843,13 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testIsisolatedProcess003', 0, function () { - for(var i=0; i<18; i++) - { - var pres =Process.isIsolatedProcess() - expect(pres).assertEqual(true) - } - }) - - /** - * @tc.name: testIsisolatedProcess004 - * @tc.desc: Returns a boolean whether the process is isolated. - * @tc.require: AR000GFB04 - * @tc.author: liwenqiang - */ - it('testIsisolatedProcess004', 0, function () { - for(var i=0; i<20; i++) + for(var i=0; i<1000; i++) { - var pres =Process.isIsolatedProcess() - expect(pres).assertEqual(true) + var pres =process.isIsolatedProcess() + expect(pres).assertEqual(false) } }) - /** - * @tc.name: testIsisolatedProcess005 - * @tc.desc: Returns a boolean whether the process is isolated. - * @tc.require: AR000GFB04 - * @tc.author: liwenqiang - */ - it('testIsisolatedProcess005', 0, function () { - for(var i=0; i<25; i++) - { - var pres =Process.isIsolatedProcess() - expect(pres).assertEqual(true) - } - }) /** * @tc.name: testIsappuid001 @@ -1920,8 +1858,9 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testIsappuid001', 0, function () { - var isorno = Process.isAppUid(456) - expect(isorno).assertEqual(false) + var appUid = process.uid + var isorno = process.isAppUid(appUid) + expect(isorno).assertEqual(true) }) /** @@ -1931,7 +1870,7 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testIsappuid002', 0, function () { - var isorno = Process.isAppUid(123) + var isorno = process.isAppUid(123) expect(isorno).assertEqual(false) }) @@ -1942,7 +1881,7 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testIsappuid003', 0, function () { - var isorno = Process.isAppUid(80000) + var isorno = process.isAppUid(80000) expect(isorno).assertEqual(false) }) @@ -1953,7 +1892,7 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testIsappuid004', 0, function () { - var isorno = Process.isAppUid(789) + var isorno = process.isAppUid(789) expect(isorno).assertEqual(false) }) @@ -1964,7 +1903,7 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testIsappuid005', 0, function () { - var isorno = Process.isAppUid(8569) + var isorno = process.isAppUid(8569) expect(isorno).assertEqual(false) }) @@ -1975,7 +1914,7 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testIs64Bit001', 0, function () { - var isorno = Process.is64Bit() + var isorno = process.is64Bit() expect(isorno).assertEqual(false) }) @@ -1986,9 +1925,9 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testIs64Bit002', 0, function () { - for(var i=0; i<3; i++) + for(var i=0; i<10; i++) { - var isorno = Process.is64Bit() + var isorno = process.is64Bit() expect(isorno).assertEqual(false) } }) @@ -2000,40 +1939,13 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testIs64Bit003', 0, function () { - for(var i=0; i<15; i++) - { - var isorno = Process.is64Bit() - expect(isorno).assertEqual(false) - } - }) - - /** - * @tc.name: testIs64Bit004 - * @tc.desc: Returns a boolean whether the process is running in a 64-bit environment. - * @tc.require: AR000GFB04 - * @tc.author: liwenqiang - */ - it('testIs64Bit004', 0, function () { - for(var i=0; i<18; i++) + for(var i=0; i<1000; i++) { - var isorno = Process.is64Bit() + var isorno = process.is64Bit() expect(isorno).assertEqual(false) } }) - /** - * @tc.name: testIs64Bit005 - * @tc.desc: Returns a boolean whether the process is running in a 64-bit environment. - * @tc.require: AR000GFB04 - * @tc.author: liwenqiang - */ - it('testIs64Bit005', 0, function () { - for(var i=0; i<22; i++) - { - var isorno = Process.is64Bit() - expect(isorno).assertEqual(false) - } - }) /** * @tc.name: testGetuidforname001 @@ -2042,8 +1954,12 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetuidforname001',0, function () { - var pres = Process.getUidForName("1111") - expect(pres).assertEqual(-1) + var pres = process.getUidForName("root") + if(pres != -1) + { + var flag = new Boolean(true) + expect(flag).assertEqual(true) + } }) /** @@ -2053,9 +1969,9 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetuidforname002', 0, function () { - for(var i=0; i<3; i++) + for(var i=0; i<10; i++) { - var pres = Process.getUidForName("12356") + var pres = process.getUidForName("12356") expect(pres).assertEqual(-1) } }) @@ -2067,40 +1983,13 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetuidforname003', 0, function () { - for(var i=0; i<18; i++) - { - var pres = Process.getUidForName("12356") - expect(pres).assertEqual(-1) - } - }) - - /** - * @tc.name: testGetuidforname004 - * @tc.desc: Returns the uid based on the specified user name. - * @tc.require: AR000GFB04 - * @tc.author: liwenqiang - */ - it('testGetuidforname004', 0, function () { - for(var i=0; i<16; i++) + for(var i=0; i<1000; i++) { - var pres = Process.getUidForName("12356") + var pres = process.getUidForName("12356") expect(pres).assertEqual(-1) } }) - /** - * @tc.name: testGetuidforname005 - * @tc.desc: Returns the uid based on the specified user name. - * @tc.require: AR000GFB04 - * @tc.author: liwenqiang - */ - it('testGetuidforname005', 0, function () { - for(var i=0; i<21; i++) - { - var pres = Process.getUidForName("12356") - expect(pres).assertEqual(-1) - } - }) /** * @tc.name: testGetthreadpriority001 @@ -2109,11 +1998,11 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetthreadpriority001', 0, function () { - var pres = Process.tid - var pri = Process.getThreadPriority(pres) + var pres = process.tid + var pri = process.getThreadPriority(pres) if(pri) { - var flag = true + var flag = new Boolean(true) expect(flag).assertEqual(true) } }) @@ -2125,13 +2014,13 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetthreadpriority002', 0, function () { - var pres = Process.tid - for(var i=0; i<3; i++) + var pres = process.tid + for(var i=0; i<10; i++) { - var pri = Process.getThreadPriority(pres) + var pri = process.getThreadPriority(pres) if(pri > 0) { - var flag = true + var flag = new Boolean(true) expect(flag).assertEqual(true) } } @@ -2144,51 +2033,13 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetthreadpriority003', 0, function () { - var pres = Process.tid - for(var i=0; i<16; i++) - { - var pri = Process.getThreadPriority(pres) - if(pri > 0) - { - var flag = true - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetthreadpriority004 - * @tc.desc: Returns the thread priority based on the specified tid. - * @tc.require: AR000GFB04 - * @tc.author: liwenqiang - */ - it('testGetthreadpriority004', 0, function () { - var pres = Process.tid - for(var i=0; i<18; i++) - { - var pri = Process.getThreadPriority(pres) - if(pri > 0) - { - var flag = true - expect(flag).assertEqual(true) - } - } - }) - - /** - * @tc.name: testGetthreadpriority005 - * @tc.desc: Returns the thread priority based on the specified tid. - * @tc.require: AR000GFB04 - * @tc.author: liwenqiang - */ - it('testGetthreadpriority005', 0, function () { - var pres = Process.tid - for(var i=0; i<25; i++) + var pres = process.tid + for(var i=0; i<1000; i++) { - var pri = Process.getThreadPriority(pres) + var pri = process.getThreadPriority(pres) if(pri > 0) { - var flag = true + var flag = new Boolean(true) expect(flag).assertEqual(true) } } @@ -2197,17 +2048,17 @@ describe('ChildProcessTest', function () { /** * @tc.name: testGetstartrealtime001 * @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of - * the system to the start of the process. + the system to the start of the process. * @tc.require: AR000GFB04 * @tc.author: liwenqiang */ it('testGetstartrealtime001', 0, function () { - for(var i=0; i<3; i++) + for(var i=0; i<10; i++) { - var pri = Process.getStartRealtime() - if(pri > 0) + var pri = process.getStartRealtime() + if(pri !== null) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) } @@ -2216,15 +2067,15 @@ describe('ChildProcessTest', function () { /** * @tc.name: testGetstartrealtime002 * @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of - * the system to the start of the process. + the system to the start of the process. * @tc.require: AR000GFB04 * @tc.author: liwenqiang */ it('testGetstartrealtime002', 0, function () { - var pri = Process.getStartRealtime() - if(pri > 0) + var pri = process.getStartRealtime() + if(pri !== null) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) }) @@ -2232,17 +2083,17 @@ describe('ChildProcessTest', function () { /** * @tc.name: testGetstartrealtime003 * @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of - * the system to the start of the process. + the system to the start of the process. * @tc.require: AR000GFB04 * @tc.author: liwenqiang */ it('testGetstartrealtime003', 0, function () { - for(var i=0; i<16; i++) + for(var i=0; i<100; i++) { - var pri = Process.getStartRealtime() - if(pri > 0) + var pri = process.getStartRealtime() + if(pri !== null) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) } @@ -2251,36 +2102,17 @@ describe('ChildProcessTest', function () { /** * @tc.name: testGetstartrealtime004 * @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of - * the system to the start of the process. + the system to the start of the process. * @tc.require: AR000GFB04 * @tc.author: liwenqiang */ it('testGetstartrealtime004', 0, function () { - for(var i=0; i<19; i++) - { - var pri = Process.getStartRealtime() - if(pri > 0) - { - var flag = true - } - expect(flag).assertEqual(true) - } - }) - - /** - * @tc.name: testGetstartrealtime005 - * @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of - * the system to the start of the process. - * @tc.require: AR000GFB04 - * @tc.author: liwenqiang - */ - it('testGetstartrealtime005', 0, function () { - for(var i=0; i<22; i++) + for(var i=0; i<1000; i++) { - var pri = Process.getStartRealtime() + var pri = process.getPastCputime() if(pri > 0) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) } @@ -2293,12 +2125,12 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetpastCputime001', 0, function () { - for(var i=0; i<3; i++) + for(var i=0; i<10; i++) { - var pri = Process.getPastCputime() + var pri = process.getStartRealtime() if(pri > 0) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) } @@ -2311,10 +2143,10 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetpastCputime002', 0, function () { - var pri = Process.getPastCputime() + var pri = process.getPastCputime() if(pri > 0) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) }) @@ -2326,12 +2158,12 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetpastCputime003', 0, function () { - for(var i=0; i<12; i++) + for(var i=0; i<100; i++) { - var pri = Process.getPastCputime() + var pri = process.getPastCputime() if(pri > 0) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) } @@ -2344,30 +2176,12 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetpastCputime004', 0, function () { - for(var i=0; i<16; i++) - { - var pri = Process.getPastCputime() - if(pri > 0) - { - var flag = true - } - expect(flag).assertEqual(true) - } - }) - - /** - * @tc.name: testGetpastCputime005 - * @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time. - * @tc.require: AR000GFB04 - * @tc.author: liwenqiang - */ - it('testGetpastCputime005', 0, function () { - for(var i=0; i<21; i++) + for(var i=0; i<1000; i++) { - var pri = Process.getPastCputime() + var pri = process.getPastCputime() if(pri > 0) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) } @@ -2381,10 +2195,10 @@ describe('ChildProcessTest', function () { */ it('testGetSystemConfig001', 0, function () { var _SC_ARG_MAX = 0 - var pri = Process.getSystemConfig(_SC_ARG_MAX) + var pri = process.getSystemConfig(_SC_ARG_MAX) if(pri > 0) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) }) @@ -2397,12 +2211,12 @@ describe('ChildProcessTest', function () { */ it('testGetSystemConfig002', 0, function () { var _SC_ARG_MAX = 0 - for(var i=0; i<3; i++) + for(var i=0; i<10; i++) { - var pri = Process.getSystemConfig(_SC_ARG_MAX) + var pri = process.getSystemConfig(_SC_ARG_MAX) if(pri > 0) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) } @@ -2416,12 +2230,12 @@ describe('ChildProcessTest', function () { */ it('testGetSystemConfig003', 0, function () { var _SC_ARG_MAX = 0 - for(var i=0; i<8; i++) + for(var i=0; i<100; i++) { - var pri = Process.getSystemConfig(_SC_ARG_MAX) + var pri = process.getSystemConfig(_SC_ARG_MAX) if(pri > 0) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) } @@ -2434,16 +2248,13 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetSystemConfig004', 0, function () { - var _SC_ARG_MAX = 0 - for(var i=0; i<15; i++) + var _SC_OPEN_MAX = 4 + var pri = process.getSystemConfig(_SC_OPEN_MAX) + if(pri > 0) { - var pri = Process.getSystemConfig(_SC_ARG_MAX) - if(pri > 0) - { - var flag = true - } - expect(flag).assertEqual(true) + var flag = new Boolean(true) } + expect(flag).assertEqual(true) }) /** @@ -2453,16 +2264,13 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetSystemConfig005', 0, function () { - var _SC_ARG_MAX = 0 - for(var i=0; i<19; i++) + var _SC_PAGESIZE = 8 + var pri = process.getSystemConfig(_SC_PAGESIZE) + if(pri > 0) { - var pri = Process.getSystemConfig(_SC_ARG_MAX) - if(pri > 0) - { - var flag = true - } - expect(flag).assertEqual(true) + var flag = new Boolean(true) } + expect(flag).assertEqual(true) }) /** @@ -2472,10 +2280,10 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetAvailableCores001', 0, function () { - var pri = Process.getAvailableCores() + var pri = process.getAvailableCores() if(pri != null) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) }) @@ -2487,12 +2295,12 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetAvailableCores002', 0, function () { - for(var i=0; i<3; i++) + for(var i=0; i<10; i++) { - var pri = Process.getAvailableCores() + var pri = process.getAvailableCores() if(pri != 0) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) } @@ -2505,52 +2313,17 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetAvailableCores003', 0, function () { - for(var i=0; i<9; i++) - { - var pri = Process.getAvailableCores() - if(pri != 0) - { - var flag = true - } - expect(flag).assertEqual(true) - } - }) - - /** - * @tc.name: testGetAvailableCores004 - * @tc.desc: Returns cpu cores available for the current process on a multi-core device. - * @tc.require: AR000GFB04 - * @tc.author: liwenqiang - */ - it('testGetAvailableCores004', 0, function () { - for(var i=0; i<12; i++) + for(var i=0; i<100; i++) { - var pri = Process.getAvailableCores() + var pri = process.getAvailableCores() if(pri != 0) { - var flag = true + var flag = new Boolean(true) } expect(flag).assertEqual(true) } }) - /** - * @tc.name: testGetAvailableCores005 - * @tc.desc: Returns cpu cores available for the current process on a multi-core device. - * @tc.require: AR000GFB04 - * @tc.author: liwenqiang - */ - it('testGetAvailableCores005', 0, function () { - for(var i=0; i<18; i++) - { - var pri = Process.getAvailableCores() - if(pri != 0) - { - var flag = true - } - expect(flag).assertEqual(true) - } - }) /** * @tc.name: testGetEnvironmentVar001 @@ -2559,9 +2332,9 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetEnvironmentVar001', 0, function () { - var pri = Process.getEnvironmentVar("USER") + var pri = process.getEnvironmentVar("USER") if(pri != null) { - var flag = true + var flag = new Boolean(true) expect(flag).assertEqual(true) } }) @@ -2573,12 +2346,12 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetEnvironmentVar002', 0, function () { - for(var i=0; i<3; i++) + for(var i=0; i<10; i++) { - var pri = Process.getEnvironmentVar("PATH") + var pri = process.getEnvironmentVar("PATH") if(pri != null) { - var flag = true + var flag = new Boolean(true) expect(flag).assertEqual(true) } } @@ -2591,12 +2364,12 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetEnvironmentVar003', 0, function () { - for(var i=0; i<15; i++) + for(var i=0; i<100; i++) { - var pri = Process.getEnvironmentVar("PATH") + var pri = process.getEnvironmentVar("PATH") if(pri != null) { - var flag = true + var flag = new Boolean(true) expect(flag).assertEqual(true) } } @@ -2609,12 +2382,12 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetEnvironmentVar004', 0, function () { - for(var i=0; i<26; i++) + for(var i=0; i<10; i++) { - var pri = Process.getEnvironmentVar("PATH") + var pri = process.getEnvironmentVar("USER") if(pri != null) { - var flag = true + var flag = new Boolean(true) expect(flag).assertEqual(true) } } @@ -2627,12 +2400,12 @@ describe('ChildProcessTest', function () { * @tc.author: liwenqiang */ it('testGetEnvironmentVar005', 0, function () { - for(var i=0; i<19; i++) + for(var i=0; i<100; i++) { - var pri = Process.getEnvironmentVar("PATH") + var pri = process.getEnvironmentVar("USER") if(pri != null) { - var flag = true + var flag = new Boolean(true) expect(flag).assertEqual(true) } } diff --git a/compileruntime/process_lib_standard/src/main/js/test/Process.test.js.bak b/compileruntime/process_lib_standard/src/main/js/test/Process.test.js.bak new file mode 100644 index 0000000000000000000000000000000000000000..9cef5f9699804e689e76dc02ec5b8e9bad6045ad --- /dev/null +++ b/compileruntime/process_lib_standard/src/main/js/test/Process.test.js.bak @@ -0,0 +1,2410 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite' +import process from '@ohos.process' +describe('ChildProcessTest', function () { + + /** + * @tc.name: testRunCmd001 + * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testRunCmd001', 0, async function () { + var child = process.runCmd('echo abc') + child.wait() + var array = new Uint8Array([97, 98, 99, 10, 0]) + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testRunCmd002 + * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testRunCmd002', 0, async function () { + var child = process.runCmd('echo abc;', { maxBuffer : 2 }) + child.wait() + var array = new Uint8Array([97, 98, 0]) + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testRunCmd003 + * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testRunCmd003', 0, async function () { + var child = process.runCmd('sleep 5; echo abc;', { timeout : 1, killSignal : 9 }) + child.wait() + var array = new Uint8Array([0]) + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + expect(child.exitCode).assertEqual(0) + }) + + /** + * @tc.name: testRunCmd004 + * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testRunCmd004', 0, async function ( ) { + var child = process.runCmd('sleep 2; echo abc;', { timeout : 9000, killSignal : 9 }) + child.wait() + var array = new Uint8Array([97, 98, 99, 10, 0]) + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + expect(child.exitCode).assertEqual(0) + }) + + /** + * @tc.name: testRunCmd005 + * @tc.desc: Return a child process object and spawns a new ChildProcess to run the command. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testRunCmd005', 0, async function ( ) { + var child = process.runCmd('echo abc', { maxBuffer : 1000 }) + child.wait() + var array = new Uint8Array([97, 98, 99, 10, 0]) + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testGetOutput001 + * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetOutput001', 0, async function () { + var child = process.runCmd('echo bcd;') + var array = new Uint8Array([98, 99, 100, 10, 0]) + child.wait(); + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testGetOutput002 + * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetOutput002', 0, async function () { + var child = process.runCmd('echo 123;'); + var array = new Uint8Array([49, 50, 51, 10, 0]); + child.wait(); + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]); + } + }) + }) + + /** + * @tc.name: testGetOutput003 + * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetOutput003', 0, async function () { + var child = process.runCmd('echo helloWorld;'); + var array = new Uint8Array([104, 101, 108, 108, 111, 87, 111, 114, 108, 100, 10, 0]); + child.wait(); + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]); + } + }) + }) + + /** + * @tc.name: testGetOutput004 + * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetOutput004', 0, async function () { + var child = process.runCmd('echo 浣犲?'); + var array = new Uint8Array([228, 189, 160, 229, 165, 189, 10, 0]); + child.wait(); + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]); + } + }) + }) + + /** + * @tc.name: testGetOutput005 + * @tc.desc: return it as 'Uint8Array' of the stdout until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetOutput005', 0, async function () { + var child = process.runCmd('echo ~_~;'); + var array = new Uint8Array([126, 95, 126, 10, 0]); + child.wait(); + child.getOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]); + } + }) + }) + + /** + * @tc.name: testGetErrorOutput001 + * @tc.desc: return it as 'Uint8Array of the stderr until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetErrorOutput001', 0, async function () { + var child = process.runCmd('makdir 1.txt') + child.wait() + var array = new Uint8Array([115, 104, 58, 32, 109, 97, 107, 100, 105, 114, 58, 32, 105, 110, 97, 99, 99, + 101, 115, 115, 105, 98, 108, 101, 32, 111, 114, 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 10, 0]) + child.getErrorOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testGetErrorOutput002 + * @tc.desc: return it as 'Uint8Array of the stderr until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetErrorOutput002', 0, async function () { + var child = process.runCmd('echo "error" 1>&2') + child.wait() + var array = new Uint8Array([101, 114, 111, 114, 10, 0]) + child.getErrorOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testGetErrorOutput003 + * @tc.desc: return it as 'Uint8Array of the stderr until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetErrorOutput003', 0, async function () { + var child = process.runCmd('1') + child.wait() + var array = new Uint8Array([115, 104, 58, 32, 49, 58, 32, 105, 110, 97, 99, 99, 101, 115, 115, 105, 98, + 108, 101, 32, 111, 114, 32, 110, 111, 116, 32, 102, 111, 117, 110, 100, 10, 0]) + child.getErrorOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testGetErrorOutput004 + * @tc.desc: return it as 'Uint8Array of the stderr until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetErrorOutput004', 0, async function () { + var child = process.runCmd('chmod 777 123') + var array = new Uint8Array([99, 104, 109, 111, 100, 58, 32, 49, 50, 51, 58, 32, 78, 111, 32, 115, 117, 99, + 104, 32, 102, 105, 108, 101, 32, 111, 114, 32, 100, 105, 114, 101, 99, 116, 111, 114, 121, 10, 0]); + child.wait(); + child.getErrorOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testGetErrorOutput005 + * @tc.desc: return it as 'Uint8Array of the stderr until EOF. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetErrorOutput005', 0, async function () { + var child = process.runCmd('cp ./1 ./2') + var array = new Uint8Array([99, 112, 58, 32, 98, 97, 100, 32, 39, 46, 47, 49, 39, 58, 32, 78, 111, 32, 115, + 117, 99, 104, 32, 102, 105, 108, 101, 32, 111, 114, 32, 100, 105, 114, 101, 99, 116, 111, 114, 121, 10, 0]) + child.wait(); + child.getErrorOutput().then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testWait001 + * @tc.desc: return 'number' is the targer process exit code. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testWait001', 0, async function () { + var child = process.runCmd('ls') + var status = child.wait() + status.then(val=>{ + expect(val).assertEqual(0) + }) + }) + + /** + * @tc.name: testWait002 + * @tc.desc: return 'number' is the targer process exit code. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testWait002', 0, async function () { + var child = process.runCmd('ls; sleep 5;') + child.kill(9); + var status = child.wait() + status.then(val=>{ + expect(val).assertEqual(9) + }) + }) + + /** + * @tc.name: testWait003 + * @tc.desc: return 'number' is the targer process exit code. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testWait003', 0, async function () { + var child = process.runCmd('echo helloWorld'); + var status = child.wait(); + status.then(val=>{ + expect(val).assertEqual(0); + }) + }) + + /** + * @tc.name: testWait004 + * @tc.desc: return 'number' is the targer process exit code. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testWait004', 0, async function () { + var child = process.runCmd('mkdir 123'); + var status = child.wait(); + status.then(val=>{ + expect(val).assertEqual(256); + }) + }) + + /** + * @tc.name: testWait005 + * @tc.desc: return 'number' is the targer process exit code. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testWait005', 0, async function () { + var child = process.runCmd('sleep 5; echo abc;', { timeout : 1, killSignal : 9 }); + var status = child.wait(); + status.then(val=>{ + expect(val).assertEqual(9); + }) + }) + + /** + * @tc.name: testchildPid001 + * @tc.desc: return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testchildPid001', 0, function () { + var child = process.runCmd('ls; sleep 5;') + child.wait() + var pid_ = child.pid + expect(pid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPid002 + * @tc.desc: return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid002', 0, function () { + var child = process.runCmd('mkdir test.cpp') + child.wait() + var pid_ = child.pid + expect(pid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPid003 + * @tc.desc: return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid003', 0, function () { + var child = process.runCmd('each abc') + child.wait() + var pid_ = child.pid + expect(pid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPid004 + * @tc.desc: return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid004', 0, function () { + var child = process.runCmd('cd ..') + child.wait() + var pid_ = child.pid + expect(pid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPid005 + * @tc.desc: return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid005', 0, function () { + var child = process.runCmd('adc') + child.wait() + var pid_ = child.pid + expect(pid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPpid001 + * @tc.desc: return ppid is the pid of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid001', 0, function () { + var child = process.runCmd('ls; sleep 5;') + var status = child.wait() + var ppid_ = child.ppid + expect(ppid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPpid002 + * @tc.desc: return ppid is the pid of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid002', 0, function () { + var child = process.runCmd('mkdir test.cpp') + child.wait() + var ppid_ = child.ppid + expect(ppid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPpid003 + * @tc.desc: return ppid is the pid of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid003', 0, function () { + var child = process.runCmd('each abc') + child.wait() + var ppid_ = child.ppid + expect(ppid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPpid004 + * @tc.desc: return ppid is the pid of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid004', 0, function () { + var child = process.runCmd('cd ..') + child.wait() + var ppid_ = child.ppid + expect(ppid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testPpid005 + * @tc.desc: return ppid is the pid of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid005', 0, function () { + var child = process.runCmd('adc') + child.wait() + var ppid_ = child.ppid + expect(ppid_ > 0).assertEqual(true) + }) + + /** + * @tc.name: testKill001 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill001', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var result = child.kill(13) + var temp = child.killed + expect(temp).assertEqual(true) + }) + + /** + * @tc.name: testKill002 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill002', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var result = child.kill(1) + var temp = child.killed + expect(temp).assertEqual(true) + }) + + /** + * @tc.name: testKill003 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill003', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var result = child.kill('SIGHUP') + var temp = child.killed + expect(temp).assertEqual(true) + }) + + /** + * @tc.name: testKill004 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill004', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var result = child.kill('ABC') + var temp = child.killed + expect(temp).assertEqual(true) + }) + + /** + * @tc.name: testKill005 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill005', 0, function () { + var child = process.runCmd('ls') + child.wait() + var result = child.kill(9) + var temp = child.killed + expect(temp).assertEqual(false) + }) + + /** + * @tc.name: testClose001 + * @tc.desc: close the target process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testClose001', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var result = child.close() + expect(child.exitCode).assertEqual(9) + }) + + /** + * @tc.name: testClose002 + * @tc.desc: close the target process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testClose002', 0, function () { + var child = process.runCmd('ls') + function sleep(ms, callback) { + setTimeout(callback, ms) + } + sleep(1000, () => {} ) + var result = child.close() + expect(child.exitCode === 0).assertEqual(false) + }) + + /** + * @tc.name: testClose003 + * @tc.desc: close the target process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testClose003', 0, function () { + var child = process.runCmd('ls;') + var status = child.wait() + var result = child.close() + expect(child.exitCode).assertEqual(0) + }) + + /** + * @tc.name: testClose004 + * @tc.desc: close the target process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testClose004', 0, function () { + var child = process.runCmd('ls') + var result = child.close() + expect(child.exitCode).assertEqual(9) + }) + + /** + * @tc.name: testClose005 + * @tc.desc: close the target process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testClose005', 0, function () { + var child = process.runCmd('sleep 5; echo A') + var result = child.close() + var status = child.wait() + expect(child.exitCode).assertEqual(9) + }) + + /** + * @tc.name: testKilled001 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKilled001', 0, function () { + var child = process.runCmd('ls; sleep 1s;') + var result = child.kill(3) + var temp = child.killed + expect(temp).assertEqual(true) + }) + + /** + * @tc.name: testKilled002 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKilled002', 0, function () { + var child = process.runCmd('ls; sleep 1s;') + var result = child.close() + var temp = child.killed + expect(temp).assertEqual(false) + }) + + /** + * @tc.name: testKilled003 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKilled003', 0, function () { + var child = process.runCmd('ls; sleep 1s;') + var status = child.wait() + var result = child.kill(9) + var temp = child.killed + expect(temp).assertEqual(false) + }) + + /** + * @tc.name: testKilled004 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKilled004', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var result = child.kill('SIGHUP') + var temp = child.killed + expect(temp).assertEqual(true) + }) + + /** + * @tc.name: testKilled005 + * @tc.desc: return boolean is whether the current process signal is sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKilled005', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var result = child.kill('1') + var temp = child.killed + expect(temp).assertEqual(true) + }) + + /** + * @tc.name: testExitCode001 + * @tc.desc: return exitCode is the exit code of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testExitCode001', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + var temp = child.kill(9) + child.wait() + var result = child.exitCode + expect(result).assertEqual(9) + }) + + /** + * @tc.name: testExitCode002 + * @tc.desc: return exitCode is the exit code of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testExitCode002', 0, function () { + var child = process.runCmd('ls;') + child.wait() + var result = child.exitCode + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testExitCode003 + * @tc.desc: return exitCode is the exit code of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testExitCode003', 0, function () { + var child = process.runCmd('ls; sleep 5s;') + child.close() + child.wait() + var result = child.exitCode + expect(result).assertEqual(9) + }) + + /** + * @tc.name: testExitCode004 + * @tc.desc: return exitCode is the exit code of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testExitCode004', 0, function () { + var child = process.runCmd('ls') + var temp = child.kill('ABCD') + child.close() + var result = child.exitCode + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testExitCode005 + * @tc.desc: return exitCode is the exit code of the current child process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testExitCode005', 0, function () { + var child = process.runCmd('echo A') + var result= child.wait() + var status = child.close() + expect(child.exitCode).assertEqual(0) + }) + + /** + * @tc.name: testGetUid001 + * @tc.desc: returns the digital user id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetUid001', 0, function () { + var result = process.uid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetUid002 + * @tc.desc: returns the digital user id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetUid002', 0, function () { + for(var i = 0; i < 3; i++){ + var result = process.uid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetUid003 + * @tc.desc: returns the digital user id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetUid003', 0, function () { + for(var i = 0; i < 6; i++){ + var result = process.uid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetUid004 + * @tc.desc: returns the digital user id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetUid004', 0, function () { + for(var i = 0; i < 10; i++){ + var result = process.uid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetUid005 + * @tc.desc: returns the digital user id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetUid005', 0, function () { + for(var i = 0; i < 25; i++){ + var result = process.uid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGid001 + * @tc.desc: returns the numeric group id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGid001', 0, function () { + var result = process.gid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetGid002 + * @tc.desc: returns the numeric group id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGid002', 0, function () { + for(var i = 0; i < 3; i++){ + var result = process.gid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGid003 + * @tc.desc: returns the numeric group id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGid003', 0, function () { + for(var i = 0; i < 5; i++){ + var result = process.gid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGid004 + * @tc.desc: returns the numeric group id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGid004', 0, function () { + for(var i = 0; i < 10; i++){ + var result = process.gid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGid005 + * @tc.desc: returns the numeric group id of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGid005', 0, function () { + for(var i = 0; i < 9; i++){ + var result = process.gid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEuid001 + * @tc.desc: return the numeric valid user identity of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEuid001', 0, function () { + var result = process.euid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetEuid002 + * @tc.desc: return the numeric valid user identity of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEuid002', 0, function () { + for(var i = 0; i < 3; i++){ + var result = process.euid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEuid003 + * @tc.desc: return the numeric valid user identity of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEuid003', 0, function () { + for(var i = 0; i < 5; i++){ + var result = process.euid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEuid004 + * @tc.desc: return the numeric valid user identity of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEuid004', 0, function () { + for(var i = 0; i < 8; i++){ + var result = process.euid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEuid005 + * @tc.desc: return the numeric valid user identity of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEuid005', 0, function () { + for(var i = 0; i < 15; i++){ + var result = process.euid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEgid001 + * @tc.desc: returns the numeric valid group ID of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEgid001', 0, function () { + var result = process.egid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetEgid002 + * @tc.desc: returns the numeric valid group ID of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEgid002', 0, function () { + for(var i = 0; i < 3; i++){ + var result = process.egid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEgid003 + * @tc.desc: returns the numeric valid group ID of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEgid003', 0, function () { + for(var i = 0; i < 5; i++){ + var result = process.egid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEgid004 + * @tc.desc: returns the numeric valid group ID of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEgid004', 0, function () { + for(var i = 0; i < 15; i++){ + var result = process.egid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEgid005 + * @tc.desc: returns the numeric valid group ID of the process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetEgid005', 0, function () { + for(var i = 0; i < 26; i++){ + var result = process.egid + if(result != null) { + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGroups001 + * @tc.desc: return an array with supplementary group id. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGroups001', 0, function () { + var result = process.groups + var len = result.length + if(len > 0) { + var flag = true + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetGroups002 + * @tc.desc: return an array with supplementary group id. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGroups002', 0, function () { + for(var i = 0; i < 3; i++){ + var result = process.groups + if(result != null) { + var len = result.length + if(len > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGroups003 + * @tc.desc: return an array with supplementary group id. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGroups003', 0, function () { + for(var i = 0; i < 5; i++){ + var result = process.groups + if(result != null) { + var len = result.length + if(len > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGroups004 + * @tc.desc: return an array with supplementary group id. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGroups004', 0, function () { + for(var i = 0; i < 18; i++){ + var result = process.groups + if(result != null) { + var len = result.length + if(len > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetGroups005 + * @tc.desc: return an array with supplementary group id. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testGetGroups005', 0, function () { + for(var i = 0; i < 28; i++){ + var result = process.groups + if(result != null) { + var len = result.length + if(len > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testChdir001 + * @tc.desc: Change current directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testChdir001', 0, function () { + var result = process.chdir('/system') + var result1 = process.cwd() + expect(result1).assertEqual('/system') + }) + + /** + * @tc.name: testChdir002 + * @tc.desc: Change current directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testChdir002', 0, function () { + var result = process.chdir('/system/lib') + var result1 = process.cwd() + expect(result1).assertEqual('/system/lib') + }) + + /** + * @tc.name: testChdir003 + * @tc.desc: Change current directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testChdir003', 0, function () { + var result = process.chdir('/..') + var result1 = process.cwd() + expect(result1).assertEqual('/') + }) + + /** + * @tc.name: testChdir004 + * @tc.desc: Change current directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testChdir004', 0, function () { + var result = process.chdir('/system/app') + var result1 = process.cwd() + expect(result1).assertEqual('/system/app') + }) + + /** + * @tc.name: testChdir005 + * @tc.desc: Change current directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testChdir005', 0, function () { + var result = process.chdir('/data') + var result1 = process.cwd() + expect(result1).assertEqual('/data') + }) + + /** + * @tc.name: testKill001 + * @tc.desc: Return whether the signal was sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill001', 0, function () { + var result = process.kill(123, 3) + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testKill002 + * @tc.desc: Return whether the signal was sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill002', 0, function () { + var pres = process.pid + var result = process.kill(pres, 23) + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testKill003 + * @tc.desc: Return whether the signal was sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill003', 0, function () { + var pres = process.pid + var result = process.kill(pres, 28) + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testKill004 + * @tc.desc: Return whether the signal was sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill004', 0, function () { + var pres = process.pid + var result = process.kill(pres, 17) + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testKill005 + * @tc.desc: Return whether the signal was sent successfully. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testKill005', 0, function () { + var result = process.kill(113, 3) + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testUptime001 + * @tc.desc: Returns the running time of the system. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testUptime001', 0, function () { + var result1 = process.uptime() + function sleep(d){ + while(process.uptime() - result1 <= d); + } + sleep(5); + var result2 = process.uptime() - 6 + expect(result1).assertEqual(result2) + }) + + /** + * @tc.name: testUptime002 + * @tc.desc: Returns the running time of the system. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testUptime002', 0, function () { + var result1 = process.uptime() + function sleep(d){ + while(process.uptime() - result1 <= d); + } + sleep(8); + var result2 = process.uptime() - 9 + expect(result1).assertEqual(result2) + }) + + /** + * @tc.name: testUptime003 + * @tc.desc: Returns the running time of the system. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testUptime003', 0, function () { + var result1 = process.uptime() + function sleep(d){ + while(process.uptime() - result1 <= d); + } + sleep(10); + var result2 = process.uptime() - 11 + expect(result1).assertEqual(result2) + }) + + /** + * @tc.name: testUptime004 + * @tc.desc: Returns the running time of the system. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testUptime004', 0, function () { + var result1 = process.uptime() + function sleep(d){ + while(process.uptime() - result1 <= d); + } + sleep(7); + var result2 = process.uptime() - 8 + expect(result1).assertEqual(result2) + }) + + /** + * @tc.name: testUptime005 + * @tc.desc: Returns the running time of the system. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testUptime005', 0, function () { + var result1 = process.uptime() + function sleep(d){ + while(process.uptime() - result1 <= d); + } + sleep(11); + var result2 = process.uptime() - 12 + expect(result1).assertEqual(result2) + }) + + /** + * @tc.name: testPid001 + * @tc.desc: Return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid001', 0, function () { + var result = process.pid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testPid002 + * @tc.desc: Return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid002', 0, function () { + for(var i = 0; i < 3; i++) + { + var result = process.pid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testPid003 + * @tc.desc: Return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid003', 0, function () { + for(var i = 0; i < 5; i++) + { + var result = process.pid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testPid004 + * @tc.desc: Return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid004', 0, function () { + for(var i = 0; i < 10; i++) + { + var result = process.pid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testPid005 + * @tc.desc: Return pid is the pid of the current process. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPid005', 0, function () { + for(var i = 0; i < 28; i++) + { + var result = process.pid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testPpid001 + * @tc.desc: Return ppid is the pid of the current child process + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid001', 0, function () { + var result = process.ppid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testPpid002 + * @tc.desc: Return ppid is the pid of the current child process + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid002', 0, function () { + for(var i = 0; i < 3; i++) + { + var result = process.ppid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testPpid003 + * @tc.desc: Return ppid is the pid of the current child process + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid003', 0, function () { + for(var i = 0; i < 5; i++) + { + var result = process.ppid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testPpid004 + * @tc.desc: Return ppid is the pid of the current child process + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid004', 0, function () { + for(var i = 0; i < 16; i++) + { + var result = process.ppid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testPpid005 + * @tc.desc: Return ppid is the pid of the current child process + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testPpid005', 0, function () { + for(var i = 0; i < 28; i++) + { + var result = process.ppid + if(result > 0) { + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testCwd001 + * @tc.desc: Return the current work directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testCwd001', 0, function () { + var cwdir = process.cwd() + if(cwdir){ + var flag = true + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testCwd002 + * @tc.desc: Return the current work directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testCwd002', 0, function () { + for(var i = 0; i < 3; i++) + { + var cwdir = process.cwd() + if(cwdir){ + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testCwd003 + * @tc.desc: Return the current work directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testCwd003', 0, function () { + for(var i = 0; i < 10; i++) + { + var cwdir = process.cwd() + if(cwdir){ + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testCwd004 + * @tc.desc: Return the current work directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testCwd004', 0, function () { + for(var i = 0; i < 18; i++) + { + var cwdir = process.cwd() + if(cwdir){ + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testCwd005 + * @tc.desc: Return the current work directory. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testCwd005', 0, function () { + for(var i = 0; i < 29; i++) + { + var cwdir = process.cwd() + if(cwdir){ + var flag = true + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testOn001 + * @tc.desc: Register for an event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOn001', 0, function () { + function add(){ + var value = 3 + 2 + } + var ontest = process.on(1, add) + expect(ontest).assertEqual(false) + }) + + /** + * @tc.name: testOn002 + * @tc.desc: Register for an event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOn002', 0, function () { + function add1(num){ + var value = num + 3 + } + var on = process.on("add123", add1) + }) + + /** + * @tc.name: testOn003 + * @tc.desc: Register for an event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOn003', 0, function () { + function add2(num0, num1){ + var value = num0 + num1 + } + var ontest = process.on(879, add2) + expect(ontest).assertEqual(false) + }) + + /** + * @tc.name: testOn004 + * @tc.desc: Register for an event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOn004', 0, function () { + function add3(num0, num1){ + var value = num0 + num1 + } + var ontest = process.on(12345, add3) + expect(ontest).assertEqual(false) + }) + + /** + * @tc.name: testOn005 + * @tc.desc: Register for an event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOn005', 0, function () { + function add4(num0, num1){ + var value = num0 + num1 + } + var ontest = process.on(1000, add4) + expect(ontest).assertEqual(false) + }) + + /** + * @tc.name: testOff001 + * @tc.desc: Remove registered event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOff001', 0, function () { + function add1(num){ + var value = num + 3 + } + var on = process.on("add123", add1) + var offtest = process.off("add123") + expect(offtest).assertEqual(true) + }) + + /** + * @tc.name: testOff002 + * @tc.desc: Remove registered event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOff002', 0, function () { + var offtest = process.off("123") + expect(offtest).assertEqual(false) + }) + + /** + * @tc.name: testOff003 + * @tc.desc: Remove registered event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOff003', 0, function () { + var offtest = process.off("456") + expect(offtest).assertEqual(false) + }) + + /** + * @tc.name: testOff004 + * @tc.desc: Remove registered event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOff004', 0, function () { + function add1(num){ + var value = num + 3 + } + var on = process.on("function_add1", add1) + var offtest = process.off("function_add1") + expect(offtest).assertEqual(true) + }) + + /** + * @tc.name: testOff005 + * @tc.desc: Remove registered event. + * @tc.require: AR000GFB2S + * @tc.author: wangben + */ + it('testOff005', 0, function () { + function add1(num){ + var value = num + 3 + } + var on = process.on("add", add1) + var offtest = process.off("add") + expect(offtest).assertEqual(true) + }) + + /** + * @tc.name: testTid001 + * @tc.desc: Returns the tid of the current thread. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testTid001', 0, function () { + var pres = process.tid + if(pres > 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testTid002 + * @tc.desc: Returns the tid of the current thread. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testTid002', 0, function () { + for(var i=0; i<10; i++) + { + var pres = process.tid + if(pres > 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testTid003 + * @tc.desc: Returns the tid of the current thread. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testTid003', 0, function () { + for(var i=0; i<1000; i++) + { + var pres = process.tid + if(pres > 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + } + }) + + + /** + * @tc.name: testIsisolatedProcess001 + * @tc.desc: Returns a boolean whether the process is isolated. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testIsisolatedProcess001', 0, function () { + var pres = process.isIsolatedProcess() + expect(pres).assertEqual(false) + }) + + /** + * @tc.name: testIsisolatedProcess002 + * @tc.desc: Returns a boolean whether the process is isolated. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testIsisolatedProcess002', 0, function () { + for(var i=0; i<10; i++) + { + var pres =process.isIsolatedProcess() + expect(pres).assertEqual(false) + } + }) + + /** + * @tc.name: testIsisolatedProcess003 + * @tc.desc: Returns a boolean whether the process is isolated. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testIsisolatedProcess003', 0, function () { + for(var i=0; i<1000; i++) + { + var pres =process.isIsolatedProcess() + expect(pres).assertEqual(false) + } + }) + + + /** + * @tc.name: testIsappuid001 + * @tc.desc: Returns a boolean whether the specified uid belongs to a particular application. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testIsappuid001', 0, function () { + var appUid = process.uid + var isorno = process.isAppUid(appUid) + expect(isorno).assertEqual(true) + }) + + /** + * @tc.name: testIsappuid002 + * @tc.desc: Returns a boolean whether the specified uid belongs to a particular application. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testIsappuid002', 0, function () { + var isorno = process.isAppUid(123) + expect(isorno).assertEqual(false) + }) + + /** + * @tc.name: testIsappuid003 + * @tc.desc: Returns a boolean whether the specified uid belongs to a particular application. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testIsappuid003', 0, function () { + var isorno = process.isAppUid(80000) + expect(isorno).assertEqual(false) + }) + + /** + * @tc.name: testIsappuid004 + * @tc.desc: Returns a boolean whether the specified uid belongs to a particular application. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testIsappuid004', 0, function () { + var isorno = process.isAppUid(789) + expect(isorno).assertEqual(false) + }) + + /** + * @tc.name: testIsappuid005 + * @tc.desc: Returns a boolean whether the specified uid belongs to a particular application. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testIsappuid005', 0, function () { + var isorno = process.isAppUid(8569) + expect(isorno).assertEqual(false) + }) + + /** + * @tc.name: testIs64Bit001 + * @tc.desc: Returns a boolean whether the process is running in a 64-bit environment. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testIs64Bit001', 0, function () { + var isorno = process.is64Bit() + expect(isorno).assertEqual(false) + }) + + /** + * @tc.name: testIs64Bit002 + * @tc.desc: Returns a boolean whether the process is running in a 64-bit environment. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testIs64Bit002', 0, function () { + for(var i=0; i<10; i++) + { + var isorno = process.is64Bit() + expect(isorno).assertEqual(false) + } + }) + + /** + * @tc.name: testIs64Bit003 + * @tc.desc: Returns a boolean whether the process is running in a 64-bit environment. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testIs64Bit003', 0, function () { + for(var i=0; i<1000; i++) + { + var isorno = process.is64Bit() + expect(isorno).assertEqual(false) + } + }) + + + /** + * @tc.name: testGetuidforname001 + * @tc.desc: Returns the uid based on the specified user name. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetuidforname001',0, function () { + var pres = process.getUidForName("root") + if(pres != -1) + { + var flag = new Boolean(true) + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testGetuidforname002 + * @tc.desc: Returns the uid based on the specified user name. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetuidforname002', 0, function () { + for(var i=0; i<10; i++) + { + var pres = process.getUidForName("12356") + expect(pres).assertEqual(-1) + } + }) + + /** + * @tc.name: testGetuidforname003 + * @tc.desc: Returns the uid based on the specified user name. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetuidforname003', 0, function () { + for(var i=0; i<1000; i++) + { + var pres = process.getUidForName("12356") + expect(pres).assertEqual(-1) + } + }) + + + /** + * @tc.name: testGetthreadpriority001 + * @tc.desc: Returns the thread priority based on the specified tid. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetthreadpriority001', 0, function () { + var pres = process.tid + var pri = process.getThreadPriority(pres) + if(pri) + { + var flag = new Boolean(true) + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testGetthreadpriority002 + * @tc.desc: Returns the thread priority based on the specified tid. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetthreadpriority002', 0, function () { + var pres = process.tid + for(var i=0; i<10; i++) + { + var pri = process.getThreadPriority(pres) + if(pri > 0) + { + var flag = new Boolean(true) + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetthreadpriority003 + * @tc.desc: Returns the thread priority based on the specified tid. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetthreadpriority003', 0, function () { + var pres = process.tid + for(var i=0; i<1000; i++) + { + var pri = process.getThreadPriority(pres) + if(pri > 0) + { + var flag = new Boolean(true) + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetstartrealtime001 + * @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of + the system to the start of the process. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetstartrealtime001', 0, function () { + for(var i=0; i<10; i++) + { + var pri = process.getStartRealtime() + if(pri !== null) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testGetstartrealtime002 + * @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of the system to the start of the process. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetstartrealtime002', 0, function () { + var pri = process.getStartRealtime() + if(pri !== null) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetstartrealtime003 + * @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of the system to the start of the process. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetstartrealtime003', 0, function () { + for(var i=0; i<100; i++) + { + var pri = process.getStartRealtime() + if(pri !== null) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testGetstartrealtime004 + * @tc.desc: Returns the elapsed real time (in milliseconds) taken from the start of the system to the start of the process. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetstartrealtime004', 0, function () { + for(var i=0; i<1000; i++) + { + var pri = process.getPastCputime() + if(pri > 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testGetpastCputime001 + * @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetpastCputime001', 0, function () { + for(var i=0; i<10; i++) + { + var pri = process.getStartRealtime() + if(pri > 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testGetpastCputime002 + * @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetpastCputime002', 0, function () { + var pri = process.getPastCputime() + if(pri > 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetpastCputime003 + * @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetpastCputime003', 0, function () { + for(var i=0; i<100; i++) + { + var pri = process.getPastCputime() + if(pri > 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testGetpastCputime004 + * @tc.desc: Returns the cpu time (in milliseconds) from the time when the process starts to the current time. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetpastCputime004', 0, function () { + for(var i=0; i<1000; i++) + { + var pri = process.getPastCputime() + if(pri > 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testGetSystemConfig001 + * @tc.desc: Returns the system configuration at runtime. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetSystemConfig001', 0, function () { + var _SC_ARG_MAX = 0 + var pri = process.getSystemConfig(_SC_ARG_MAX) + if(pri > 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetSystemConfig002 + * @tc.desc: Returns the system configuration at runtime. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetSystemConfig002', 0, function () { + var _SC_ARG_MAX = 0 + for(var i=0; i<10; i++) + { + var pri = process.getSystemConfig(_SC_ARG_MAX) + if(pri > 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testGetSystemConfig003 + * @tc.desc: Returns the system configuration at runtime. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetSystemConfig003', 0, function () { + var _SC_ARG_MAX = 0 + for(var i=0; i<100; i++) + { + var pri = process.getSystemConfig(_SC_ARG_MAX) + if(pri > 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testGetSystemConfig004 + * @tc.desc: Returns the system configuration at runtime. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetSystemConfig004', 0, function () { + var _SC_OPEN_MAX = 4 + var pri = process.getSystemConfig(_SC_OPEN_MAX) + if(pri > 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetSystemConfig005 + * @tc.desc: Returns the system configuration at runtime. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetSystemConfig005', 0, function () { + var _SC_PAGESIZE = 8 + var pri = process.getSystemConfig(_SC_PAGESIZE) + if(pri > 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetAvailableCores001 + * @tc.desc: Returns cpu cores available for the current process on a multi-core device. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetAvailableCores001', 0, function () { + var pri = process.getAvailableCores() + if(pri != null) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + }) + + /** + * @tc.name: testGetAvailableCores002 + * @tc.desc: Returns cpu cores available for the current process on a multi-core device. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetAvailableCores002', 0, function () { + for(var i=0; i<10; i++) + { + var pri = process.getAvailableCores() + if(pri != 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testGetAvailableCores003 + * @tc.desc: Returns cpu cores available for the current process on a multi-core device. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetAvailableCores003', 0, function () { + for(var i=0; i<100; i++) + { + var pri = process.getAvailableCores() + if(pri != 0) + { + var flag = new Boolean(true) + } + expect(flag).assertEqual(true) + } + }) + + + /** + * @tc.name: testGetEnvironmentVar001 + * @tc.desc: Returns the system value for environment variables. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetEnvironmentVar001', 0, function () { + var pri = process.getEnvironmentVar("USER") + if(pri != null) { + var flag = new Boolean(true) + expect(flag).assertEqual(true) + } + }) + + /** + * @tc.name: testGetEnvironmentVar002 + * @tc.desc: Returns the system value for environment variables. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetEnvironmentVar002', 0, function () { + for(var i=0; i<10; i++) + { + var pri = process.getEnvironmentVar("PATH") + if(pri != null) + { + var flag = new Boolean(true) + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEnvironmentVar003 + * @tc.desc: Returns the system value for environment variables. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetEnvironmentVar003', 0, function () { + for(var i=0; i<100; i++) + { + var pri = process.getEnvironmentVar("PATH") + if(pri != null) + { + var flag = new Boolean(true) + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEnvironmentVar004 + * @tc.desc: Returns the system value for environment variables. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetEnvironmentVar004', 0, function () { + for(var i=0; i<10; i++) + { + var pri = process.getEnvironmentVar("USER") + if(pri != null) + { + var flag = new Boolean(true) + expect(flag).assertEqual(true) + } + } + }) + + /** + * @tc.name: testGetEnvironmentVar005 + * @tc.desc: Returns the system value for environment variables. + * @tc.require: AR000GFB04 + * @tc.author: liwenqiang + */ + it('testGetEnvironmentVar005', 0, function () { + for(var i=0; i<100; i++) + { + var pri = process.getEnvironmentVar("USER") + if(pri != null) + { + var flag = new Boolean(true) + expect(flag).assertEqual(true) + } + } + }) +}) \ No newline at end of file diff --git a/compileruntime/process_lib_standard/src/main/resources/base/media/icon.png b/compileruntime/process_lib_standard/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/compileruntime/process_lib_standard/src/main/resources/base/media/icon.png differ diff --git a/compileruntime/process_lib_standard/src/ohosTest/js/default/pages/index/index.css b/compileruntime/process_lib_standard/src/ohosTest/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/compileruntime/process_lib_standard/src/ohosTest/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/compileruntime/process_lib_standard/src/ohosTest/js/default/pages/index/index.js b/compileruntime/process_lib_standard/src/ohosTest/js/default/pages/index/index.js deleted file mode 100644 index f5d8c4c162c14daa197c1e62f30a1749beeaf925..0000000000000000000000000000000000000000 --- a/compileruntime/process_lib_standard/src/ohosTest/js/default/pages/index/index.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import file from '@system.file' -import app from '@system.app' -import device from '@system.device' -import router from '@system.router' -import {Core, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - const instrumentLog = new InstrumentLog({ - 'id': 'report' - }) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.addService('report', instrumentLog) - core.init() - core.subscribeEvent('spec', instrumentLog) - core.subscribeEvent('suite', instrumentLog) - core.subscribeEvent('task', instrumentLog) - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} \ No newline at end of file diff --git a/compileruntime/process_lib_standard/src/ohosTest/js/test/ExampleJsunit.test.js b/compileruntime/process_lib_standard/src/ohosTest/js/test/ExampleJsunit.test.js deleted file mode 100644 index 13f684d1378b3571985a59ce155fd1308b759a88..0000000000000000000000000000000000000000 --- a/compileruntime/process_lib_standard/src/ohosTest/js/test/ExampleJsunit.test.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import app from '@system.app' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' - -describe('appInfoTest', function () { - it('app_info_test_001', 0, function () { - var info = app.getInfo() - expect(info.versionName).assertEqual('1.0') - expect(info.versionCode).assertEqual('3') - }) -}) \ No newline at end of file diff --git a/compileruntime/process_lib_standard/src/ohosTest/resources/base/element/string.json b/compileruntime/process_lib_standard/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index 757cc9dc2301c1b3f60ffe9c69f4508cf79aca06..0000000000000000000000000000000000000000 --- a/compileruntime/process_lib_standard/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "childprocess" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - } - ] -} \ No newline at end of file diff --git a/compileruntime/uri_lib_standard/BUILD.gn b/compileruntime/uri_lib_standard/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..dd6d2008da811cec3f33972c1d5720cb7f4972e9 --- /dev/null +++ b/compileruntime/uri_lib_standard/BUILD.gn @@ -0,0 +1,39 @@ +# Copyright (C) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") +ohos_js_hap_suite("uri_js_test") { + hap_profile = "./src/main/config.json" + js2abc = true + deps = [ + ":uri_js_assets", + ":uri_resources", + ] + + # shared_libraries = [ + # "//third_party/giflib:libgif", + # "//third_party/libpng:libpng", + # ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "UriJSApiTest" + + # part_name = "prebuilt_hap" + # subsystem_name = "xts" +} +ohos_js_assets("uri_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("uri_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/compileruntime/uri_lib_standard/Test.json b/compileruntime/uri_lib_standard/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..65f6393aea25dbb7cadc9d33b7bf410a0417d1f7 --- /dev/null +++ b/compileruntime/uri_lib_standard/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for startup uri js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.uri", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "UriJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/compileruntime/uri_lib_standard/signature/openharmony_sx.p7b b/compileruntime/uri_lib_standard/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/compileruntime/uri_lib_standard/signature/openharmony_sx.p7b differ diff --git a/compileruntime/uri_lib_standard/src/main/config.json b/compileruntime/uri_lib_standard/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..2748fa0a83491be1a61ba43fa4b0e4085593c489 --- /dev/null +++ b/compileruntime/uri_lib_standard/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "com.example.uri", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.uri", + "name": ".MyApplication", + "mainAbility": "com.example.uri.MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.uri.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": true + } + } + ] + } +} \ No newline at end of file diff --git a/compileruntime/uri_lib_standard/src/main/js/default/app.js b/compileruntime/uri_lib_standard/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..e423f4bce4698ec1d7dc86c3eea3990a5e7b1085 --- /dev/null +++ b/compileruntime/uri_lib_standard/src/main/js/default/app.js @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/compileruntime/util_lib_standard/src/ohosTest/js/default/i18n/en-US.json b/compileruntime/uri_lib_standard/src/main/js/default/i18n/en-US.json similarity index 77% rename from compileruntime/util_lib_standard/src/ohosTest/js/default/i18n/en-US.json rename to compileruntime/uri_lib_standard/src/main/js/default/i18n/en-US.json index 55561b83737c3c31d082fbfa11e5fc987a351104..e63c70d978a3a53be988388c87182f81785e170c 100644 --- a/compileruntime/util_lib_standard/src/ohosTest/js/default/i18n/en-US.json +++ b/compileruntime/uri_lib_standard/src/main/js/default/i18n/en-US.json @@ -2,7 +2,5 @@ "strings": { "hello": "Hello", "world": "World" - }, - "Files": { } } \ No newline at end of file diff --git a/compileruntime/process_lib_standard/src/ohosTest/js/default/i18n/zh-CN.json b/compileruntime/uri_lib_standard/src/main/js/default/i18n/zh-CN.json similarity index 77% rename from compileruntime/process_lib_standard/src/ohosTest/js/default/i18n/zh-CN.json rename to compileruntime/uri_lib_standard/src/main/js/default/i18n/zh-CN.json index cce1af06761a42add0cac1a0567aa3237eda8cb4..de6ee5748322f44942c1b003319d8e66c837675f 100644 --- a/compileruntime/process_lib_standard/src/ohosTest/js/default/i18n/zh-CN.json +++ b/compileruntime/uri_lib_standard/src/main/js/default/i18n/zh-CN.json @@ -2,7 +2,5 @@ "strings": { "hello": "您好", "world": "世界" - }, - "Files": { } } \ No newline at end of file diff --git a/compileruntime/uri_lib_standard/src/main/js/default/pages/index/index.css b/compileruntime/uri_lib_standard/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2b1965821483f4f8c8b97c86ef07fe87ea767d01 --- /dev/null +++ b/compileruntime/uri_lib_standard/src/main/js/default/pages/index/index.css @@ -0,0 +1,44 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 40px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #FFFFFF; + } +} + +@media screen and (device-type: tv) { + .container { + background-image: url("../../common/images/Wallpaper.png"); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + + .title { + font-size: 100px; + color: #FFFFFF; + } +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} diff --git a/compileruntime/url_lib_standard/src/ohosTest/js/default/pages/index/index.hml b/compileruntime/uri_lib_standard/src/main/js/default/pages/index/index.hml similarity index 67% rename from compileruntime/url_lib_standard/src/ohosTest/js/default/pages/index/index.hml rename to compileruntime/uri_lib_standard/src/main/js/default/pages/index/index.hml index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..abeadefb6faa934b6dc51d6bbcf66b765485e5ad 100644 --- a/compileruntime/url_lib_standard/src/ohosTest/js/default/pages/index/index.hml +++ b/compileruntime/uri_lib_standard/src/main/js/default/pages/index/index.hml @@ -1,4 +1,4 @@ -
+
{{ $t('strings.hello') }} {{ title }} diff --git a/compileruntime/util_lib_standard/src/ohosTest/js/default/pages/index/index.js b/compileruntime/uri_lib_standard/src/main/js/default/pages/index/index.js similarity index 60% rename from compileruntime/util_lib_standard/src/ohosTest/js/default/pages/index/index.js rename to compileruntime/uri_lib_standard/src/main/js/default/pages/index/index.js index 9b041d7007852ac57c688654fb8f42c2c9ac9a51..235baf671486069cea33d4746d310e86962fe25c 100644 --- a/compileruntime/util_lib_standard/src/ohosTest/js/default/pages/index/index.js +++ b/compileruntime/uri_lib_standard/src/main/js/default/pages/index/index.js @@ -17,7 +17,7 @@ import file from '@system.file' import app from '@system.app' import device from '@system.device' import router from '@system.router' -import {Core, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index' +import {Core} from 'deccjsunit/lite' export default { data: { @@ -29,27 +29,11 @@ export default { onShow() { console.info('onShow finish') const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - const instrumentLog = new InstrumentLog({ - 'id': 'report' - }) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.addService('report', instrumentLog) core.init() - core.subscribeEvent('spec', instrumentLog) - core.subscribeEvent('suite', instrumentLog) - core.subscribeEvent('task', instrumentLog) - - const configService = core.getDefaultService('config') - configService.setConfig(this) - require('../../../test/List.test') core.execute() }, onReady() { }, -} \ No newline at end of file +} + diff --git a/compileruntime/url_lib_standard/src/ohosTest/js/test/List.test.js b/compileruntime/uri_lib_standard/src/main/js/test/List.test.js similarity index 94% rename from compileruntime/url_lib_standard/src/ohosTest/js/test/List.test.js rename to compileruntime/uri_lib_standard/src/main/js/test/List.test.js index 86ae9fa262b8d3fa27e4ac734dbd529d37d0b7cd..72ee52203cee7d86c5185df1b0b65806e63ec21b 100644 --- a/compileruntime/url_lib_standard/src/ohosTest/js/test/List.test.js +++ b/compileruntime/uri_lib_standard/src/main/js/test/List.test.js @@ -13,4 +13,4 @@ * limitations under the License. */ -require('./ExampleJsunit.test.js') \ No newline at end of file +require('./uri.test.js') \ No newline at end of file diff --git a/compileruntime/uri_lib_standard/src/main/js/test/uri.test.js b/compileruntime/uri_lib_standard/src/main/js/test/uri.test.js new file mode 100644 index 0000000000000000000000000000000000000000..283f53717e61dd27309be31b3f9f165fc9c056a9 --- /dev/null +++ b/compileruntime/uri_lib_standard/src/main/js/test/uri.test.js @@ -0,0 +1,804 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite' +import Uri from '@ohos.uri' +describe('UriTest', function () { + + /** + * @tc.name: testConstructor001 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor001', 0, function () { + try { + let that = new Uri.URI('#http://username:password@host:8080/directory/file?foo=1&bar=2'); + } catch (err) { + expect(err).assertEqual("Error: #It can't be the first"); + } + }) + + /** + * @tc.name: testConstructor002 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor002', 0, function () { + try { + let that = new Uri.URI({name: 'gaogao'}); + } catch (err) { + expect(err).assertEqual("Error: input type err"); + } + }) + + /** + * @tc.name: testConstructor003 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor003', 0, function () { + try { + let that = new Uri.URI('ht/tp://username:pas sword@host:8080/directory/file?foo=1&bar=2'); + } catch (err) { + expect(err).assertEqual("Error: SpecialPath does not conform to the rule"); + } + }) + + /** + * @tc.name: testConstructor004 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor004', 0, function () { + try { + let that = new Uri.URI('http://username:password@[::]:8080/directory/file?Query#gaogao faofao'); + } catch (err) { + expect(err).assertEqual("Error: Fragment does not conform to the rule"); + } + }) + + /** + * @tc.name: testConstructor005 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor005', 0, function () { + try { + let that = new Uri.URI('http://username:password@host:8080/directory/file?foo^=1&bar=2#gaogaofaofao'); + } catch (err) { + expect(err).assertEqual("Error: Query does not conform to the rule"); + } + }) + + /** + * @tc.name: testConstructor006 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor006', 0, function () { + try { + let that = new Uri.URI('1http://username:password@host:8080/directory/file?foo=1&bar=2#gaogaofaofao'); + } catch (err) { + expect(err).assertEqual("Error: Scheme the first character must be a letter"); + } + }) + + /** + * @tc.name: testConstructor007 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor007', 0, function () { + try { + let that = new Uri.URI('ht@tp://username:password@host:8080/directory/file?foo=1&bar=2#gaogaofaofao'); + } catch (err) { + expect(err).assertEqual("Error: scheme does not conform to the rule"); + } + }) + + /** + * @tc.name: testConstructor008 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor008', 0, function () { + try { + let that = new Uri.URI('http://username:password@[::]:80r80/directory/file?foo=1&bar=2#gaogaofaofao'); + } catch (err) { + expect(err).assertEqual("Error: Prot does not conform to the rule"); + } + }) + + /** + * @tc.name: testConstructor009 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor009', 0, function () { + try { + let that = new Uri.URI('http://username:password@[::12:55:8080/directory/file?foo=1&bar=2#gaogaofaofao'); + } catch (err) { + expect(err).assertEqual("Error: IPv6 is missing a closing bracket"); + } + }) + + /** + * @tc.name: testConstructor010 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor010', 0, function () { + try { + let that = new Uri.URI('http://username:pa^ssword@[::12:55]:8080/directory/file?foo=1&bar=2#gaogaofaofao'); + } catch (err) { + expect(err).assertEqual("Error: userInfo does not conform to the rule"); + } + }) + + /** + * @tc.name: testConstructor011 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor011', 0, function () { + try { + let that = new Uri.URI('http://username:password@[::1你2:55]:8080/directory/file?foo=1&bar=2#gaogaofaofao'); + } catch (err) { + expect(err).assertEqual("Error: ipv6 does not conform to the rule"); + } + }) + + /** + * @tc.name: testConstructor012 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor012', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@www.baidu.com:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@www.baidu.com:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("www.baidu.com"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor013 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor013', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1080::8:800:200C:417A]:99/path/66path1?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[1080::8:800:200C:417A]:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[1080::8:800:200C:417A]:99/path/66path1?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[1080::8:800:200C:417A]"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/66path1"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor014 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor014', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[::]:88/path/path66?foooo#gaogao'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[::]:88"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[::]:88/path/path66?foooo"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[::]"); + expect(gaogao.port).assertEqual("88"); + expect(gaogao.path).assertEqual("/path/path66"); + expect(gaogao.query).assertEqual("foooo"); + expect(gaogao.fragment).assertEqual("gaogao"); + }) + + /** + * @tc.name: testConstructor015 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor015', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66path1?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[1:0:0:1:2:1:2:1]:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66path1?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[1:0:0:1:2:1:2:1]"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/66path1"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor016 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor016', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[::FFFF:129.144.52.38]:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[::FFFF:129.144.52.38]:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[::FFFF:129.144.52.38]:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[::FFFF:129.144.52.38]"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor017 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor017', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[::192.9.5.5]:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[::192.9.5.5]:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[::192.9.5.5]:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[::192.9.5.5]"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor018 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor018', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[22::22:2:2%ss]:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[22::22:2:2%ss]:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[22::22:2:2%ss]:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[22::22:2:2%ss]"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor019 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor019', 0, function () { + let gaogao = + new Uri.URI('http://gg:gaogao@[fe80:0000:0001:0000:0440:44ff:1233:5678]:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[fe80:0000:0001:0000:0440:44ff:1233:5678]:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[fe80:0000:0001:0000:0440:44ff:1233:5678]:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[fe80:0000:0001:0000:0440:44ff:1233:5678]"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor020 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor020', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[fe80::0001:0000]:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[fe80::0001:0000]:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[fe80::0001:0000]:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[fe80::0001:0000]"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor021 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor021', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@199.98.55.44:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@199.98.55.44:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@199.98.55.44:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("199.98.55.44"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor022 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor022', 0, function () { + let gaogao = new Uri.URI('http://16.9.5.4:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("16.9.5.4:99"); + expect(gaogao.ssp).assertEqual("//16.9.5.4:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("null"); + expect(gaogao.host).assertEqual("16.9.5.4"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor023 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor023', 0, function () { + let gaogao = new Uri.URI('http://49.99.54.12:50/path/path23?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("49.99.54.12:50"); + expect(gaogao.ssp).assertEqual("//49.99.54.12:50/path/path23?query"); + expect(gaogao.userinfo).assertEqual("null"); + expect(gaogao.host).assertEqual("49.99.54.12"); + expect(gaogao.port).assertEqual("50"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor024 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor024', 0, function () { + let gaogao = new Uri.URI('http://user@49.10pe8.54.12:80/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("user@49.10pe8.54.12:80"); + expect(gaogao.ssp).assertEqual("//user@49.10pe8.54.12:80/path/path23?query"); + expect(gaogao.userinfo).assertEqual("null"); + expect(gaogao.host).assertEqual("null"); + expect(gaogao.port).assertEqual("-1"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testConstructor025 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor025', 0, function () { + let gaogao = new Uri.URI('http://user@www.baidu.com/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("user@www.baidu.com"); + expect(gaogao.ssp).assertEqual("//user@www.baidu.com/path/path23?query"); + expect(gaogao.userinfo).assertEqual("user"); + expect(gaogao.host).assertEqual("www.baidu.com"); + expect(gaogao.port).assertEqual("-1"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testConstructor026 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor026', 0, function () { + let gaogao = new Uri.URI('http://user@www.hw.com:77/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("user@www.hw.com:77"); + expect(gaogao.ssp).assertEqual("//user@www.hw.com:77/path/path23?query"); + expect(gaogao.userinfo).assertEqual("user"); + expect(gaogao.host).assertEqual("www.hw.com"); + expect(gaogao.port).assertEqual("77"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testConstructor027 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor027', 0, function () { + let gaogao = new Uri.URI('ht2tp://user@www.h12343w.com:77/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("ht2tp"); + expect(gaogao.authority).assertEqual("user@www.h12343w.com:77"); + expect(gaogao.ssp).assertEqual("//user@www.h12343w.com:77/path/path23?query"); + expect(gaogao.userinfo).assertEqual("user"); + expect(gaogao.host).assertEqual("www.h12343w.com"); + expect(gaogao.port).assertEqual("77"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testConstructor028 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor028', 0, function () { + let gaogao = new Uri.URI('ht2tp://user@www.1hw.1com:77/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("ht2tp"); + expect(gaogao.authority).assertEqual("user@www.1hw.1com:77"); + expect(gaogao.ssp).assertEqual("//user@www.1hw.1com:77/path/path23?query"); + expect(gaogao.userinfo).assertEqual("null"); + expect(gaogao.host).assertEqual("null"); + expect(gaogao.port).assertEqual("-1"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testConstructor029 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor029', 0, function () { + let gaogao = new Uri.URI('http://user@hosthost/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("user@hosthost"); + expect(gaogao.ssp).assertEqual("//user@hosthost/path/path23?query"); + expect(gaogao.userinfo).assertEqual("user"); + expect(gaogao.host).assertEqual("hosthost"); + expect(gaogao.port).assertEqual("-1"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testConstructor030 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor030', 0, function () { + let gaogao = new Uri.URI('http://user@[::]/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("user@[::]"); + expect(gaogao.ssp).assertEqual("//user@[::]/path/path23?query"); + expect(gaogao.userinfo).assertEqual("user"); + expect(gaogao.host).assertEqual("[::]"); + expect(gaogao.port).assertEqual("-1"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testConstructor031 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor031', 0, function () { + let gaogao = new Uri.URI('http://[::192:0:5]/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("[::192:0:5]"); + expect(gaogao.ssp).assertEqual("//[::192:0:5]/path/path23?query"); + expect(gaogao.userinfo).assertEqual("null"); + expect(gaogao.host).assertEqual("[::192:0:5]"); + expect(gaogao.port).assertEqual("-1"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testEquals001 + * @tc.desc: Tests this URI for equality with another object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testEquals001', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment'); + let gaogao1 = gaogao; + let res = gaogao.equals(gaogao1); + expect(res).assertEqual(true); + }) + + /** + * @tc.name: testEquals002 + * @tc.desc: Tests this URI for equality with another object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testEquals002', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment'); + let gaogao1 = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment'); + let res = gaogao.equals(gaogao1); + expect(res).assertEqual(true); + }) + + /** + * @tc.name: testEquals003 + * @tc.desc: Tests this URI for equality with another object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testEquals003', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment'); + let gaogao1 = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment123'); + let res = gaogao.equals(gaogao1); + expect(res).assertEqual(false); + }) + + /** + * @tc.name: testEquals004 + * @tc.desc: Tests this URI for equality with another object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testEquals004', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@wwwaaa:99/path1?query#fagment'); + let gaogao1 = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment123'); + let res = gaogao.equals(gaogao1); + expect(res).assertEqual(false); + }) + + /** + * @tc.name: testEquals005 + * @tc.desc: Tests this URI for equality with another object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testEquals005', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment'); + let gaogao1 = new Uri.URI('http://[1:0:0:1:2:1:2:1]/path1?query#fagment123'); + let res = gaogao.equals(gaogao1); + expect(res).assertEqual(false); + }) + + /** + * @tc.name: testNormalize001 + * @tc.desc: Normalizes this URI's path. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testNormalize001', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66./../././mm/.././path1?query#fagment'); + let res = gaogao.normalize(); + expect(res.path).assertEqual("/path/path1"); + expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/path1?query#fagment"); + }) + + /** + * @tc.name: testNormalize002 + * @tc.desc: Normalizes this URI's path. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testNormalize002', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path?query#fagment'); + let res = gaogao.normalize(); + expect(res.path).assertEqual("/../../path"); + expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path?query#fagment"); + }) + + /** + * @tc.name: testNormalize003 + * @tc.desc: Normalizes this URI's path. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testNormalize003', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment'); + let res = gaogao.normalize(); + expect(res.path).assertEqual("/../../../aa/bb/cc"); + expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../../aa/bb/cc?query#fagment"); + }) + + /** + * @tc.name: testNormalize004 + * @tc.desc: Normalizes this URI's path. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testNormalize004', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../path/.././../aa/bb/cc?query'); + let res = gaogao.normalize(); + expect(res.path).assertEqual("/../../aa/bb/cc"); + expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../aa/bb/cc?query"); + }) + + /** + * @tc.name: testNormalize005 + * @tc.desc: Normalizes this URI's path. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testNormalize005', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/./path/./aa/bb/cc?query#fagment'); + let res = gaogao.normalize(); + expect(res.path).assertEqual("/path/aa/bb/cc"); + expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/aa/bb/cc?query#fagment"); + }) + + /** + * @tc.name: testToString001 + * @tc.desc: Returns the content of this URI as a US-ASCII string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testToString001', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment'); + let res = gaogao.toString(); + expect(res).assertEqual('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment'); + }) + + /** + * @tc.name: testToString002 + * @tc.desc: Returns the content of this URI as a US-ASCII string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testToString002', 0, function () { + let gaogao = new Uri.URI('htt1p://gg:gaogao@[::192.9.5.5]:99/path/66path1?query#fagment'); + let res = gaogao.toString(); + expect(res).assertEqual('htt1p://gg:gaogao@[::192.9.5.5]:99/path/66path1?query#fagment'); + }) + + /** + * @tc.name: testToString003 + * @tc.desc: Returns the content of this URI as a US-ASCII string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testToString003', 0, function () { + let gaogao = new Uri.URI('ftp://username:password@www.baidu.com:88/path?query#fagment'); + let res = gaogao.toString(); + expect(res).assertEqual('ftp://username:password@www.baidu.com:88/path?query#fagment'); + }) + + /** + * @tc.name: testToString004 + * @tc.desc: Returns the content of this URI as a US-ASCII string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testToString004', 0, function () { + let gaogao = new Uri.URI('http://gg:gao你好gao@199.98.55.44:99/path/p你好ath?qu你好ery#fag你好ment'); + let res = gaogao.toString(); + expect(res).assertEqual('http://gg:gao%E4%BD%A0%E5%A5%BDgao@199.98.55.44:99/path/' + + 'p%E4%BD%A0%E5%A5%BDath?qu%E4%BD%A0%E5%A5%BDery#fag%E4%BD%A0%E5%A5%BDment'); + }) + + /** + * @tc.name: testToString005 + * @tc.desc: Returns the content of this URI as a US-ASCII string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testToString005', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@199.98.55.44:99/path/path?query#fagment'); + let res = gaogao.toString(); + expect(res).assertEqual('http://gg:gaogao@199.98.55.44:99/path/path?query#fagment'); + }) + + /** + * @tc.name: testCheckIsAbsolute001 + * @tc.desc: Tells whether or not this URI is absolute. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testCheckIsAbsolute001', 0, function () { + let gaogao = new Uri.URI('f/tp://username:password@www.baidu.com:88/path?query#fagment'); + let res = gaogao.checkIsAbsolute(); + expect(res).assertEqual(false); + }) + + /** + * @tc.name: testCheckIsAbsolute002 + * @tc.desc: Tells whether or not this URI is absolute. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testCheckIsAbsolute002', 0, function () { + let gaogao = new Uri.URI('ftp://username:password@www.baidu.com:88/path?query#fagment'); + let res = gaogao.checkIsAbsolute(); + expect(res).assertEqual(true); + }) + + /** + * @tc.name: testCheckIsAbsolute003 + * @tc.desc: Tells whether or not this URI is absolute. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testCheckIsAbsolute003', 0, function () { + let gaogao = new Uri.URI('htt/p://username:password@www.baidu.com:88/path?query#fagment'); + let res = gaogao.checkIsAbsolute(); + expect(res).assertEqual(false); + }) + + /** + * @tc.name: testCheckIsAbsolute004 + * @tc.desc: Tells whether or not this URI is absolute. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testCheckIsAbsolute004', 0, function () { + let gaogao = new Uri.URI('https://username:password@www.baidu.com:88/path?query#fagment'); + let res = gaogao.checkIsAbsolute(); + expect(res).assertEqual(true); + }) + + /** + * @tc.name: testCheckIsAbsolute005 + * @tc.desc: Tells whether or not this URI is absolute. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testCheckIsAbsolute005', 0, function () { + let gaogao = new Uri.URI('http1://username:password@www.baidu.com:88/path?query#fagment'); + let res = gaogao.checkIsAbsolute(); + expect(res).assertEqual(true); + }) +}) \ No newline at end of file diff --git a/compileruntime/uri_lib_standard/src/main/js/test/uri.test.js.bak b/compileruntime/uri_lib_standard/src/main/js/test/uri.test.js.bak new file mode 100644 index 0000000000000000000000000000000000000000..37f662b1bcadc48b324b453ae586bb548095e6eb --- /dev/null +++ b/compileruntime/uri_lib_standard/src/main/js/test/uri.test.js.bak @@ -0,0 +1,803 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite' +import Uri from '@ohos.uri' +describe('UriTest', function () { + + /** + * @tc.name: testConstructor001 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor001', 0, function () { + try { + let that = new Uri.URI('#http://username:password@host:8080/directory/file?foo=1&bar=2'); + } catch (err) { + expect(err).assertEqual("Error: #It can't be the first"); + } + }) + + /** + * @tc.name: testConstructor002 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor002', 0, function () { + try { + let that = new Uri.URI({name: 'gaogao'}); + } catch (err) { + expect(err).assertEqual("Error: input type err"); + } + }) + + /** + * @tc.name: testConstructor003 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor003', 0, function () { + try { + let that = new Uri.URI('ht/tp://username:pas sword@host:8080/directory/file?foo=1&bar=2'); + } catch (err) { + expect(err).assertEqual("Error: SpecialPath does not conform to the rule"); + } + }) + + /** + * @tc.name: testConstructor004 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor004', 0, function () { + try { + let that = new Uri.URI('http://username:password@[::]:8080/directory/file?Query#gaogao faofao'); + } catch (err) { + expect(err).assertEqual("Error: Fragment does not conform to the rule"); + } + }) + + /** + * @tc.name: testConstructor005 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor005', 0, function () { + try { + let that = new Uri.URI('http://username:password@host:8080/directory/file?foo^=1&bar=2#gaogaofaofao'); + } catch (err) { + expect(err).assertEqual("Error: Query does not conform to the rule"); + } + }) + + /** + * @tc.name: testConstructor006 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor006', 0, function () { + try { + let that = new Uri.URI('1http://username:password@host:8080/directory/file?foo=1&bar=2#gaogaofaofao'); + } catch (err) { + expect(err).assertEqual("Error: Scheme the first character must be a letter"); + } + }) + + /** + * @tc.name: testConstructor007 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor007', 0, function () { + try { + let that = new Uri.URI('ht@tp://username:password@host:8080/directory/file?foo=1&bar=2#gaogaofaofao'); + } catch (err) { + expect(err).assertEqual("Error: scheme does not conform to the rule"); + } + }) + + /** + * @tc.name: testConstructor008 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor008', 0, function () { + try { + let that = new Uri.URI('http://username:password@[::]:80r80/directory/file?foo=1&bar=2#gaogaofaofao'); + } catch (err) { + expect(err).assertEqual("Error: Prot does not conform to the rule"); + } + }) + + /** + * @tc.name: testConstructor009 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor009', 0, function () { + try { + let that = new Uri.URI('http://username:password@[::12:55:8080/directory/file?foo=1&bar=2#gaogaofaofao'); + } catch (err) { + expect(err).assertEqual("Error: IPv6 is missing a closing bracket"); + } + }) + + /** + * @tc.name: testConstructor010 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor010', 0, function () { + try { + let that = new Uri.URI('http://username:pa^ssword@[::12:55]:8080/directory/file?foo=1&bar=2#gaogaofaofao'); + } catch (err) { + expect(err).assertEqual("Error: userInfo does not conform to the rule"); + } + }) + + /** + * @tc.name: testConstructor011 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor011', 0, function () { + try { + let that = new Uri.URI('http://username:password@[::1你2:55]:8080/directory/file?foo=1&bar=2#gaogaofaofao'); + } catch (err) { + expect(err).assertEqual("Error: ipv6 does not conform to the rule"); + } + }) + + /** + * @tc.name: testConstructor012 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor012', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@www.baidu.com:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@www.baidu.com:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("www.baidu.com"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor013 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor013', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1080::8:800:200C:417A]:99/path/66path1?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[1080::8:800:200C:417A]:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[1080::8:800:200C:417A]:99/path/66path1?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[1080::8:800:200C:417A]"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/66path1"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor014 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor014', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[::]:88/path/path66?foooo#gaogao'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[::]:88"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[::]:88/path/path66?foooo"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[::]"); + expect(gaogao.port).assertEqual("88"); + expect(gaogao.path).assertEqual("/path/path66"); + expect(gaogao.query).assertEqual("foooo"); + expect(gaogao.fragment).assertEqual("gaogao"); + }) + + /** + * @tc.name: testConstructor015 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor015', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66path1?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[1:0:0:1:2:1:2:1]:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66path1?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[1:0:0:1:2:1:2:1]"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/66path1"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor016 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor016', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[::FFFF:129.144.52.38]:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[::FFFF:129.144.52.38]:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[::FFFF:129.144.52.38]:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[::FFFF:129.144.52.38]"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor017 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor017', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[::192.9.5.5]:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[::192.9.5.5]:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[::192.9.5.5]:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[::192.9.5.5]"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor018 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor018', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[22::22:2:2%ss]:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[22::22:2:2%ss]:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[22::22:2:2%ss]:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[22::22:2:2%ss]"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor019 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor019', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[fe80:0000:0001:0000:0440:44ff:1233:5678]:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[fe80:0000:0001:0000:0440:44ff:1233:5678]:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[fe80:0000:0001:0000:0440:44ff:1233:5678]:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[fe80:0000:0001:0000:0440:44ff:1233:5678]"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor020 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor020', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[fe80::0001:0000]:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@[fe80::0001:0000]:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@[fe80::0001:0000]:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("[fe80::0001:0000]"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor021 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor021', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@199.98.55.44:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("gg:gaogao@199.98.55.44:99"); + expect(gaogao.ssp).assertEqual("//gg:gaogao@199.98.55.44:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("gg:gaogao"); + expect(gaogao.host).assertEqual("199.98.55.44"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor022 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor022', 0, function () { + let gaogao = new Uri.URI('http://16.9.5.4:99/path/path?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("16.9.5.4:99"); + expect(gaogao.ssp).assertEqual("//16.9.5.4:99/path/path?query"); + expect(gaogao.userinfo).assertEqual("null"); + expect(gaogao.host).assertEqual("16.9.5.4"); + expect(gaogao.port).assertEqual("99"); + expect(gaogao.path).assertEqual("/path/path"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor023 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor023', 0, function () { + let gaogao = new Uri.URI('http://49.99.54.12:50/path/path23?query#fagment'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("49.99.54.12:50"); + expect(gaogao.ssp).assertEqual("//49.99.54.12:50/path/path23?query"); + expect(gaogao.userinfo).assertEqual("null"); + expect(gaogao.host).assertEqual("49.99.54.12"); + expect(gaogao.port).assertEqual("50"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("fagment"); + }) + + /** + * @tc.name: testConstructor024 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor024', 0, function () { + let gaogao = new Uri.URI('http://user@49.10pe8.54.12:80/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("user@49.10pe8.54.12:80"); + expect(gaogao.ssp).assertEqual("//user@49.10pe8.54.12:80/path/path23?query"); + expect(gaogao.userinfo).assertEqual("null"); + expect(gaogao.host).assertEqual("null"); + expect(gaogao.port).assertEqual("-1"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testConstructor025 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor025', 0, function () { + let gaogao = new Uri.URI('http://user@www.baidu.com/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("user@www.baidu.com"); + expect(gaogao.ssp).assertEqual("//user@www.baidu.com/path/path23?query"); + expect(gaogao.userinfo).assertEqual("user"); + expect(gaogao.host).assertEqual("www.baidu.com"); + expect(gaogao.port).assertEqual("-1"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testConstructor026 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor026', 0, function () { + let gaogao = new Uri.URI('http://user@www.hw.com:77/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("user@www.hw.com:77"); + expect(gaogao.ssp).assertEqual("//user@www.hw.com:77/path/path23?query"); + expect(gaogao.userinfo).assertEqual("user"); + expect(gaogao.host).assertEqual("www.hw.com"); + expect(gaogao.port).assertEqual("77"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testConstructor027 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor027', 0, function () { + let gaogao = new Uri.URI('ht2tp://user@www.h12343w.com:77/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("ht2tp"); + expect(gaogao.authority).assertEqual("user@www.h12343w.com:77"); + expect(gaogao.ssp).assertEqual("//user@www.h12343w.com:77/path/path23?query"); + expect(gaogao.userinfo).assertEqual("user"); + expect(gaogao.host).assertEqual("www.h12343w.com"); + expect(gaogao.port).assertEqual("77"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testConstructor028 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor028', 0, function () { + let gaogao = new Uri.URI('ht2tp://user@www.1hw.1com:77/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("ht2tp"); + expect(gaogao.authority).assertEqual("user@www.1hw.1com:77"); + expect(gaogao.ssp).assertEqual("//user@www.1hw.1com:77/path/path23?query"); + expect(gaogao.userinfo).assertEqual("null"); + expect(gaogao.host).assertEqual("null"); + expect(gaogao.port).assertEqual("-1"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testConstructor029 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor029', 0, function () { + let gaogao = new Uri.URI('http://user@hosthost/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("user@hosthost"); + expect(gaogao.ssp).assertEqual("//user@hosthost/path/path23?query"); + expect(gaogao.userinfo).assertEqual("user"); + expect(gaogao.host).assertEqual("hosthost"); + expect(gaogao.port).assertEqual("-1"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testConstructor030 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor030', 0, function () { + let gaogao = new Uri.URI('http://user@[::]/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("user@[::]"); + expect(gaogao.ssp).assertEqual("//user@[::]/path/path23?query"); + expect(gaogao.userinfo).assertEqual("user"); + expect(gaogao.host).assertEqual("[::]"); + expect(gaogao.port).assertEqual("-1"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testConstructor031 + * @tc.desc: Constructs a URI by parsing the given string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testConstructor031', 0, function () { + let gaogao = new Uri.URI('http://[::192:0:5]/path/path23?query#qwer'); + expect(gaogao.scheme).assertEqual("http"); + expect(gaogao.authority).assertEqual("[::192:0:5]"); + expect(gaogao.ssp).assertEqual("//[::192:0:5]/path/path23?query"); + expect(gaogao.userinfo).assertEqual("null"); + expect(gaogao.host).assertEqual("[::192:0:5]"); + expect(gaogao.port).assertEqual("-1"); + expect(gaogao.path).assertEqual("/path/path23"); + expect(gaogao.query).assertEqual("query"); + expect(gaogao.fragment).assertEqual("qwer"); + }) + + /** + * @tc.name: testEquals001 + * @tc.desc: Tests this URI for equality with another object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testEquals001', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment'); + let gaogao1 = gaogao; + let res = gaogao.equals(gaogao1); + expect(res).assertEqual(true); + }) + + /** + * @tc.name: testEquals002 + * @tc.desc: Tests this URI for equality with another object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testEquals002', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment'); + let gaogao1 = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment'); + let res = gaogao.equals(gaogao1); + expect(res).assertEqual(true); + }) + + /** + * @tc.name: testEquals003 + * @tc.desc: Tests this URI for equality with another object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testEquals003', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment'); + let gaogao1 = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment123'); + let res = gaogao.equals(gaogao1); + expect(res).assertEqual(false); + }) + + /** + * @tc.name: testEquals004 + * @tc.desc: Tests this URI for equality with another object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testEquals004', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@wwwaaa:99/path1?query#fagment'); + let gaogao1 = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment123'); + let res = gaogao.equals(gaogao1); + expect(res).assertEqual(false); + }) + + /** + * @tc.name: testEquals005 + * @tc.desc: Tests this URI for equality with another object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testEquals005', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment'); + let gaogao1 = new Uri.URI('http://[1:0:0:1:2:1:2:1]/path1?query#fagment123'); + let res = gaogao.equals(gaogao1); + expect(res).assertEqual(false); + }) + + /** + * @tc.name: testNormalize001 + * @tc.desc: Normalizes this URI's path. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testNormalize001', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66./../././mm/.././path1?query#fagment'); + let res = gaogao.normalize(); + expect(res.path).assertEqual("/path/path1"); + expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/path1?query#fagment"); + }) + + /** + * @tc.name: testNormalize002 + * @tc.desc: Normalizes this URI's path. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testNormalize002', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path?query#fagment'); + let res = gaogao.normalize(); + expect(res.path).assertEqual("/../../path"); + expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path?query#fagment"); + }) + + /** + * @tc.name: testNormalize003 + * @tc.desc: Normalizes this URI's path. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testNormalize003', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment'); + let res = gaogao.normalize(); + expect(res.path).assertEqual("/../../../aa/bb/cc"); + expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../../aa/bb/cc?query#fagment"); + }) + + /** + * @tc.name: testNormalize004 + * @tc.desc: Normalizes this URI's path. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testNormalize004', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../path/.././../aa/bb/cc?query'); + let res = gaogao.normalize(); + expect(res.path).assertEqual("/../../aa/bb/cc"); + expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../aa/bb/cc?query"); + }) + + /** + * @tc.name: testNormalize005 + * @tc.desc: Normalizes this URI's path. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testNormalize005', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/./path/./aa/bb/cc?query#fagment'); + let res = gaogao.normalize(); + expect(res.path).assertEqual("/path/aa/bb/cc"); + expect(res.toString()).assertEqual("http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/aa/bb/cc?query#fagment"); + }) + + /** + * @tc.name: testToString001 + * @tc.desc: Returns the content of this URI as a US-ASCII string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testToString001', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment'); + let res = gaogao.toString(); + expect(res).assertEqual('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment'); + }) + + /** + * @tc.name: testToString002 + * @tc.desc: Returns the content of this URI as a US-ASCII string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testToString002', 0, function () { + let gaogao = new Uri.URI('htt1p://gg:gaogao@[::192.9.5.5]:99/path/66path1?query#fagment'); + let res = gaogao.toString(); + expect(res).assertEqual('htt1p://gg:gaogao@[::192.9.5.5]:99/path/66path1?query#fagment'); + }) + + /** + * @tc.name: testToString003 + * @tc.desc: Returns the content of this URI as a US-ASCII string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testToString003', 0, function () { + let gaogao = new Uri.URI('ftp://username:password@www.baidu.com:88/path?query#fagment'); + let res = gaogao.toString(); + expect(res).assertEqual('ftp://username:password@www.baidu.com:88/path?query#fagment'); + }) + + /** + * @tc.name: testToString004 + * @tc.desc: Returns the content of this URI as a US-ASCII string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testToString004', 0, function () { + let gaogao = new Uri.URI('http://gg:gao你好gao@199.98.55.44:99/path/p你好ath?qu你好ery#fag你好ment'); + let res = gaogao.toString(); + expect(res).assertEqual('http://gg:gao%E4%BD%A0%E5%A5%BDgao@199.98.55.44:99/path/' + + 'p%E4%BD%A0%E5%A5%BDath?qu%E4%BD%A0%E5%A5%BDery#fag%E4%BD%A0%E5%A5%BDment'); + }) + + /** + * @tc.name: testToString005 + * @tc.desc: Returns the content of this URI as a US-ASCII string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testToString005', 0, function () { + let gaogao = new Uri.URI('http://gg:gaogao@199.98.55.44:99/path/path?query#fagment'); + let res = gaogao.toString(); + expect(res).assertEqual('http://gg:gaogao@199.98.55.44:99/path/path?query#fagment'); + }) + + /** + * @tc.name: testCheckIsAbsolute001 + * @tc.desc: Tells whether or not this URI is absolute. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testCheckIsAbsolute001', 0, function () { + let gaogao = new Uri.URI('f/tp://username:password@www.baidu.com:88/path?query#fagment'); + let res = gaogao.checkIsAbsolute(); + expect(res).assertEqual(false); + }) + + /** + * @tc.name: testCheckIsAbsolute002 + * @tc.desc: Tells whether or not this URI is absolute. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testCheckIsAbsolute002', 0, function () { + let gaogao = new Uri.URI('ftp://username:password@www.baidu.com:88/path?query#fagment'); + let res = gaogao.checkIsAbsolute(); + expect(res).assertEqual(true); + }) + + /** + * @tc.name: testCheckIsAbsolute003 + * @tc.desc: Tells whether or not this URI is absolute. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testCheckIsAbsolute003', 0, function () { + let gaogao = new Uri.URI('htt/p://username:password@www.baidu.com:88/path?query#fagment'); + let res = gaogao.checkIsAbsolute(); + expect(res).assertEqual(false); + }) + + /** + * @tc.name: testCheckIsAbsolute004 + * @tc.desc: Tells whether or not this URI is absolute. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testCheckIsAbsolute004', 0, function () { + let gaogao = new Uri.URI('https://username:password@www.baidu.com:88/path?query#fagment'); + let res = gaogao.checkIsAbsolute(); + expect(res).assertEqual(true); + }) + + /** + * @tc.name: testCheckIsAbsolute005 + * @tc.desc: Tells whether or not this URI is absolute. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testCheckIsAbsolute005', 0, function () { + let gaogao = new Uri.URI('http1://username:password@www.baidu.com:88/path?query#fagment'); + let res = gaogao.checkIsAbsolute(); + expect(res).assertEqual(true); + }) +}) \ No newline at end of file diff --git a/compileruntime/uri_lib_standard/src/main/resources/base/element/string.json b/compileruntime/uri_lib_standard/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0bae6bd40f7360d5d818998221b199d3ec0f69c0 --- /dev/null +++ b/compileruntime/uri_lib_standard/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/compileruntime/uri_lib_standard/src/main/resources/base/media/icon.png b/compileruntime/uri_lib_standard/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/compileruntime/uri_lib_standard/src/main/resources/base/media/icon.png differ diff --git a/compileruntime/url_lib_standard/BUILD.gn b/compileruntime/url_lib_standard/BUILD.gn index 595e22ccac223fd21a983ca25eb1033f86fef7b4..557642e6548ed0d2e062eb0a34b6e2a7206ed071 100644 --- a/compileruntime/url_lib_standard/BUILD.gn +++ b/compileruntime/url_lib_standard/BUILD.gn @@ -12,15 +12,23 @@ # limitations under the License. import("//test/xts/tools/build/suite.gni") - ohos_js_hap_suite("url_js_test") { hap_profile = "./src/main/config.json" + js2abc = true deps = [ ":url_js_assets", ":url_resources", ] + + # shared_libraries = [ + # "//third_party/giflib:libgif", + # "//third_party/libpng:libpng", + # ] certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsUrlJsTest" + hap_name = "UrlJsTest" + + # part_name = "prebuilt_hap" + # subsystem_name = "xts" } ohos_js_assets("url_js_assets") { source_dir = "./src/main/js/default" diff --git a/compileruntime/url_lib_standard/Test.json b/compileruntime/url_lib_standard/Test.json index 509cac922121ecc4c467069126977e9047bf3077..7246972760202009369848a23f34724daea489d3 100644 --- a/compileruntime/url_lib_standard/Test.json +++ b/compileruntime/url_lib_standard/Test.json @@ -9,7 +9,7 @@ "kits": [ { "test-file-name": [ - "ActsUrlJsTest.hap" + "UrlJsTest.hap" ], "type": "AppInstallKit", "cleanup-apps": true diff --git a/compileruntime/url_lib_standard/src/main/config.json b/compileruntime/url_lib_standard/src/main/config.json index eded041ca18822a8db943ab7a2293fd8c32d1f85..1919daf2b4b82bd28d9ba9fde52b92af1086517c 100644 --- a/compileruntime/url_lib_standard/src/main/config.json +++ b/compileruntime/url_lib_standard/src/main/config.json @@ -5,6 +5,10 @@ "version": { "code": 1000000, "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 } }, "deviceConfig": {}, diff --git a/compileruntime/url_lib_standard/src/main/java/com/example/url/MainAbility.java b/compileruntime/url_lib_standard/src/main/java/com/example/url/MainAbility.java deleted file mode 100644 index 1029c01195535d7671415ad1490aa483571d41e5..0000000000000000000000000000000000000000 --- a/compileruntime/url_lib_standard/src/main/java/com/example/url/MainAbility.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.example.url; - -import ohos.ace.ability.AceAbility; -import ohos.aafwk.content.Intent; - -public class MainAbility extends AceAbility { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - } - - @Override - public void onStop() { - super.onStop(); - } -} diff --git a/compileruntime/url_lib_standard/src/main/java/com/example/url/MyApplication.java b/compileruntime/url_lib_standard/src/main/java/com/example/url/MyApplication.java deleted file mode 100644 index d0bd8e832c63d6b1e691f5fc58c9284982cbde3b..0000000000000000000000000000000000000000 --- a/compileruntime/url_lib_standard/src/main/java/com/example/url/MyApplication.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.example.url; - -import ohos.aafwk.ability.AbilityPackage; - -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/compileruntime/url_lib_standard/src/main/js/test/ExampleJsunit.test.js b/compileruntime/url_lib_standard/src/main/js/test/ExampleJsunit.test.js deleted file mode 100644 index 2d8aa9fb75f84cdf6b1a070b0f24b74c4fd792b3..0000000000000000000000000000000000000000 --- a/compileruntime/url_lib_standard/src/main/js/test/ExampleJsunit.test.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import app from '@system.app' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite' - -describe('appInfoTest', function () { - it('app_info_test_001', 0, function () { - var info = app.getInfo() - expect(info.versionCode).assertEqual('1000000') - }) -}) \ No newline at end of file diff --git a/compileruntime/url_lib_standard/src/main/js/test/List.test.js b/compileruntime/url_lib_standard/src/main/js/test/List.test.js index 8a9a35ff2dc4ccb7b55bd59545e29f4cb3785b52..e6046fd924bbce146525b8268100322301eb80fe 100644 --- a/compileruntime/url_lib_standard/src/main/js/test/List.test.js +++ b/compileruntime/url_lib_standard/src/main/js/test/List.test.js @@ -13,4 +13,4 @@ * limitations under the License. */ require('./url.test.js') -require('./ExampleJsunit.test.js') + diff --git a/compileruntime/url_lib_standard/src/main/js/test/url.test.js b/compileruntime/url_lib_standard/src/main/js/test/url.test.js index 3c7e42f36cd06c2518df81f8319ad081f810af9d..486fe9161140277de2f75323cbcfd7ab23852500 100644 --- a/compileruntime/url_lib_standard/src/main/js/test/url.test.js +++ b/compileruntime/url_lib_standard/src/main/js/test/url.test.js @@ -12,11 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite' import Url from '@ohos.url' - describe('UrlFunTest', function () { - + /** * @tc.name: testUrlAppend001 * @tc.desc: Appends a specified key/value pair as a new search parameter. @@ -173,7 +172,7 @@ describe('UrlFunTest', function () { i++; arr[i]=pair[1]; i++; - }; + } expect(arr[1]).assertEqual("value1"); }) @@ -255,7 +254,7 @@ describe('UrlFunTest', function () { expect(arr[4]).assertEqual("jss") }) - /** + /** * @tc.name: testUrlForEach001 * @tc.desc: Callback functions are used to traverse key-value pairs on the URLSearchParams instance object. * @tc.require: AR000GFB2S @@ -269,12 +268,12 @@ describe('UrlFunTest', function () { { arr[i] = value + " " + key + " " + (params === SearchParams) i++ - }; + } params.forEach(func); expect(arr[0]).assertEqual("value1 key1 true"); }) - /** + /** * @tc.name: testUrlForEach002 * @tc.desc: Callback functions are used to traverse key-value pairs on the URLSearchParams instance object. * @tc.require: AR000GFB2S @@ -288,7 +287,7 @@ describe('UrlFunTest', function () { { arr[i] = value + " " + key + " " + (params === SearchParams) i++ - }; + } params.forEach(func); expect(arr[1]).assertEqual("value2 key2 true"); }) @@ -308,7 +307,7 @@ describe('UrlFunTest', function () { { arr[i] = value + " " + key + " " + (params === SearchParams) i++ - }; + } params.forEach(func); expect(arr[2]).assertEqual("jk foo true"); }) @@ -327,7 +326,7 @@ describe('UrlFunTest', function () { { arr[i] = value + " " + key + " " + (params === SearchParams) i++ - }; + } params.forEach(func); expect(arr[1]).assertEqual("txt jss true"); }) @@ -347,7 +346,7 @@ describe('UrlFunTest', function () { { arr[i] = value + " " + key + " " + (params === SearchParams) i++ - }; + } params.forEach(func); expect(arr[0]).assertEqual("bar foo true"); }) @@ -424,13 +423,7 @@ describe('UrlFunTest', function () { let params = new Url.URLSearchParams("key1=value1&key2=value2") params.append("key1","AAA") var result = params.getAll("key1") - console.info('test result size=' + result.length) - console.info('test result type=' + typeof result ) - console.info('test result=' + result) - var s = "value1,AAA" - console.info('test s size=' + s.length) - expect(result[0]).assertEqual("value1") - expect(result[1]).assertEqual("AAA") + expect(result).assertEqual("value1,AAA") }) /** @@ -443,13 +436,7 @@ describe('UrlFunTest', function () { let params = new Url.URLSearchParams("key1=value1&8=DEF") params.append("8","A8A") var result = params.getAll("8") - console.info('test result size=' + result.length) - console.info('test result type=' + typeof result ) - console.info('test result=' + result) - var s = "DEF,A8A" - console.info('test s size=' + s.length) - expect(result[0]).assertEqual("DEF") - expect(result[1]).assertEqual("A8A") + expect(result).assertEqual("DEF,A8A") }) /** @@ -459,11 +446,10 @@ describe('UrlFunTest', function () { * @tc.author: maxiaodong */ it('testUrlGetAll003', 0, function () { - let params = new Url.URLSearchParams("key1=value1&key2=value2&key3=大") + let params = new Url.URLSearchParams("key1=value1&key2=value2&key3=da") params.append("key3","A3A") var result = params.getAll("key3") - expect(result[0]).assertEqual("大") - expect(result[1]).assertEqual("A3A") + expect(result).assertEqual("da,A3A") }) /** @@ -474,12 +460,9 @@ describe('UrlFunTest', function () { */ it('testUrlGetAll004', 0, function () { let params = new Url.URLSearchParams("key1=value1&key2=value2&key3=大") - params.append("key4","A3A3") + params.append("key3","A3A") var result = params.getAll("key4") - console.info('test result size=' + result.length) - console.info('test result type=' + typeof result ) - console.info('test result=' + result) - expect(result[0]).assertEqual("A3A3") + expect(result).assertEqual('') }) /** @@ -492,12 +475,7 @@ describe('UrlFunTest', function () { let params = new Url.URLSearchParams("key1=value1&key2=value2&key3=大") params.append("key3","A3A") var result = params.getAll("key2") - console.info('test result size=' + result.length) - console.info('test result type=' + typeof result ) - console.info('test result=' + result) - var s = "value2" - console.info('test s size=' + s.length) - expect(result[0]).assertEqual("value2") + expect(result).assertEqual("value2") }) /** @@ -575,7 +553,7 @@ describe('UrlFunTest', function () { for(var key of params.keys()) { arr[i] = key i++ - }; + } expect(arr[0]).assertEqual("小"); }) @@ -592,7 +570,7 @@ describe('UrlFunTest', function () { for(var key of params.keys()) { arr[i] = key i++ - }; + } expect(arr[1]).assertEqual("¥"); }) @@ -609,7 +587,7 @@ describe('UrlFunTest', function () { for(var key of params.keys()) { arr[i] = key i++ - }; + } expect(arr[2]).assertEqual("key3"); }) @@ -626,7 +604,7 @@ describe('UrlFunTest', function () { for(var key of params.keys()) { arr[i] = key i++ - }; + } expect(arr[3]).assertEqual("key4"); }) @@ -643,7 +621,7 @@ describe('UrlFunTest', function () { for(var key of params.keys()) { arr[i] = key i++ - }; + } expect(arr[4]).assertEqual("key5"); }) @@ -657,6 +635,7 @@ describe('UrlFunTest', function () { */ it('testUrlSet001', 0, function () { let params = new Url.URLSearchParams("1=value1&2=value2&key3=3"); + // params.append("11","ACA"); params.set("11","CCC"); var res = params.toString(); expect(res).assertEqual("1=value1&2=value2&key3=3&11=CCC"); @@ -702,6 +681,7 @@ describe('UrlFunTest', function () { */ it('testUrlSet004', 0, function () { let params = new Url.URLSearchParams("1=value1&2=value2&key3=3"); + // params.append("1","ACA"); params.set("1","CCC"); var res = params.toString(); expect(res).assertEqual("1=CCC&2=value2&key3=3"); @@ -972,9 +952,9 @@ describe('UrlFunTest', function () { */ it('testUrlSearchParamsConstruction003', 0, function () { let params = new Url.URLSearchParams([ - ['user', 'abc'], - ['query', 'first'], - ['query', 'second'], + ['user', 'abc'], + ['query', 'first'], + ['query', 'second'], ]); var result= params.toString() expect(result).assertEqual("user=abc&query=first&query=second") @@ -1215,7 +1195,7 @@ describe('UrlFunTest', function () { * @tc.require: AR000GFB2S * @tc.author: zhaoduwei */ - it('Url_origin_test_005', 0, function () { + it('testUrlOrigin005', 0, function () { let params = new Url.URL('http://username:password@host22:100#fragment') var result= params.origin expect(result).assertEqual('http://host22:100') @@ -1314,12 +1294,9 @@ describe('UrlFunTest', function () { * @tc.author: zhaoduwei */ it('testUrlUsername003', 0, function () { - console.log('testUrlUsername[start]') let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') params.username = 'skk' - console.log('testUrlUsername['+params.username+']') var result= params.username - console.log('testUrlUsername['+result+']') expect(result).assertEqual('skk') }) @@ -1330,12 +1307,9 @@ describe('UrlFunTest', function () { * @tc.author: zhaoduwei */ it('testUrlUsername004', 0, function () { - console.log('testUrlUsername[start]') let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') params.username = 'skp111' - console.log('testUrlUsername['+params.username+']') var result= params.username - console.log('testUrlUsername['+result+']') expect(result).assertEqual('skp111') }) @@ -1395,7 +1369,7 @@ describe('UrlFunTest', function () { */ it('testUrlPassword004', 0, function () { let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') - params.password = "1234" + params.password = '1234' var result= params.password expect(result).assertEqual('1234') }) @@ -1408,7 +1382,7 @@ describe('UrlFunTest', function () { */ it('testUrlPassword005', 0, function () { let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') - params.password = ""; + params.password = ''; var result= params.password expect(result).assertEqual('') }) @@ -1458,7 +1432,6 @@ describe('UrlFunTest', function () { it('testUrlHost004', 0, function () { let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') params.host = 'jkjk' - params.password = 'test' var result= params.host expect(result).assertEqual('jkjk:8080') }) @@ -2044,7 +2017,7 @@ describe('UrlFunTest', function () { * @tc.require: AR000GFB2S * @tc.author: zhaoduwei */ - it('Url_construction_test_011', 0, function () { + it('testUrlConstruction011', 0, function () { let params = new Url.URL('htt1p://www.0902zy.cn/path?abc=123&def=456#yyyy') let params1 = new Url.URL('www.baidu.com/ssaa',params) var result = params1.href diff --git a/compileruntime/url_lib_standard/src/main/js/test/url.test.js.bak b/compileruntime/url_lib_standard/src/main/js/test/url.test.js.bak new file mode 100644 index 0000000000000000000000000000000000000000..83f3e8e0076c4e5a76914ad589181490d9e25c6f --- /dev/null +++ b/compileruntime/url_lib_standard/src/main/js/test/url.test.js.bak @@ -0,0 +1,2064 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite' +import Url from '@ohos.url' +describe('UrlFunTest', function () { + + /** + * @tc.name: testUrlAppend001 + * @tc.desc: Appends a specified key/value pair as a new search parameter. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlAppend001', 0, function () { + var that = new Url.URL('http://username:password@host:8080/directory/file?foo=1&bar=2'); + var params = new Url.URLSearchParams(that.search); + params.append('ma','jk') + var result = params.toString() + expect(result).assertEqual('foo=1&bar=2&ma=jk') + }) + + /** + * @tc.name: testUrlAppend002 + * @tc.desc: Appends a specified key/value pair as a new search parameter. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlAppend002', 0, function () { + let that = new Url.URL('https://example.com?foo=1&bar=2') + let params = new Url.URLSearchParams(that.search) + params.append("ma 大","jk¥") + var result = params.toString() + expect(result).assertEqual("foo=1&bar=2&ma+%E5%A4%A7=jk%EF%BF%A5") + }) + + /** + * @tc.name: testUrlAppend003 + * @tc.desc: Appends a specified key/value pair as a new search parameter. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlAppend003', 0, function () { + let that = new Url.URL('https://example.com?foo=1&bar=2') + let params = new Url.URLSearchParams(that.search) + params.append("foo~!@#$%^&*()_+-=","jk") + var result = params.toString() + expect(result).assertEqual("foo=1&bar=2&foo%7E%21%40%23%24%25%5E%26*%28%29_%2B-%3D=jk") + }) + + /** + * @tc.name: testUrlAppend004 + * @tc.desc: Appends a specified key/value pair as a new search parameter. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlAppend004', 0, function () { + let that = new Url.URL('https://example.com?foo=1&bar=2') + let params = new Url.URLSearchParams(that.search) + params.append("app","par") + var result = params.toString() + expect(result).assertEqual("foo=1&bar=2&app=par") + }) + + /** + * @tc.name: testUrlAppend005 + * @tc.desc: Appends a specified key/value pair as a new search parameter. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlAppend005', 0, function () { + let that = new Url.URL('https://example.com?foo=1&bar=2') + let params = new Url.URLSearchParams(that.search) + params.append("123","456") + var result = params.toString() + expect(result).assertEqual("foo=1&bar=2&123=456") + }) + + /** + * @tc.name: testUrlDelete001 + * @tc.desc: Deletes the given search parameter and its associated value,from the list of all search parameters. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlDelete001', 0, function () { + let that = new Url.URL('https://example.com?foo=1&bar=2') + let params = new Url.URLSearchParams(that.search) + params.delete("foo") + var result = params.toString() + expect(result).assertEqual("bar=2") + }) + + /** + * @tc.name: testUrlDelete002 + * @tc.desc: Deletes the given search parameter and its associated value,from the list of all search parameters. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlDelete002', 0, function () { + let that = new Url.URL('https://example.com?foo大=1&bar=2'); + let params = new Url.URLSearchParams(that.search); + params.delete('foo'); + var result = params.toString(); + expect(result).assertEqual("foo%E5%A4%A7=1&bar=2"); + }) + + /** + * @tc.name: testUrlDelete003 + * @tc.desc: Deletes the given search parameter and its associated value,from the list of all search parameters. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlDelete003', 0, function () { + let that = new Url.URL('https://example.com?foo大=1&bar=2'); + let params = new Url.URLSearchParams(that.search); + params.delete("foo大"); + var result = params.toString(); + expect(result).assertEqual("bar=2") + }) + + /** + * @tc.name: testUrlDelete004 + * @tc.desc: Deletes the given search parameter and its associated value,from the list of all search parameters. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlDelete004', 0, function () { + let that = new Url.URL('https://example.com?foo=1&bar=2'); + let params = new Url.URLSearchParams(that.search); + params.delete('bar'); + var result = params.toString(); + expect(result).assertEqual("foo=1"); + }) + + /** + * @tc.name: testUrlDelete005 + * @tc.desc: Deletes the given search parameter and its associated value,from the list of all search parameters. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlDelete005', 0, function () { + let that = new Url.URL('https://example.com?foo=1&bar=2'); + let params = new Url.URLSearchParams(that.search); + params.delete("faa"); + var result = params.toString(); + expect(result).assertEqual("foo=1&bar=2") + }) + + /** + * @tc.name: testUrlEntries001 + * @tc.desc: Returns an ES6 iterator. Each item of the iterator is a JavaScript Array. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlEntries001', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2"); + + var i=0; + var arr={}; + for(var pair of params.entries()) { + arr[i]=pair[0]; + i++; + arr[i]=pair[1]; + i++; + }; + expect(arr[1]).assertEqual("value1"); + }) + + /** + * @tc.name: testUrlEntries002 + * @tc.desc: Returns an ES6 iterator. Each item of the iterator is a JavaScript Array. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlEntries002', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2") + var i=0; + var arr={}; + for(var pair of params.entries()) { + arr[i]=pair[0]; + i++; + arr[i]=pair[1]; + i++; + } + expect(arr[2]).assertEqual("key2") + }) + + /** + * @tc.name: testUrlEntries003 + * @tc.desc: Returns an ES6 iterator. Each item of the iterator is a JavaScript Array. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlEntries003', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2") + params.append("foo","jk") + var i=0; + var arr={}; + for(var pair of params.entries()) { + arr[i]=pair[0]; + i++; + arr[i]=pair[1]; + i++; + } + expect(arr[5]).assertEqual("jk") + }) + + /** + * @tc.name: testUrlEntries004 + * @tc.desc: Returns an ES6 iterator. Each item of the iterator is a JavaScript Array. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlEntries004', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2") + var i=0; + var arr={}; + for(var pair of params.entries()) { + arr[i]=pair[0]; + i++; + arr[i]=pair[1]; + i++; + } + expect(arr[3]).assertEqual("value2") + }) + + /** + * @tc.name: testUrlEntries005 + * @tc.desc: Returns an ES6 iterator. Each item of the iterator is a JavaScript Array. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlEntries005', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2") + params.append("jss","txt") + var i=0; + var arr={}; + for(var pair of params.entries()) { + arr[i]=pair[0]; + i++; + arr[i]=pair[1]; + i++; + } + expect(arr[4]).assertEqual("jss") + }) + + /** + * @tc.name: testUrlForEach001 + * @tc.desc: Callback functions are used to traverse key-value pairs on the URLSearchParams instance object. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlForEach001', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2") + var arr={}; + var i = 0; + function func(value, key, SearchParams) + { + arr[i] = value + " " + key + " " + (params === SearchParams) + i++ + } + params.forEach(func); + expect(arr[0]).assertEqual("value1 key1 true"); + }) + + /** + * @tc.name: testUrlForEach002 + * @tc.desc: Callback functions are used to traverse key-value pairs on the URLSearchParams instance object. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlForEach002', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2"); + var arr={}; + var i = 0; + function func(value, key, SearchParams) + { + arr[i] = value + " " + key + " " + (params === SearchParams) + i++ + }; + params.forEach(func); + expect(arr[1]).assertEqual("value2 key2 true"); + }) + + /** + * @tc.name: testUrlForEach003 + * @tc.desc: Callback functions are used to traverse key-value pairs on the URLSearchParams instance object. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlForEach003', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2"); + params.append("foo","jk"); + var arr={}; + var i = 0; + function func(value, key, SearchParams) + { + arr[i] = value + " " + key + " " + (params === SearchParams) + i++ + }; + params.forEach(func); + expect(arr[2]).assertEqual("jk foo true"); + }) + + /** + * @tc.name: testUrlForEach004 + * @tc.desc: Callback functions are used to traverse key-value pairs on the URLSearchParams instance object. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlForEach004', 0, function () { + let params = new Url.URLSearchParams("foo=bar&jss=txt"); + var arr={}; + var i = 0; + function func(value, key, SearchParams) + { + arr[i] = value + " " + key + " " + (params === SearchParams) + i++ + } + params.forEach(func); + expect(arr[1]).assertEqual("txt jss true"); + }) + + /** + * @tc.name: testUrlForEach005 + * @tc.desc: Callback functions are used to traverse key-value pairs on the URLSearchParams instance object. + * @tc.require: AR000GFB2S + * @tc.author: jiangkai + */ + it('testUrlForEach005', 0, function () { + let params = new Url.URLSearchParams("foo=bar&jss=txt"); + params.append("foo","jk"); + var arr={}; + var i = 0; + function func(value, key, SearchParams) + { + arr[i] = value + " " + key + " " + (params === SearchParams) + i++ + }; + params.forEach(func); + expect(arr[0]).assertEqual("bar foo true"); + }) + + /** + * @tc.name: testUrlGet001 + * @tc.desc: Returns the first value associated to the given search parameter. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlGet001', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2") + var result = params.get("1") + expect(result).assertEqual(undefined) + }) + + /** + * @tc.name: testUrlForEach002 + * @tc.desc: Returns the first value associated to the given search parameter. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlForEach002', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2") + var result = params.get("key2") + expect(result).assertEqual("value2") + }) + + /** + * @tc.name: testUrlForEach003 + * @tc.desc: Returns the first value associated to the given search parameter. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlForEach003', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2") + params.append("5","JKL") + var result = params.get("5") + expect(result).assertEqual("JKL") + }) + + /** + * @tc.name: testUrlForEach004 + * @tc.desc: Returns the first value associated to the given search parameter. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlForEach004', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2") + var result = params.get("key1") + expect(result).assertEqual("value1") + }) + + /** + * @tc.name: testUrlForEach005 + * @tc.desc: Returns the first value associated to the given search parameter. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlForEach005', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2") + params.append("jss","JL") + var result = params.get("jss") + expect(result).assertEqual("JL") + }) + + /** + * @tc.name: testUrlGetAll001 + * @tc.desc: Returns all key-value pairs associated with a given search parameter as an array. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlGetAll001', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2") + params.append("key1","AAA") + var result = params.getAll("key1") + expect(result).assertEqual("value1,AAA") + }) + + /** + * @tc.name: testUrlGetAll002 + * @tc.desc: Returns all key-value pairs associated with a given search parameter as an array. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlGetAll002', 0, function () { + let params = new Url.URLSearchParams("key1=value1&8=DEF") + params.append("8","A8A") + var result = params.getAll("8") + expect(result).assertEqual("DEF,A8A") + }) + + /** + * @tc.name: testUrlGetAll003 + * @tc.desc: Returns all key-value pairs associated with a given search parameter as an array. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlGetAll003', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2&key3=da") + params.append("key3","A3A") + var result = params.getAll("key3") + expect(result).assertEqual("da,A3A") + }) + + /** + * @tc.name: testUrlGetAll004 + * @tc.desc: Returns all key-value pairs associated with a given search parameter as an array. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlGetAll004', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2&key3=大") + params.append("key3","A3A") + var result = params.getAll("key4") + expect(result).assertEqual('') + }) + + /** + * @tc.name: testUrlGetAll005 + * @tc.desc: Returns all key-value pairs associated with a given search parameter as an array. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlGetAll005', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2&key3=大") + params.append("key3","A3A") + var result = params.getAll("key2") + expect(result).assertEqual("value2") + }) + + /** + * @tc.name: testUrlHas001 + * @tc.desc: Returns a Boolean that indicates whether a parameter with the specified name exists. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlHas001', 0, function () { + let params = new Url.URLSearchParams("key1=value1&key2=value2&key3=大") + var result = params.has("2") + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testUrlHas002 + * @tc.desc: Returns a Boolean that indicates whether a parameter with the specified name exists. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlHas002', 0, function () { + let params = new Url.URLSearchParams("小=value1&key2=value2&key3=大") + var result = params.has("小") + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testUrlHas003 + * @tc.desc: Returns a Boolean that indicates whether a parameter with the specified name exists. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlHas003', 0, function () { + let params = new Url.URLSearchParams("小=value1&¥=value2&key3=大") + params.append("¥","ACA") + var result = params.has("¥") + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testUrlHas004 + * @tc.desc: Returns a Boolean that indicates whether a parameter with the specified name exists. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlHas004', 0, function () { + let params = new Url.URLSearchParams("小=value1&key2=value2&key3=大") + var result = params.has("无") + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testUrlHas005 + * @tc.desc: Returns a Boolean that indicates whether a parameter with the specified name exists. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlHas005', 0, function () { + let params = new Url.URLSearchParams("小=value1&¥=value2&key3=大") + params.append("¥","ACA") + var result = params.has("¥11") + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testUrlKeys001 + * @tc.desc: Returns an iterator allowing to go through all keys contained in this object. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlKeys001', 0, function () { + let params = new Url.URLSearchParams("小=value1&¥=value2&key3=大"); + var arr={}; + var i = 0; + for(var key of params.keys()) { + arr[i] = key + i++ + }; + expect(arr[0]).assertEqual("小"); + }) + + /** + * @tc.name: testUrlKeys002 + * @tc.desc: Returns an iterator allowing to go through all keys contained in this object. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlKeys002', 0, function () { + let params = new Url.URLSearchParams("小=value1&¥=value2&key3=大"); + var arr={}; + var i = 0; + for(var key of params.keys()) { + arr[i] = key + i++ + }; + expect(arr[1]).assertEqual("¥"); + }) + + /** + * @tc.name: testUrlKeys003 + * @tc.desc: Returns an iterator allowing to go through all keys contained in this object. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlKeys003', 0, function () { + let params = new Url.URLSearchParams("小=value1&¥=value2&key3=大"); + var arr={}; + var i = 0; + for(var key of params.keys()) { + arr[i] = key + i++ + }; + expect(arr[2]).assertEqual("key3"); + }) + + /** + * @tc.name: testUrlKeys004 + * @tc.desc: Returns an iterator allowing to go through all keys contained in this object. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlKeys004', 0, function () { + let params = new Url.URLSearchParams("小=value1&¥=value2&key3=大&key4=六"); + var arr={}; + var i = 0; + for(var key of params.keys()) { + arr[i] = key + i++ + }; + expect(arr[3]).assertEqual("key4"); + }) + + /** + * @tc.name: testUrlKeys005 + * @tc.desc: Returns an iterator allowing to go through all keys contained in this object. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlKeys005', 0, function () { + let params = new Url.URLSearchParams("小=value1&¥=value2&key3=大&key4=六&key5=发"); + var arr={}; + var i = 0; + for(var key of params.keys()) { + arr[i] = key + i++ + }; + expect(arr[4]).assertEqual("key5"); + }) + + /** + * @tc.name: testUrlSet001 + * @tc.desc: Sets the value associated with a given search parameter to the given value. + * If there were several matching values, this method deletes the others. + * If the search parameter doesn't exist, this method creates it. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlSet001', 0, function () { + let params = new Url.URLSearchParams("1=value1&2=value2&key3=3"); + // params.append("11","ACA"); + params.set("11","CCC"); + var res = params.toString(); + expect(res).assertEqual("1=value1&2=value2&key3=3&11=CCC"); + }) + + /** + * @tc.name: testUrlSet002 + * @tc.desc: Sets the value associated with a given search parameter to the given value. + * If there were several matching values, this method deletes the others. + * If the search parameter doesn't exist, this method creates it. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlSet002', 0, function () { + let params = new Url.URLSearchParams("1=value1&2=value2&key3=3"); + params.set('10','BBB'); + var res = params.toString(); + expect(res).assertEqual("1=value1&2=value2&key3=3&10=BBB"); + }) + + /** + * @tc.name: testUrlSet003 + * @tc.desc: Sets the value associated with a given search parameter to the given value. + * If there were several matching values, this method deletes the others. + * If the search parameter doesn't exist, this method creates it. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlSet003', 0, function () { + let params = new Url.URLSearchParams("1=value1&2=value2&key3=3"); + params.set("ma 大" ,"10¥"); + var res = params.toString(); + expect(res).assertEqual("1=value1&2=value2&key3=3&ma+%E5%A4%A7=10%EF%BF%A5"); + }) + + /** + * @tc.name: testUrlSet004 + * @tc.desc: Sets the value associated with a given search parameter to the given value. + * If there were several matching values, this method deletes the others. + * If the search parameter doesn't exist, this method creates it. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlSet004', 0, function () { + let params = new Url.URLSearchParams("1=value1&2=value2&key3=3"); + // params.append("1","ACA"); + params.set("1","CCC"); + var res = params.toString(); + expect(res).assertEqual("1=CCC&2=value2&key3=3"); + }) + + /** + * @tc.name: testUrlSet005 + * @tc.desc: Sets the value associated with a given search parameter to the given value. + * If there were several matching values, this method deletes the others. + * If the search parameter doesn't exist, this method creates it. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlSet005', 0, function () { + let params = new Url.URLSearchParams("1=value1&2=value2&key3=3"); + params.set('12','BBB'); + var res = params.toString(); + expect(res).assertEqual("1=value1&2=value2&key3=3&12=BBB"); + }) + + /** + * @tc.name: testUrlSort001 + * @tc.desc: Sort all key/value pairs contained in this object in place and return undefined. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlSort001', 0, function () { + let params = new Url.URLSearchParams("1=value1&3=value3&2=key2"); + params.sort(); + var res = params.toString(); + expect(res).assertEqual("1=value1&2=key2&3=value3"); + }) + + /** + * @tc.name: testUrlSort002 + * @tc.desc: Sort all key/value pairs contained in this object in place and return undefined. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlSort002', 0, function () { + let params = new Url.URLSearchParams("a=value1&c=value2&b=key2"); + params.sort(); + var res = params.toString(); + expect(res).assertEqual("a=value1&b=key2&c=value2"); + }) + + /** + * @tc.name: testUrlSort003 + * @tc.desc: Sort all key/value pairs contained in this object in place and return undefined. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlSort003', 0, function () { + let params = new Url.URLSearchParams("d=value1&c=value2&b=33"); + params.append("a","ACA"); + params.sort(); + var res = params.toString(); + expect(res).assertEqual("a=ACA&b=33&c=value2&d=value1"); + }) + + /** + * @tc.name: testUrlSort004 + * @tc.desc: Sort all key/value pairs contained in this object in place and return undefined. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlSort004', 0, function () { + let params = new Url.URLSearchParams("1=value1&3=value3&2=key2&4=key4"); + params.sort(); + var res = params.toString(); + expect(res).assertEqual("1=value1&2=key2&3=value3&4=key4"); + }) + + /** + * @tc.name: testUrlSort005 + * @tc.desc: Sort all key/value pairs contained in this object in place and return undefined. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlSort005', 0, function () { + let params = new Url.URLSearchParams("a=value1&c=value2&4=key4&b=key2"); + params.sort(); + var res = params.toString(); + expect(res).assertEqual("4=key4&a=value1&b=key2&c=value2"); + }) + + /** + * @tc.name: testUrlValues001 + * @tc.desc: Returns an iterator allowing to go through all values contained in this object. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlValues001', 0, function () { + let params = new Url.URLSearchParams("d=value1&c=value2&b=大") + var arr={} + var i = 0 + for(var value of params.values()) { + arr[i] = value + i++ + } + expect(arr[0]).assertEqual("value1") + }) + + /** + * @tc.name: testUrlValues002 + * @tc.desc: Returns an iterator allowing to go through all values contained in this object. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlValues002', 0, function () { + let params = new Url.URLSearchParams("d=value1&c=value2&b=大") + var arr={} + var i = 0 + for(var value of params.values()) { + arr[i] = value + i++ + } + expect(arr[1]).assertEqual("value2") + }) + + /** + * @tc.name: testUrlValues003 + * @tc.desc: Returns an iterator allowing to go through all values contained in this object. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlValues003', 0, function () { + let params = new Url.URLSearchParams("d=value1&c=value2&b=大") + params.append("a","ACA") + var arr={} + var i = 0 + for(var value of params.values()) { + arr[i] = value + i++ + } + expect(arr[3]).assertEqual("ACA") + }) + + /** + * @tc.name: testUrlValues004 + * @tc.desc: Returns an iterator allowing to go through all values contained in this object. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlValues004', 0, function () { + let params = new Url.URLSearchParams("d=value1&c=value2&b=大&4=key4") + var arr={} + var i = 0 + for(var value of params.values()) { + arr[i] = value + i++ + } + expect(arr[3]).assertEqual("key4") + }) + + /** + * @tc.name: testUrlValues005 + * @tc.desc: Returns an iterator allowing to go through all values contained in this object. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlValues005', 0, function () { + let params = new Url.URLSearchParams("d=value1&c=value2&b=大&4=key4&5=key5") + var arr={} + var i = 0 + for(var value of params.values()) { + arr[i] = value + i++ + } + expect(arr[4]).assertEqual("key5") + }) + + /** + * @tc.name: testUrlToString001 + * @tc.desc: Returns a query string suitable for use in a URL. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlToString001', 0, function () { + let params = new Url.URLSearchParams("d=value1&c=value2&b=大") + var result= params.toString() + expect(result).assertEqual("d=value1&c=value2&b=%E5%A4%A7") + }) + + /** + * @tc.name: testUrlToString002 + * @tc.desc: Returns a query string suitable for use in a URL. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlToString002', 0, function () { + let params = new Url.URLSearchParams("d=value1&c=value2&b= 大") + params.append("1 12","QQQ") + var result= params.toString() + expect(result).assertEqual("d=value1&c=value2&b=+%E5%A4%A7&1+12=QQQ") + }) + + /** + * @tc.name: testUrlToString003 + * @tc.desc: Returns a query string suitable for use in a URL. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlToString003', 0, function () { + let params = new Url.URLSearchParams("¥=)") + params.delete("5") + var result= params.toString() + expect(result).assertEqual("%EF%BF%A5=%29") + }) + + /** + * @tc.name: testUrlToString004 + * @tc.desc: Returns a query string suitable for use in a URL. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlToString004', 0, function () { + let params = new Url.URLSearchParams("d=value1&c=value2&b=大&4=key4") + var result= params.toString() + expect(result).assertEqual("d=value1&c=value2&b=%E5%A4%A7&4=key4") + }) + + /** + * @tc.name: testUrlToString005 + * @tc.desc: Returns a query string suitable for use in a URL. + * @tc.require: AR000GFB2S + * @tc.author: maxiaodong + */ + it('testUrlToString005', 0, function () { + let params = new Url.URLSearchParams("d=value1&c=value2&b= 大&4=key4&5=key5") + params.append("1 12","QQQ") + var result= params.toString() + expect(result).assertEqual("d=value1&c=value2&b=+%E5%A4%A7&4=key4&5=key5&1+12=QQQ") + }) + + /** + * @tc.name: testUrlSearchParamsConstruction001 + * @tc.desc: A parameterized constructor used to create an URLSearchParams instance. + * @tc.require: AR000GFB2S + * @tc.author: zhangyouyou + */ + it('testUrlSearchParamsConstruction001', 0, function () { + let params = new Url.URLSearchParams('?user=abc&query=xyz') + var result= params.toString() + expect(result).assertEqual("user=abc&query=xyz") + }) + + /** + * @tc.name: testUrlSearchParamsConstruction002 + * @tc.desc: A parameterized constructor used to create an URLSearchParams instance. + * @tc.require: AR000GFB2S + * @tc.author: zhangyouyou + */ + it('testUrlSearchParamsConstruction002', 0, function () { + let params = new Url.URLSearchParams({ + user: 'abc', + query: ['first', 'second'] + }); + var result= params.toString() + expect(result).assertEqual("user=abc&query=first%2Csecond") + }) + + /** + * @tc.name: testUrlSearchParamsConstruction003 + * @tc.desc: A parameterized constructor used to create an URLSearchParams instance. + * @tc.require: AR000GFB2S + * @tc.author: zhangyouyou + */ + it('testUrlSearchParamsConstruction003', 0, function () { + let params = new Url.URLSearchParams([ + ['user', 'abc'], + ['query', 'first'], + ['query', 'second'], + ]); + var result= params.toString() + expect(result).assertEqual("user=abc&query=first&query=second") + }) + + /** + * @tc.name: testUrlSearchParamsConstruction004 + * @tc.desc: A parameterized constructor used to create an URLSearchParams instance. + * @tc.require: AR000GFB2S + * @tc.author: zhangyouyou + */ + it('testUrlSearchParamsConstruction004', 0, function () { + const map = new Map(); + map.set('user', 'abc'); + map.set('query', 'xyz'); + let params = new Url.URLSearchParams(map) + var result= params.toString() + expect(result).assertEqual("user=abc&query=xyz") + }) + + /** + * @tc.name: testUrlSearchParamsConstruction005 + * @tc.desc: A parameterized constructor used to create an URLSearchParams instance. + * @tc.require: AR000GFB2S + * @tc.author: zhangyouyou + */ + it('testUrlSearchParamsConstruction005', 0, function () { + function* getQueryPairs() { + yield ['user', 'abc']; + yield ['query', 'first']; + yield ['query', 'second']; + } + let params = new Url.URLSearchParams(getQueryPairs()); + var result= params.toString() + expect(result).assertEqual("user=abc&query=first&query=second") + }) + + /** + * @tc.name: testUrlSearchParamsConstruction006 + * @tc.desc: A parameterized constructor used to create an URLSearchParams instance. + * @tc.require: AR000GFB2S + * @tc.author: zhangyouyou + */ + it('testUrlSearchParamsConstruction006', 0, function () { + let params = new Url.URLSearchParams() + params.append('abcde','fghki') + var paramsResult = params.toString() + expect(paramsResult).assertEqual('abcde=fghki') + }) + + /** + * @tc.name: testUrlSearchParamsConstruction007 + * @tc.desc: A parameterized constructor used to create an URLSearchParams instance. + * @tc.require: AR000GFB2S + * @tc.author: zhangyouyou + */ + it('testUrlSearchParamsConstruction007', 0, function () { + let param + let params = new Url.URLSearchParams(param) + params.append('abcde','fghki') + var paramsResult = params.toString() + expect(paramsResult).assertEqual('abcde=fghki') + }) + + /** + * @tc.name: testUrlToString001 + * @tc.desc: Returns the serialized URL as a string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlToString001', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + var result= params.toString() + expect(result).assertEqual("http://username:password@host:8080/directory/file?query#fragment") + }) + + /** + * @tc.name: testUrlToString002 + * @tc.desc: Returns the serialized URL as a string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlToString002', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file') + var result= params.toString() + expect(result).assertEqual("http://username:password@host:8080/directory/file") + }) + + /** + * @tc.name: testUrlToString003 + * @tc.desc: Returns the serialized URL as a string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlToString003', 0, function () { + let params = new Url.URL('http://username:password@host:8080#fragment') + var result= params.toString() + expect(result).assertEqual("http://username:password@host:8080/#fragment") + }) + + /** + * @tc.name: testUrlToString004 + * @tc.desc: Returns the serialized URL as a string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlToString004', 0, function () { + let params = new Url.URL('http1://host/directory/file?query#fragment') + var result= params.toString() + expect(result).assertEqual("http1://host/directory/file?query#fragment") + }) + + /** + * @tc.name: testUrlToString005 + * @tc.desc: Returns the serialized URL as a string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlToString005', 0, function () { + let params = new Url.URL('http:host:8080/directory/file?query#fragment') + var result= params.toString() + expect(result).assertEqual("http://host:8080/directory/file?query#fragment") + }) + + /** + * @tc.name: testUrlHref001 + * @tc.desc: Gets and sets the serialized URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHref001', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + var result= params.href + expect(result).assertEqual("http://username:password@host:8080/directory/file?query#fragment") + }) + + /** + * @tc.name: testUrlHref002 + * @tc.desc: Gets and sets the serialized URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHref002', 0, function () { + let params = new Url.URL('http://host:8080/directory/file?query#fragment') + var result= params.href + expect(result).assertEqual("http://host:8080/directory/file?query#fragment") + }) + + /** + * @tc.name: testUrlHref003 + * @tc.desc: Gets and sets the serialized URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHref003', 0, function () { + let params = new Url.URL('http://username:password@host:8080') + var result= params.href + expect(result).assertEqual("http://username:password@host:8080/") + }) + + /** + * @tc.name: testUrlHref004 + * @tc.desc: Gets and sets the serialized URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHref004', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.href = 'http1://myhost/path?sss=1#ff'; + var result= params.href + expect(result).assertEqual("http1://myhost/path?sss=1#ff") + }) + + /** + * @tc.name: testUrlHref005 + * @tc.desc: Gets and sets the serialized URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHref005', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.href = 'http://myhost:99/path#ff'; + var result= params.href + expect(result).assertEqual("http://myhost:99/path#ff") + }) + + /** + * @tc.name: testUrlOrigin001 + * @tc.desc: Gets the read-only serialization of the URL's origin. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlOrigin001', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + var result= params.origin + expect(result).assertEqual('http://host:8080') + }) + + /** + * @tc.name: testUrlOrigin002 + * @tc.desc: Gets the read-only serialization of the URL's origin. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlOrigin002', 0, function () { + let params = new Url.URL('http://username:password@host:11/directory/file?query#fragment') + var result= params.origin + expect(result).assertEqual('http://host:11') + }) + + /** + * @tc.name: testUrlOrigin003 + * @tc.desc: Gets the read-only serialization of the URL's origin. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlOrigin003', 0, function () { + let params = new Url.URL('http://username:password@host/directory/file?query#fragment') + var result= params.origin + expect(result).assertEqual('http://host') + }) + + /** + * @tc.name: testUrlOrigin004 + * @tc.desc: Gets the read-only serialization of the URL's origin. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlOrigin004', 0, function () { + let params = new Url.URL('http://username:password@aaaasshost:212/directory/file?query#fragment') + var result= params.origin + expect(result).assertEqual('http://aaaasshost:212') + }) + + /** + * @tc.name: testUrlOrigin005 + * @tc.desc: Gets the read-only serialization of the URL's origin. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlOrigin005', 0, function () { + let params = new Url.URL('http://username:password@host22:100#fragment') + var result= params.origin + expect(result).assertEqual('http://host22:100') + }) + + /** + * @tc.name: testUrlProtocol001 + * @tc.desc: Gets and sets the protocol portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlProtocol001', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + var result= params.protocol + expect(result).assertEqual('http:') + }) + + /** + * @tc.name: testUrlProtocol002 + * @tc.desc: Gets and sets the protocol portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlProtocol002', 0, function () { + let params = new Url.URL('http1://username:password@host:8080/directory/file?query#fragment') + var result= params.protocol + expect(result).assertEqual('http1:') + }) + + /** + * @tc.name: testUrlProtocol003 + * @tc.desc: Gets and sets the protocol portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlProtocol003', 0, function () { + let params = new Url.URL('https://username:password@host:8080/directory/file?query#fragment') + var result= params.protocol + expect(result).assertEqual('https:') + }) + + /** + * @tc.name: testUrlProtocol004 + * @tc.desc: Gets and sets the protocol portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlProtocol004', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.protocol = 'https:'; + var result= params.protocol + expect(result).assertEqual('https:') + }) + + /** + * @tc.name: testUrlProtocol005 + * @tc.desc: Gets and sets the protocol portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlProtocol005', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.protocol = 'ftp:'; + var result= params.protocol + expect(result).assertEqual('ftp:') + }) + + /** + * @tc.name: testUrlUsername001 + * @tc.desc: Gets and sets the username portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlUsername001', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + var result= params.username + expect(result).assertEqual('username') + }) + + /** + * @tc.name: testUrlUsername002 + * @tc.desc: Gets and sets the username portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlUsername002', 0, function () { + let params = new Url.URL('http://zhao:password@host:8080/directory/file?query#fragment') + var result= params.username + expect(result).assertEqual('zhao') + }) + + /** + * @tc.name: testUrlUsername003 + * @tc.desc: Gets and sets the username portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlUsername003', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.username = 'skk' + var result= params.username + expect(result).assertEqual('skk') + }) + + /** + * @tc.name: testUrlUsername004 + * @tc.desc: Gets and sets the username portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlUsername004', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.username = 'skp111' + var result= params.username + expect(result).assertEqual('skp111') + }) + + /** + * @tc.name: testUrlUsername005 + * @tc.desc: Gets and sets the username portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlUsername005', 0, function () { + let params = new Url.URL('http://usme@host:8080/directory/file?query#fragment') + var result= params.username + expect(result).assertEqual('usme') + }) + + /** + * @tc.name: testUrlPassword001 + * @tc.desc: Gets and sets the password portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPassword001', 0, function () { + let params = new Url.URL('http://username:11@host:8080/directory/file?query#fragment') + var result= params.password + expect(result).assertEqual('11') + }) + + /** + * @tc.name: testUrlPassword002 + * @tc.desc: Gets and sets the password portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPassword002', 0, function () { + let params = new Url.URL('http://username:23aa@host:8080/directory/file?query#fragment') + var result= params.password + expect(result).assertEqual('23aa') + }) + + /** + * @tc.name: testUrlPassword003 + * @tc.desc: Gets and sets the password portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPassword003', 0, function () { + let params = new Url.URL('http://username@host:8080/directory/file?query#fragment') + var result= params.password + expect(result).assertEqual('') + }) + + /** + * @tc.name: testUrlPassword004 + * @tc.desc: Gets and sets the password portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPassword004', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.password = '1234' + var result= params.password + expect(result).assertEqual('1234') + }) + + /** + * @tc.name: testUrlPassword005 + * @tc.desc: Gets and sets the password portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPassword005', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.password = ''; + var result= params.password + expect(result).assertEqual('') + }) + + /** + * @tc.name: testUrlHost001 + * @tc.desc: Gets and sets the host portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHost001', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + var result= params.host + expect(result).assertEqual('host:8080') + }) + + /** + * @tc.name: testUrlHost002 + * @tc.desc: Gets and sets the host portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHost002', 0, function () { + let params = new Url.URL('http://username:password@hosthost/directory/file?query#fragment') + var result= params.host + expect(result).assertEqual('hosthost') + }) + + /** + * @tc.name: testUrlHost003 + * @tc.desc: Gets and sets the host portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHost003', 0, function () { + let params = new Url.URL('http://username:password@host:199/directory/file?query#fragment') + var result= params.host + expect(result).assertEqual('host:199') + }) + + /** + * @tc.name: testUrlHost004 + * @tc.desc: Gets and sets the host portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHost004', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.host = 'jkjk' + var result= params.host + expect(result).assertEqual('jkjk:8080') + }) + + /** + * @tc.name: testUrlHost005 + * @tc.desc: Gets and sets the host portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHost005', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.host = 'jkjk:100' + var result= params.host + expect(result).assertEqual('jkjk:100') + }) + + /** + * @tc.name: testUrlHostname001 + * @tc.desc: Gets and sets the host name portion of the URL,not include the port. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHostname001', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + var result= params.hostname + expect(result).assertEqual('host') + }) + + /** + * @tc.name: testUrlHostname002 + * @tc.desc: Gets and sets the host name portion of the URL,not include the port. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHostname002', 0, function () { + let params = new Url.URL('http://username:password@host123:8080/directory/file?query#fragment') + var result= params.hostname + expect(result).assertEqual('host123') + }) + + /** + * @tc.name: testUrlHostname003 + * @tc.desc: Gets and sets the host name portion of the URL,not include the port. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHostname003', 0, function () { + let params = new Url.URL('http://username:password@885ssa:8080/directory/file?query#fragment') + var result= params.hostname + expect(result).assertEqual('885ssa') + }) + + /** + * @tc.name: testUrlHostname004 + * @tc.desc: Gets and sets the host name portion of the URL,not include the port. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHostname004', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.hostname = 'sksk' + var result= params.hostname + expect(result).assertEqual('sksk') + }) + + /** + * @tc.name: testUrlHostname005 + * @tc.desc: Gets and sets the host name portion of the URL,not include the port. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHostname005', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.hostname = 'hosthost' + var result= params.hostname + expect(result).assertEqual('hosthost') + }) + + /** + * @tc.name: testUrlPort001 + * @tc.desc: Gets and sets the port portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPort001', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + var result= params.port + expect(result).assertEqual('8080') + }) + + /** + * @tc.name: testUrlPort002 + * @tc.desc: Gets and sets the port portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPort002', 0, function () { + let params = new Url.URL('http://username:password@host:100/directory/file?query#fragment') + var result= params.port + expect(result).assertEqual('100') + }) + + /** + * @tc.name: testUrlPort003 + * @tc.desc: Gets and sets the port portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPort003', 0, function () { + let params = new Url.URL('http://username:password@host/directory/file?query#fragment') + var result= params.port + expect(result).assertEqual('') + }) + + /** + * @tc.name: testUrlPort004 + * @tc.desc: Gets and sets the port portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPort004', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.port = '99' + var result= params.port + expect(result).assertEqual('99') + }) + + /** + * @tc.name: testUrlPort005 + * @tc.desc: Gets and sets the port portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPort005', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.port = '123' + var result= params.port + expect(result).assertEqual('123') + }) + + /** + * @tc.name: testUrlPathname001 + * @tc.desc: Gets and sets the path portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPathname001', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + var result= params.pathname + expect(result).assertEqual('/directory/file') + }) + + /** + * @tc.name: testUrlPathname002 + * @tc.desc: Gets and sets the path portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPathname002', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory?query#fragment') + var result= params.pathname + expect(result).assertEqual('/directory') + }) + + /** + * @tc.name: testUrlPathname003 + * @tc.desc: Gets and sets the path portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPathname003', 0, function () { + let params = new Url.URL('http://username:password@host:8080?query#fragment') + var result= params.pathname + expect(result).assertEqual('/') + }) + + /** + * @tc.name: testUrlPathname004 + * @tc.desc: Gets and sets the path portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPathname004', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.pathname = 'path' + var result= params.pathname + expect(result).assertEqual('/path') + }) + + /** + * @tc.name: testUrlPathname005 + * @tc.desc: Gets and sets the path portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlPathname005', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query#fragment') + params.pathname = '/directory/file11' + var result= params.pathname + expect(result).assertEqual('/directory/file11') + }) + + /** + * @tc.name: testUrlSearch001 + * @tc.desc: Gets and sets the serialized query portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlSearch001', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query=qqqq#fragment') + var result= params.search + expect(result).assertEqual('?query=qqqq') + }) + + /** + * @tc.name: testUrlSearch002 + * @tc.desc: Gets and sets the serialized query portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlSearch002', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query=qqqq&ll=pp#fragment') + var result= params.search + expect(result).assertEqual('?query=qqqq&ll=pp') + }) + + /** + * @tc.name: testUrlSearch003 + * @tc.desc: Gets and sets the serialized query portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlSearch003', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?ppp9875=77#fragment') + var result= params.search + expect(result).assertEqual('?ppp9875=77') + }) + + /** + * @tc.name: testUrlSearch004 + * @tc.desc: Gets and sets the serialized query portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlSearch004', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query=qqqq#fragment') + params.search = 'kk=99' + var result= params.search + expect(result).assertEqual('?kk=99') + }) + + /** + * @tc.name: testUrlSearch005 + * @tc.desc: Gets and sets the serialized query portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlSearch005', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query=qqqq#fragment') + params.search = 'pppk=99' + var result= params.search + expect(result).assertEqual('?pppk=99') + }) + + /** + * @tc.name: testUrlHash001 + * @tc.desc: Gets and sets the fragment portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHash001', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#fragment') + var result= params.hash + expect(result).assertEqual('#fragment') + }) + + /** + * @tc.name: testUrlHash002 + * @tc.desc: Gets and sets the fragment portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHash002', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#fragment') + params.hash = '123456' + var result= params.hash + expect(result).assertEqual('#123456') + }) + + /** + * @tc.name: testUrlHash003 + * @tc.desc: Gets and sets the fragment portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHash003', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#poiu') + var result= params.hash + expect(result).assertEqual('#poiu') + }) + + /** + * @tc.name: testUrlHash004 + * @tc.desc: Gets and sets the fragment portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHash004', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp') + var result= params.hash + expect(result).assertEqual('') + }) + + /** + * @tc.name: testUrlHash005 + * @tc.desc: Gets and sets the fragment portion of the URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlHash005', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#fragment') + params.hash = 'qwer' + var result= params.hash + expect(result).assertEqual('#qwer') + }) + + /** + * @tc.name: testUrlToJson001 + * @tc.desc: Returns the serialized URL as a string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlToJson001', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory/file?query=pppppp#qwer=da') + var result= params.toJSON() + expect(result).assertEqual('http://username:password@host:8080/directory/file?query=pppppp#qwer=da') + }) + + /** + * @tc.name: testUrlToJson002 + * @tc.desc: Returns the serialized URL as a string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlToJson002', 0, function () { + let params = new Url.URL('http://host:8080/directory/file?query=pppppp#qwer=da') + var result= params.toJSON() + expect(result).assertEqual('http://host:8080/directory/file?query=pppppp#qwer=da') + }) + + /** + * @tc.name: testUrlToJson003 + * @tc.desc: Returns the serialized URL as a string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlToJson003', 0, function () { + let params = new Url.URL('http://username:password@host:8080') + var result= params.toJSON() + expect(result).assertEqual('http://username:password@host:8080/') + }) + + /** + * @tc.name: testUrlToJson004 + * @tc.desc: Returns the serialized URL as a string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlToJson004', 0, function () { + let params = new Url.URL('http11://username:password@host:8080?query=pppppp#qwer=da') + var result= params.toJSON() + expect(result).assertEqual('http11://username:password@host:8080?query=pppppp#qwer=da') + }) + + /** + * @tc.name: testUrlToJson005 + * @tc.desc: Returns the serialized URL as a string. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlToJson005', 0, function () { + let params = new Url.URL('http://username:password@host:8080/directory') + var result= params.toJSON() + expect(result).assertEqual('http://username:password@host:8080/directory') + }) + + /** + * @tc.name: testUrlIPv6001 + * @tc.desc: Gets and sets the serialized URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlIPv6001', 0, function () { + let params = new Url.URL('http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html') + var result= params.href + expect(result).assertEqual('http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/index.html') + }) + + /** + * @tc.name: testUrlIPv6002 + * @tc.desc: Gets and sets the serialized URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlIPv6002', 0, function () { + let params = new Url.URL('http://[1080:0:0:0:8:800:200C:417A]/index.html') + var result= params.href + expect(result).assertEqual('http://[1080::8:800:200c:417a]/index.html') + }) + + /** + * @tc.name: testUrlIPv6003 + * @tc.desc: Gets and sets the serialized URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlIPv6003', 0, function () { + let params = new Url.URL('http://[::FFFF:129.144.52.38]:80/index.html') + var result= params.href + expect(result).assertEqual('http://[::ffff:8190:3426]/index.html') + }) + + /** + * @tc.name: testUrlIPv4001 + * @tc.desc: Gets and sets the serialized URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlIPv4001', 0, function () { + let params = new Url.URL('http://0377.0xff.255.1:80/index.html') + var result= params.href + expect(result).assertEqual('http://255.255.255.1/index.html') + }) + + /** + * @tc.name: testUrlIPv4002 + * @tc.desc: Gets and sets the serialized URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlIPv4002', 0, function () { + let params = new Url.URL('http://0377.0xff.255.g/index.html') + var result= params.href + expect(result).assertEqual('http://0377.0xff.255.g/index.html') + }) + + /** + * @tc.name: testUrlIPv4003 + * @tc.desc: Gets and sets the serialized URL. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlIPv4003', 0, function () { + let params = new Url.URL('http://190.254.245.9:80/index.html') + var result= params.href + expect(result).assertEqual('http://190.254.245.9/index.html') + }) + + /** + * @tc.name: testUrlConstruction001 + * @tc.desc: URL constructor, which is used to instantiate a URL object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlConstruction001', 0, function () { + let params = new Url.URL('https://developer.mozilla.org',) + var result= params.href + expect(result).assertEqual('https://developer.mozilla.org/') + }) + + /** + * @tc.name: testUrlConstruction002 + * @tc.desc: URL constructor, which is used to instantiate a URL object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlConstruction002', 0, function () { + let params = new Url.URL('https://developer.mozilla.org','flie:/developer.mozilla.org') + var result= params.href + expect(result).assertEqual('https://developer.mozilla.org/') + }) + + /** + * @tc.name: testUrlConstruction003 + * @tc.desc: URL constructor, which is used to instantiate a URL object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlConstruction003', 0, function () { + let params = new Url.URL('https://developer.mozilla.org','ftp://www.example.com') + var result= params.href + expect(result).assertEqual('https://developer.mozilla.org/') + }) + + /** + * @tc.name: testUrlConstruction004 + * @tc.desc: URL constructor, which is used to instantiate a URL object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlConstruction004', 0, function () { + let params = new Url.URL(' ', 'http://www.example.com') + var result= params.href + expect(result).assertEqual('http://www.example.com/') + }) + + /** + * @tc.name: testUrlConstruction005 + * @tc.desc: URL constructor, which is used to instantiate a URL object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlConstruction005', 0, function () { + let params = new Url.URL('.', 'http://www.example.com') + var result= params.href + expect(result).assertEqual('http://www.example.com/') + }) + + /** + * @tc.name: testUrlConstruction006 + * @tc.desc: URL constructor, which is used to instantiate a URL object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlConstruction006', 0, function () { + let params = new Url.URL('../h:', 'http://www.example.com') + var result= params.href + expect(result).assertEqual('http://www.example.com/h:') + }) + + /** + * @tc.name: testUrlConstruction007 + * @tc.desc: URL constructor, which is used to instantiate a URL object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlConstruction007', 0, function () { + let params = new Url.URL('/sca/./path/path/../scasa/jjjjj', 'http://www.example.com') + var result= params.href + expect(result).assertEqual('http://www.example.com/sca/path/scasa/jjjjj') + }) + + /** + * @tc.name: testUrlConstruction008 + * @tc.desc: URL constructor, which is used to instantiate a URL object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlConstruction008', 0, function () { + let params = new Url.URL('/../sca/./path/path/../scasa/jjjjj', 'http://www.example.com') + var result= params.href + expect(result).assertEqual('http://www.example.com/sca/path/scasa/jjjjj') + }) + + /** + * @tc.name: testUrlConstruction009 + * @tc.desc: URL constructor, which is used to instantiate a URL object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlConstruction009', 0, function () { + let params = new Url.URL( '/../sca/./path/path/../scasa/jjjjj', 'file://www.example.com') + var result= params.href + expect(result).assertEqual('file://www.example.com/sca/path/scasa/jjjjj') + }) + + /** + * @tc.name: testUrlConstruction010 + * @tc.desc: URL constructor, which is used to instantiate a URL object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlConstruction010', 0, function () { + let params = new Url.URL('/../sca/./path/path/../scasa/jjjjj', 'file1://www.example.com') + var result= params.href + expect(result).assertEqual('file1://www.example.com/sca/path/scasa/jjjjj') + }) + + /** + * @tc.name: testUrlConstruction011 + * @tc.desc: URL constructor, which is used to instantiate a URL object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlConstruction011', 0, function () { + let params = new Url.URL('htt1p://www.0902zy.cn/path?abc=123&def=456#yyyy') + let params1 = new Url.URL('www.baidu.com/ssaa',params) + var result = params1.href + expect(result).assertEqual('htt1p://www.0902zy.cn/www.baidu.com/ssaa') + }) + + /** + * @tc.name: testUrlConstruction012 + * @tc.desc: URL constructor, which is used to instantiate a URL object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlConstruction012', 0, function () { + let params = new Url.URL('htt1p://www.0902zy.cn/path?abc=123&def=456#yyyy') + let params1 = new Url.URL('//www.baidu.com/ssaa',params) + var result = params1.href + expect(result).assertEqual('htt1p://www.baidu.com/ssaa') + }) + + /** + * @tc.name: testUrlConstruction013 + * @tc.desc: URL constructor, which is used to instantiate a URL object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlConstruction013', 0, function () { + let params = new Url.URL('htt1p://www.0902zy.cn/path?abc=123&def=456#yyyy') + let params1 = new Url.URL('',params) + var result = params1.href + expect(result).assertEqual('htt1p://www.0902zy.cn/path?abc=123&def=456#yyyy') + }) + + /** + * @tc.name: testUrlConstruction014 + * @tc.desc: URL constructor, which is used to instantiate a URL object. + * @tc.require: AR000GFB2S + * @tc.author: zhaoduwei + */ + it('testUrlConstruction014', 0, function () { + let params = new Url.URL('htt1p://www.0902zy.cn/path?abc=123&def=456#yyyy') + var result = params.searchParams.toString(); + expect(result).assertEqual('abc=123&def=456') + }) +}) \ No newline at end of file diff --git a/compileruntime/url_lib_standard/src/main/resources/base/media/icon.png b/compileruntime/url_lib_standard/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/compileruntime/url_lib_standard/src/main/resources/base/media/icon.png differ diff --git a/compileruntime/url_lib_standard/src/ohosTest/js/default/app.js b/compileruntime/url_lib_standard/src/ohosTest/js/default/app.js deleted file mode 100644 index 4952e62fd96d8dcf3eb348d293249c2a18176c85..0000000000000000000000000000000000000000 --- a/compileruntime/url_lib_standard/src/ohosTest/js/default/app.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export default { - onCreate() { - console.info('TestApplication onCreate'); - }, - onDestroy() { - console.info('TestApplication onDestroy'); - } -}; diff --git a/compileruntime/url_lib_standard/src/ohosTest/js/default/pages/index/index.css b/compileruntime/url_lib_standard/src/ohosTest/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/compileruntime/url_lib_standard/src/ohosTest/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/compileruntime/url_lib_standard/src/ohosTest/js/default/pages/index/index.js b/compileruntime/url_lib_standard/src/ohosTest/js/default/pages/index/index.js deleted file mode 100644 index 1edd1fbaa7c4b9f6bedd478d85933d97c0f55f00..0000000000000000000000000000000000000000 --- a/compileruntime/url_lib_standard/src/ohosTest/js/default/pages/index/index.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import file from '@system.file' -import app from '@system.app' -import device from '@system.device' -import router from '@system.router' -import {Core, Constant, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index' - -export default { - data: { - title: "" - }, - onInit() { - this.title = this.$t('strings.world'); - }, - onShow() { - console.info('onShow finish') - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - const reportExtend = new ReportExtend(file) - const instrumentLog = new InstrumentLog({ - 'id': 'report', - 'version': '1.0.3' - }) - core.addService('expect', expectExtend) - core.addService('report', reportExtend) - core.addService('report', instrumentLog) - core.init() - core.subscribeEvent('spec', instrumentLog) - core.subscribeEvent('suite', instrumentLog) - core.subscribeEvent('task', instrumentLog) - - const configService = core.getDefaultService('config') - configService.setConfig(this) - - require('../../../test/List.test') - core.execute() - }, - onReady() { - }, -} \ No newline at end of file diff --git a/compileruntime/url_lib_standard/src/ohosTest/resources/base/element/string.json b/compileruntime/url_lib_standard/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index 2dffe5ba6503c2c0d7ddcfff2d9d03759f459947..0000000000000000000000000000000000000000 --- a/compileruntime/url_lib_standard/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "URL" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - } - ] -} diff --git a/compileruntime/util_lib_standard/BUILD.gn b/compileruntime/util_lib_standard/BUILD.gn index 6b45dbc2453b600c41f2f5e33cbf8531a05ebb29..0838ec397fe5f4a6357ecf15d8fd87a84b3c2f06 100644 --- a/compileruntime/util_lib_standard/BUILD.gn +++ b/compileruntime/util_lib_standard/BUILD.gn @@ -12,15 +12,23 @@ # limitations under the License. import("//test/xts/tools/build/suite.gni") - ohos_js_hap_suite("util_js_test") { hap_profile = "./src/main/config.json" + js2abc = true deps = [ ":util_js_assets", ":util_resources", ] + + # shared_libraries = [ + # "//third_party/giflib:libgif", + # "//third_party/libpng:libpng", + # ] certificate_profile = "./signature/openharmony_sx.p7b" - hap_name = "ActsUtilJsTest" + hap_name = "UtilJsTest" + + # part_name = "prebuilt_hap" + # subsystem_name = "xts" } ohos_js_assets("util_js_assets") { source_dir = "./src/main/js/default" diff --git a/compileruntime/util_lib_standard/Test.json b/compileruntime/util_lib_standard/Test.json index d8e14d1dfaa699d1032ee378f16b41f3f1353972..111d1ab5e2d3e7b4d8a64ea0365d15fa9f193447 100644 --- a/compileruntime/util_lib_standard/Test.json +++ b/compileruntime/util_lib_standard/Test.json @@ -9,7 +9,7 @@ "kits": [ { "test-file-name": [ - "ActsUtilJsTest.hap" + "UtilJsTest.hap" ], "type": "AppInstallKit", "cleanup-apps": true diff --git a/compileruntime/util_lib_standard/src/main/config.json b/compileruntime/util_lib_standard/src/main/config.json index 75d1ac14458c1ede210bf40739cb9c9fc80e74b4..ea64f225527c8679e6fc21b969b83ba2b045115a 100644 --- a/compileruntime/util_lib_standard/src/main/config.json +++ b/compileruntime/util_lib_standard/src/main/config.json @@ -5,6 +5,10 @@ "version": { "code": 1000000, "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 } }, "deviceConfig": {}, diff --git a/compileruntime/util_lib_standard/src/main/java/com/example/childprocess/MainAbility.java b/compileruntime/util_lib_standard/src/main/java/com/example/childprocess/MainAbility.java deleted file mode 100644 index dbdddf742e23f2568178756f1cea558603671535..0000000000000000000000000000000000000000 --- a/compileruntime/util_lib_standard/src/main/java/com/example/childprocess/MainAbility.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.childprocess; - -import ohos.ace.ability.AceAbility; -import ohos.aafwk.content.Intent; - -public class MainAbility extends AceAbility { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - } - - @Override - public void onStop() { - super.onStop(); - } -} diff --git a/compileruntime/util_lib_standard/src/main/java/com/example/childprocess/MyApplication.java b/compileruntime/util_lib_standard/src/main/java/com/example/childprocess/MyApplication.java deleted file mode 100644 index bf24a9676c68a8c8fe00508525160c66d0378e80..0000000000000000000000000000000000000000 --- a/compileruntime/util_lib_standard/src/main/java/com/example/childprocess/MyApplication.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.childprocess; - -import ohos.aafwk.ability.AbilityPackage; - -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/compileruntime/util_lib_standard/src/main/java/com/example/url/MainAbility.java b/compileruntime/util_lib_standard/src/main/java/com/example/url/MainAbility.java deleted file mode 100644 index 1029c01195535d7671415ad1490aa483571d41e5..0000000000000000000000000000000000000000 --- a/compileruntime/util_lib_standard/src/main/java/com/example/url/MainAbility.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.example.url; - -import ohos.ace.ability.AceAbility; -import ohos.aafwk.content.Intent; - -public class MainAbility extends AceAbility { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - } - - @Override - public void onStop() { - super.onStop(); - } -} diff --git a/compileruntime/util_lib_standard/src/main/java/com/example/url/MyApplication.java b/compileruntime/util_lib_standard/src/main/java/com/example/url/MyApplication.java deleted file mode 100644 index d0bd8e832c63d6b1e691f5fc58c9284982cbde3b..0000000000000000000000000000000000000000 --- a/compileruntime/util_lib_standard/src/main/java/com/example/url/MyApplication.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.example.url; - -import ohos.aafwk.ability.AbilityPackage; - -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/compileruntime/util_lib_standard/src/main/js/default/pages/index/index.hml b/compileruntime/util_lib_standard/src/main/js/default/pages/index/index.hml index 9f0aae944b86533183d4307b741c7c237e6457a1..20a4e40d9a4ee698bf8e485840457dd43233a376 100644 --- a/compileruntime/util_lib_standard/src/main/js/default/pages/index/index.hml +++ b/compileruntime/util_lib_standard/src/main/js/default/pages/index/index.hml @@ -2,5 +2,4 @@ {{ $t('strings.hello') }} {{title}} -
\ No newline at end of file diff --git a/compileruntime/util_lib_standard/src/main/js/test/List.test.js b/compileruntime/util_lib_standard/src/main/js/test/List.test.js index e4726ba94e7d3fefb579529084da7329a3a4e292..628610ebda7f9b3421bf1704417fed5010c6a921 100644 --- a/compileruntime/util_lib_standard/src/main/js/test/List.test.js +++ b/compileruntime/util_lib_standard/src/main/js/test/List.test.js @@ -14,4 +14,4 @@ */ require('./ExampleJsunit.test.js') -require('./TextCodr.test.js') \ No newline at end of file +require('./util.test.js') \ No newline at end of file diff --git a/compileruntime/util_lib_standard/src/main/js/test/util.test.js b/compileruntime/util_lib_standard/src/main/js/test/util.test.js new file mode 100644 index 0000000000000000000000000000000000000000..087aefb4c786aa5a4cc88517cd83197c2b9f8887 --- /dev/null +++ b/compileruntime/util_lib_standard/src/main/js/test/util.test.js @@ -0,0 +1,7155 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite' +import util from '@ohos.util' +import url from '@ohos.url' +import app from '@system.app' +import process from '@ohos.process' +import file from '@system.file'; + +class Temperature { + constructor(value) { + this._temp = value; + } + compareTo(value) { + return this._temp >= value.getTemp(); + } + getTemp() { + return this._temp; + } + toString() { + return this._temp.toString(); + } +} +var tempLower = new Temperature(30); +var tempUpper = new Temperature(40); +var tempLess = new Temperature(20); +var tempMiDF = new Temperature(35); +var tempMidS = new Temperature(39); +var tempMore = new Temperature(45); + +var range = new util.Scope(tempLower, tempUpper); +var rangeFir = new util.Scope(tempMiDF, tempMidS); +var rangeSec = new util.Scope(tempLess, tempMore); +var rangeThi = new util.Scope(tempLess, tempMiDF); +var rangeFif = new util.Scope(tempMiDF, tempMore); + +describe('TextEncoderTest', function () { + + /** + * @tc.name: testUtilPrintf001 + * @tc.desc: Returns the formatted string. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilPrintf001', 0, function () { + var format = "%i,%s"; + var value1 = 1.5; + var value2 = "qwer"; + var value3 = 15; + var result = util.printf(format, value1, value2, value3); + expect(result).assertEqual("1,qwer 15"); + }) + + /** + * @tc.name: testUtilPrintf002 + * @tc.desc: Returns the formatted string. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilPrintf002', 0, function () { + var format = "%O"; + var value = { name: 'jack' ,age: 15 }; + var result = util.printf(format, value); + expect(result).assertEqual("{ name: 'jack',\n age: 15 }"); + }) + + /** + * @tc.name: testUtilPrintf003 + * @tc.desc: Returns the formatted string. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilPrintf003', 0, function () { + var format = "%o"; + var value = [1, 2, 3]; + var result = util.printf(format, value); + var res = '[ 1, 2, 3, [length]: 3 ]' + expect(result).assertEqual('[ 1, 2, 3, [length]: 3 ]'); + }) + + /** + * @tc.name: testUtilPrintf004 + * @tc.desc: Returns the formatted string. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilPrintf004', 0, function () { + var format = "%s,%s,%s"; + var value1 = "1.5"; + var value2 = "qwer"; + var result = util.printf(format, value1, value2); + expect(result).assertEqual('1.5,qwer,%s'); + }) + + /** + * @tc.name: testUtilPrintf005 + * @tc.desc: Returns the formatted string. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilPrintf005', 0, function () { + var format = "%d,%d"; + var value1 = 6; + var value2 = 16; + var result = util.printf(format, value1, value2); + expect(result).assertEqual('6,16'); + }) + + /** + * @tc.name: testUtilGetErrorString001 + * @tc.desc: Get the string name of the system errno. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilGetErrorString001', 0, async function () { + var errnum = 10; + var result = util.getErrorString(errnum); + expect(result).assertEqual('No child process'); + }) + + /** + * @tc.name: testUtilGetErrorString002 + * @tc.desc: Get the string name of the system errno. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilGetErrorString002', 0, async function () { + var errnum = 0; + var result = util.getErrorString(errnum); + expect(result).assertEqual('No error information'); + }) + + /** + * @tc.name: testUtilGetErrorString003 + * @tc.desc: Get the string name of the system errno. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilGetErrorString003', 0, async function () { + var errnum = -1; + var result = util.getErrorString(errnum); + expect(result).assertEqual('No error information'); + }) + + /** + * @tc.name: testUtilGetErrorString004 + * @tc.desc: Get the string name of the system errno. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilGetErrorString004', 0, async function () { + var errnum = 9; + var result = util.getErrorString(errnum); + expect(result).assertEqual('Bad file descriptor'); + }) + + /** + * @tc.name: testUtilGetErrorString005 + * @tc.desc: Get the string name of the system errno. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilGetErrorString005', 0, async function () { + var errnum = 555; + var result = util.getErrorString(errnum); + expect(result).assertEqual('No error information'); + }) + + /** + * @tc.name: testUtilPromiseWrapper001 + * @tc.desc: Takes a function following the common error-first callback style, + taking an callback as the last argument, and return a version that returns promises. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilPromiseWrapper001', 0, async function () { + function aysnFun(str1, str2, callback) { + if (typeof str1 === 'string' && typeof str1 === 'string') { + callback(null, str1 + str2); + } else { + callback('type err'); + } + } + let newPromiseObj = util.promiseWrapper(aysnFun)("Hello", 'World'); + newPromiseObj.then(res => { + expect(res).strictEqual('HelloWorld'); + }) + }) + + /** + * @tc.name: testUtilPromiseWrapper002 + * @tc.desc: Takes a function following the common error-first callback style, + taking an callback as the last argument, and return a version that returns promises. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilPromiseWrapper002', 0, async function () { + function aysnFun(str1, str2, callback) { + if (typeof str1 === 'string' && typeof str1 === 'string') { + callback(null, str1 + str2); + } else { + callback('type err'); + } + } + let newPromiseObj = util.promiseWrapper(aysnFun)([1, 2], 'World'); + newPromiseObj.catch(err => { + expect(err).strictEqual('type err'); + }) + }) + + /** + * @tc.name: testUtilPromiseWrapper003 + * @tc.desc: Takes a function following the common error-first callback style, + taking an callback as the last argument, and return a version that returns promises. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilPromiseWrapper003', 0, async function () { + const a = util.promiseWrapper(function() {}); + const b = util.promiseWrapper(a); + expect(a).strictEqual(b); + }) + + /** + * @tc.name: testUtilPromiseWrapper004 + * @tc.desc: Takes a function following the common error-first callback style, + taking an callback as the last argument, and return a version that returns promises. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilPromiseWrapper004', 0, async function () { + let errToThrow; + const thrower = util.promiseWrapper(function(a, b, c, cb) { + errToThrow = new Error(); + throw errToThrow; + }); + thrower(1, 2, 3).catch(err => { + expect(err).strictEqual(errToThrow); + }) + }) + + /** + * @tc.name: testUtilPromiseWrapper005 + * @tc.desc: Takes a function following the common error-first callback style, + taking an callback as the last argument, and return a version that returns promises. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilPromiseWrapper005', 0, async function () { + const err = new Error(); + const a = util.promiseWrapper((cb) => cb(err))(); + const b = util.promiseWrapper(() => {throw err;})(); + Promise.all([ + a.then(e => { + expect(e).strictEqual(err); + }), + b.then(e => { + expect(e).strictEqual(err); + }) + ]); + }) + + /** + * @tc.name: testUtilPromiseWrapper006 + * @tc.desc: Takes a function following the common error-first callback style, + taking an callback as the last argument, and return a version that returns promises. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilPromiseWrapper006', 0, async function () { + const err = new Error('callback with the error.'); + const stack = err.stack; + const fn = util.promiseWrapper(function(cb) { + cb(null); + cb(err); + }); + (async () => { + await fn(); + await Promise.resolve(); + return expect(stack).strictEqual(err.stack); + })(); + }) + + /** + * @tc.name: testUtilPromiseWrapper007 + * @tc.desc: Takes a function following the common error-first callback style, + taking an callback as the last argument, and return a version that returns promises. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilPromiseWrapper007', 0, async function () { + function fn(err, val, callback) { + callback(err, val); + } + (async () => { + const value = await util.promiseWrapper(fn)(null, 42); + expect(value).strictEqual(42); + })(); + }) + + /** + * @tc.name: testUtilCallbackWrapper001 + * @tc.desc: Takes an async function (or a function that returns a Promise) and + returns a function following the error-first callback style. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilCallbackWrapper001', 0, async function () { + const promiseFn = [1, 2]; + try { + util.callbackWrapper(promiseFn); + } catch(e) { + expect(e.message).strictEqual('original is not function'); + } + }) + + /** + * @tc.name: testUtilCallbackWrapper002 + * @tc.desc: Takes an async function (or a function that returns a Promise) and + returns a function following the error-first callback style. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilCallbackWrapper002', 0, async function () { + async function promiseFn() { + return Promise.resolve('value'); + } + var cb = util.callbackWrapper(promiseFn); + cb((err, ret) => { + expect(err).strictEqual(null); + expect(ret).strictEqual('value'); + }) + }) + + /** + * @tc.name: testUtilCallbackWrapper003 + * @tc.desc: Takes an async function (or a function that returns a Promise) and + returns a function following the error-first callback style. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilCallbackWrapper003', 0, async function () { + async function promiseFn() { + return 42; + } + var cb = util.callbackWrapper(promiseFn); + cb((err, ret) => { + expect(err).strictEqual(null); + expect(ret).strictEqual(42); + }) + }) + + /** + * @tc.name: testUtilCallbackWrapper004 + * @tc.desc: Takes an async function (or a function that returns a Promise) and + returns a function following the error-first callback style. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilCallbackWrapper004', 0, async function () { + async function promiseFn() { + var err = Error('value'); + return Promise.reject(err); + + } + var cb = util.callbackWrapper(promiseFn); + cb((err, ret) => { + expect(err.message).strictEqual('value'); + expect(ret).strictEqual(undefined); + }) + }) + + /** + * @tc.name: testUtilCallbackWrapper005 + * @tc.desc: Takes an async function (or a function that returns a Promise) and + returns a function following the error-first callback style. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilCallbackWrapper005', 0, async function () { + async function promiseFn(a, b) { + return a + b; + } + var cb = util.callbackWrapper(promiseFn); + cb(1, 2, (err, ret) => { + expect(err).strictEqual(null); + expect(ret).strictEqual(3); + }) + }) + + /** + * @tc.name: testUtilCallbackWrapper006 + * @tc.desc: Takes an async function (or a function that returns a Promise) and + returns a function following the error-first callback style. + * @tc.require: AR000GFB4U + * @tc.author: shikai + */ + it('testUtilCallbackWrapper006', 0, async function () { + async function promiseFn(){ + return null; + } + var cb = util.callbackWrapper(promiseFn); + try { + cb([1, 2]) + } catch(err) { + expect(err.message).strictEqual('maybe is not function'); + } + }) + + /** + * @tc.name: testEncoding001 + * @tc.desc: The source encoding's name, lowercased. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncoding001', 0, function () { + var that = new util.TextDecoder('utf-8', { ignoreBOM : true }) + var retStr = that.encoding + expect(retStr).assertEqual('utf-8') + }) + + /** + * @tc.name: testEncoding002 + * @tc.desc: The source encoding's name, lowercased. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncoding002', 0, function () { + var that = new util.TextDecoder('utf-16le') + var encodingStr = that.encoding + expect(encodingStr).assertEqual('utf-16le') + }) + + /** + * @tc.name: testEncoding003 + * @tc.desc: The source encoding's name, lowercased. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncoding003', 0, function () { + var that = new util.TextDecoder('utf-16be') + var encodingStr = that.encoding + expect(encodingStr).assertEqual('utf-16be') + }) + + /** + * @tc.name: testEncoding004 + * @tc.desc: The source encoding's name, lowercased. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncoding004', 0, function () { + var that = new util.TextDecoder('utf-16be', { ignoreBOM : true }) + var encodingStr = that.encoding + expect(encodingStr).assertEqual('utf-16be') + }) + + /** + * @tc.name: testEncoding005 + * @tc.desc: The source encoding's name, lowercased. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncoding005', 0, function () { + var that = new util.TextDecoder('utf-16be', { ignoreBOM : false }) + var encodingStr = that.encoding + expect(encodingStr).assertEqual('utf-16be') + }) + + + /** + * @tc.name: testFatal001 + * @tc.desc: Returns `true` if error mode is "fatal", and `false` otherwise. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testFatal001', 0, function () { + var that = new util.TextDecoder('utf-16be', { fatal : true }) + var fatalStr = that.fatal + expect(fatalStr).assertEqual(true) + }) + + /** + * @tc.name: testFatal002 + * @tc.desc: Returns `true` if error mode is "fatal", and `false` otherwise. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testFatal002', 0, function () { + var that = new util.TextDecoder('utf-16be', { fatal : false }) + var fatalStr = that.fatal + expect(fatalStr).assertEqual(false) + }) + + /** + * @tc.name: testFatal003 + * @tc.desc: Returns `true` if error mode is "fatal", and `false` otherwise. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testFatal003', 0, function () { + var that = new util.TextDecoder('utf-16be') + var fatalStr = that.fatal + expect(fatalStr).assertEqual(false) + }) + + /** + * @tc.name: testFatal004 + * @tc.desc: Returns `true` if error mode is "fatal", and `false` otherwise. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testFatal004', 0, function () { + var that = new util.TextDecoder('utf-8') + var fatalStr = that.fatal + expect(fatalStr).assertEqual(false) + }) + + /** + * @tc.name: testFatal005 + * @tc.desc: Returns `true` if error mode is "fatal", and `false` otherwise. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testFatal005', 0, function () { + var that = new util.TextDecoder('utf-16le') + var fatalStr = that.fatal + expect(fatalStr).assertEqual(false) + }) + + /** + * @tc.name: testIgnoreBOM001 + * @tc.desc: Returns `true` if ignore BOM flag is set, and `false` otherwise. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testIgnoreBOM001', 0, function () { + var that = new util.TextDecoder('utf-16be', { ignoreBOM : true }) + var ignoreBOMStr = that.ignoreBOM + expect(ignoreBOMStr).assertEqual(true) + }) + + /** + * @tc.name: testIgnoreBOM002 + * @tc.desc: Returns `true` if ignore BOM flag is set, and `false` otherwise. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testIgnoreBOM002', 0, function () { + var that = new util.TextDecoder('utf-16be', { ignoreBOM : false }) + var ignoreBOMStr = that.ignoreBOM + expect(ignoreBOMStr).assertEqual(false) + }) + + /** + * @tc.name: testIgnoreBOM003 + * @tc.desc: Returns `true` if ignore BOM flag is set, and `false` otherwise. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testIgnoreBOM003', 0, function () { + var that = new util.TextDecoder('utf-16be') + var ignoreBOMStr = that.ignoreBOM + expect(ignoreBOMStr).assertEqual(false) + }) + + /** + * @tc.name: testIgnoreBOM004 + * @tc.desc: Returns `true` if ignore BOM flag is set, and `false` otherwise. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testIgnoreBOM004', 0, function () { + var that = new util.TextDecoder('utf-8') + var ignoreBOMStr = that.ignoreBOM + expect(ignoreBOMStr).assertEqual(false) + }) + + /** + * @tc.name: testIgnoreBOM005 + * @tc.desc: Returns `true` if ignore BOM flag is set, and `false` otherwise. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testIgnoreBOM005', 0, function () { + var that = new util.TextDecoder('utf-16le') + var ignoreBOMStr = that.ignoreBOM + expect(ignoreBOMStr).assertEqual(false) + }) + + + /** + * @tc.name: testDecode001 + * @tc.desc: Returns the result of running encoding's decoder. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testDecode001', 0, function () { + var that = new util.TextDecoder('utf-8'); + var arr = new Uint8Array(3); + for (var i = 0; i < 3; i++) { + arr[i] = 0x61 + i; + } + var retStr = that.decode(arr); + var rel = 'abc'; + expect(retStr).assertEqual(rel); + }) + + /** + * @tc.name: testDecode002 + * @tc.desc: Returns the result of running encoding's decoder. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testDecode002', 0, function () { + var that = new util.TextDecoder('utf-16le') + var arr = new Uint8Array(6) + arr[0] = 0x61; + arr[1] = 0x00; + arr[2] = 0x62; + arr[3] = 0x00; + arr[4] = 0x63; + arr[5] = 0x00; + var retStr = that.decode(arr) + var rel = 'abc' + expect(retStr).assertEqual(rel) + }) + + /** + * @tc.name: testDecode003 + * @tc.desc: Returns the result of running encoding's decoder. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testDecode003', 0, function () { + var that = new util.TextDecoder('utf-16be'); + var arr = new Uint8Array(6); + arr[0] = 0x00; + arr[1] = 0x61; + arr[2] = 0x00; + arr[3] = 0x62; + arr[4] = 0x00; + arr[5] = 0x63; + var retStr = that.decode(arr); + var rel = 'abc' + expect(retStr).assertEqual(rel); + }) + + /** + * @tc.name: testDecode004 + * @tc.desc: Returns the result of running encoding's decoder. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testDecode004', 0, function () { + var that = new util.TextDecoder('utf-8', { ignoreBOM : true }) + var arr = new Uint8Array(6) + arr[0] = 0xEF; + arr[1] = 0xBB; + arr[2] = 0xBF; + arr[3] = 0x61; + arr[4] = 0x62; + arr[5] = 0x63; + var retStr = that.decode(arr, {stream:true}) + var BOM = '\uFEFF' + var rel = 'abc' + var re = BOM + rel + expect(retStr).assertEqual(re); + }) + + /** + * @tc.name: testDecode005 + * @tc.desc: Returns the result of running encoding's decoder. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testDecode005', 0, function () { + var that = new util.TextDecoder('utf-16le', { ignoreBOM : false }) + var arr = new Uint8Array(8) + arr[0] = 0xFF; + arr[1] = 0xFE; + arr[2] = 0x61; + arr[3] = 0x00; + arr[4] = 0x62; + arr[5] = 0x00 + arr[6] = 0x63; + arr[7] = 0x00; + var retStr = that.decode(arr, { stream : false }) + var BOM = '\uFEFF' + var rel = 'abc' + var re = BOM + rel + expect(retStr).assertEqual(re) + }) + + /** + * @tc.name: testGetEncoding001 + * @tc.desc: Encoding format. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testGetEncoding001', 0, function () { + var that = new util.TextEncoder() + var str = that.encoding + expect(str).assertEqual('utf-8') + }) + + /** + * @tc.name: testEncode001 + * @tc.desc: Returns the result of encoder. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncode001', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(20) + var result = new Uint8Array(buffer) + result = that.encode('abc') + expect(result[0]).assertEqual(0x61) + }) + + /** + * @tc.name: testEncode002 + * @tc.desc: Returns the result of encoder. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncode002', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(20) + var result = new Uint8Array(buffer) + result = that.encode('\uD800楼楼') + expect(result[5]).assertEqual(188) + }) + + /** + * @tc.name: testEncode003 + * @tc.desc: Returns the result of encoder. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncode003', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(20) + var result = new Uint8Array(buffer) + result = that.encode('a\uD800楼楼') + expect(result[0]).assertEqual(0x61) + }) + + /** + * @tc.name: testEncode004 + * @tc.desc: Returns the result of encoder. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncode004', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(20) + var result = new Uint8Array(buffer) + result = that.encode('abc\uD800楼楼') + expect(result[1]).assertEqual(0x62) + }) + + /** + * @tc.name: testEncode005 + * @tc.desc: Returns the result of encoder. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncode005', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(20) + var result = new Uint8Array(buffer) + result = that.encode('123\uD800楼楼') + expect(result[0]).assertEqual(49) + expect(result[9]).assertEqual(230) + }) + + /** + * @tc.name: testEncode006 + * @tc.desc: Returns the result of encoder. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncode006', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(20) + var result = new Uint8Array(buffer) + result = that.encode('123¥\uD800楼') + expect(result[10]).assertEqual(0xbc) + }) + + /** + * @tc.name: testEncode007 + * @tc.desc: Returns the result of encoder. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncode007', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(20) + var result = new Uint8Array(buffer) + result = that.encode('¥¥') + expect(result[0]).assertEqual(0xc2) + }) + + /** + * @tc.name: testEncode008 + * @tc.desc: Returns the result of encoder. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncode008', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(20) + var result = new Uint8Array(buffer) + result = that.encode('$$') + expect(result[0]).assertEqual(0x24) + }) + + /** + * @tc.name: testEncodeInto001 + * @tc.desc: encode string, write the result to dest array. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncodeInto001', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(20) + var dest = new Uint8Array(buffer, 0, 13) + var result = new Uint32Array(20) + result = that.encodeInto('\uD800A\uDF06A楼HiA', dest) + expect(result.read).assertEqual(7) + expect(result.written).assertEqual(13) + }) + + /** + * @tc.name: testEncodeInto002 + * @tc.desc: encode string, write the result to dest array. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncodeInto002', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(6) + var dest = new Uint8Array(buffer) + var result = new Object() + result = that.encodeInto('abc\u2603d', dest) + expect(result.read).assertEqual(4) + expect(result.written).assertEqual(6) + }) + + /** + * @tc.name: testEncodeInto003 + * @tc.desc: encode string, write the result to dest array. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncodeInto003', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(4) + var dest = new Uint8Array(buffer) + var result = new Object() + result = that.encodeInto('abcd', dest) + expect(result.read).assertEqual(4) + expect(result.written).assertEqual(4) + }) + + /** + * @tc.name: testEncodeInto004 + * @tc.desc: encode string, write the result to dest array. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncodeInto004', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(4) + var dest = new Uint8Array(buffer) + var result = new Object() + result = that.encodeInto('12345', dest) + expect(result.read).assertEqual(4) + expect(result.written).assertEqual(4) + }) + + /** + * @tc.name: testEncodeInto005 + * @tc.desc: encode string, write the result to dest array. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncodeInto005', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(4) + var dest = new Uint8Array(buffer) + var result = new Object() + result = that.encodeInto('123 4*!@#', dest) + expect(result.read).assertEqual(4) + expect(result.written).assertEqual(4) + }) + + /** + * @tc.name: testEncodeInto006 + * @tc.desc: encode string, write the result to dest array. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncodeInto006', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(4) + var dest = new Uint8Array(buffer) + var result = new Object() + result = that.encodeInto('', dest) + expect(result.read).assertEqual(0) + expect(result.written).assertEqual(0) + }) + + /** + * @tc.name: testEncodeInto007 + * @tc.desc: encode string, write the result to dest array. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncodeInto007', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(20) + var dest = new Uint8Array(buffer) + var result = new Uint32Array(20) + result = that.encodeInto('12ab', dest) + expect(result.read).assertEqual(4) + expect(result.written).assertEqual(4) + }) + + /** + * @tc.name: testEncodeInto008 + * @tc.desc: encode string, write the result to dest array. + * @tc.require: AR000GFB4U + * @tc.author: wangben + */ + it('testEncodeInto008', 0, function () { + var that = new util.TextEncoder() + var buffer = new ArrayBuffer(20) + var dest = new Uint8Array(buffer, 0, 0) + var result = new Uint32Array(20) + result = that.encodeInto('\uD800A\uDF06A楼HiA', dest) + expect(result.read).assertEqual(0) + expect(result.written).assertEqual(0) + }) +}) + +describe('ScopeTest', function () { + + /** + * @tc.name: testGetLower001 + * @tc.desc: Obtains the lower bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testGetLower001', 0, function () { + var result = range.getLower() + expect(result).assertEqual(30) + }) + + /** + * @tc.name: testGetLower002 + * @tc.desc: Obtains the lower bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testGetLower002', 0, function () { + var result = rangeFir.getLower() + expect(result).assertEqual(35) + }) + + /** + * @tc.name: testGetLower003 + * @tc.desc: Obtains the lower bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testGetLower003', 0, function () { + var result = rangeSec.getLower() + expect(result).assertEqual(20) + }) + + /** + * @tc.name: testGetLower004 + * @tc.desc: Obtains the lower bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testGetLower004', 0, function () { + var result = rangeThi.getLower() + expect(result).assertEqual(20) + }) + + /** + * @tc.name: testGetLower005 + * @tc.desc: Obtains the lower bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testGetLower005', 0, function () { + var result = rangeFif.getLower() + expect(result).assertEqual(35) + }) + + /** + * @tc.name: testGetUpper001 + * @tc.desc: Obtains the upper bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testGetUpper001', 0, function () { + var result = range.getUpper() + expect(result).assertEqual(40) + }) + + /** + * @tc.name: testGetUpper002 + * @tc.desc: Obtains the upper bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testGetUpper002', 0, function () { + var result = rangeFir.getUpper() + expect(result).assertEqual(39) + }) + + /** + * @tc.name: testGetUpper003 + * @tc.desc: Obtains the upper bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testGetUpper003', 0, function () { + var result = rangeSec.getUpper() + expect(result).assertEqual(45) + }) + + /** + * @tc.name: testGetUpper004 + * @tc.desc: Obtains the upper bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testGetUpper004', 0, function () { + var result = rangeThi.getUpper() + expect(result).assertEqual(35) + }) + + /** + * @tc.name: testGetUpper005 + * @tc.desc: Obtains the upper bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testGetUpper005', 0, function () { + var result = rangeFif.getUpper() + expect(result).assertEqual(45) + }) + + /** + * @tc.name: testClamp001 + * @tc.desc: Clamps a given value to the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testClamp001', 0, function () { + var result =range.clamp(tempLess) + expect(result).assertEqual(30) + }) + + /** + * @tc.name: testClamp002 + * @tc.desc: Clamps a given value to the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testClamp002', 0, function () { + var result =range.clamp(tempMiDF) + expect(result).assertEqual(35) + }) + + /** + * @tc.name: testClamp003 + * @tc.desc: Clamps a given value to the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testClamp003', 0, function () { + var result =range.clamp(tempMore) + expect(result).assertEqual(40) + }) + + /** + * @tc.name: testClamp004 + * @tc.desc: Clamps a given value to the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testClamp004', 0, function () { + var result =range.clamp(tempLower) + expect(result).assertEqual(30) + }) + + /** + * @tc.name: testClamp005 + * @tc.desc: Clamps a given value to the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testClamp005', 0, function () { + var result =range.clamp(tempUpper) + expect(result).assertEqual(40) + }) + + /** + * @tc.name: testContains001 + * @tc.desc: Checks whether a given value is within the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testContains001', 0, function () { + var result = range.contains(tempLess) + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testContains002 + * @tc.desc: Checks whether a given value is within the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testContains002', 0, function () { + var result = range.contains(tempMiDF) + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testContains003 + * @tc.desc: Checks whether a given value is within the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testContains003', 0, function () { + var result = range.contains(tempMore) + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testContains004 + * @tc.desc: Checks whether a given value is within the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testContains004', 0, function () { + var result = range.contains(tempLower) + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testContains005 + * @tc.desc: Checks whether a given value is within the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testContains005', 0, function () { + var result = range.contains(tempUpper) + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testContains001 + * @tc.desc: Checks whether a given range is within the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testContains001', 0, function () { + var result = range.contains(rangeFir) + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testContains002 + * @tc.desc: Checks whether a given range is within the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testContains002', 0, function () { + var result = range.contains(rangeSec) + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testContains003 + * @tc.desc: Checks whether a given range is within the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testContains003', 0, function () { + var result = range.contains(rangeThi) + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testContains004 + * @tc.desc: Checks whether a given range is within the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testContains004', 0, function () { + var result = range.contains(rangeFif) + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testContains005 + * @tc.desc: Checks whether a given range is within the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testContains005', 0, function () { + var result = range.contains(range) + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testExpand001 + * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand001', 0, function () { + var result = range.expand(tempMiDF, tempMidS) + expect(result).assertEqual('[30, 40]') + }) + + /** + * @tc.name: testExpand002 + * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand002', 0, function () { + var result = range.expand(tempLess, tempMore) + expect(result).assertEqual('[20, 45]') + }) + + /** + * @tc.name: testExpand003 + * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand003', 0, function () { + var result = range.expand(tempLess, tempMiDF) + expect(result).assertEqual('[20, 40]') + }) + + /** + * @tc.name: testExpand004 + * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand004', 0, function () { + var result = range.expand(tempMiDF, tempMore) + expect(result).assertEqual('[30, 45]') + }) + + /** + * @tc.name: testExpand005 + * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand005', 0, function () { + var result = range.expand(tempLower, tempUpper) + expect(result).assertEqual('[30, 40]') + }) + + /** + * @tc.name: testExpand001 + * @tc.desc: Creates the smallest range that includes the current range and a given range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand001', 0, function () { + var result = range.expand(rangeFir) + expect(result).assertEqual('[30, 40]') + }) + + /** + * @tc.name: testExpand002 + * @tc.desc: Creates the smallest range that includes the current range and a given range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand002', 0, function () { + var result = range.expand(rangeSec) + expect(result).assertEqual('[20, 45]') + }) + + /** + * @tc.name: testExpand003 + * @tc.desc: Creates the smallest range that includes the current range and a given range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand003', 0, function () { + var result = range.expand(rangeThi) + expect(result).assertEqual('[20, 40]') + }) + + /** + * @tc.name: testExpand004 + * @tc.desc: Creates the smallest range that includes the current range and a given range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand004', 0, function () { + var result = range.expand(rangeFif) + expect(result).assertEqual('[30, 45]') + }) + + /** + * @tc.name: testExpand005 + * @tc.desc: Creates the smallest range that includes the current range and a given range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand005', 0, function () { + var result = range.expand(range) + expect(result).assertEqual('[30, 40]') + }) + + /** + * @tc.name: testExpand001 + * @tc.desc: Creates the smallest range that includes the current range and a given value. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand001', 0, function () { + var result = range.expand(tempMiDF) + expect(result).assertEqual('[30, 40]') + }) + + /** + * @tc.name: testExpand002 + * @tc.desc: Creates the smallest range that includes the current range and a given value. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand002', 0, function () { + var result = range.expand(tempLess) + expect(result).assertEqual('[20, 40]') + }) + + /** + * @tc.name: testExpand003 + * @tc.desc: Creates the smallest range that includes the current range and a given value. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand003', 0, function () { + var result = range.expand(tempMore) + expect(result).assertEqual('[30, 45]') + }) + + /** + * @tc.name: testExpand004 + * @tc.desc: Creates the smallest range that includes the current range and a given value. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand004', 0, function () { + var result = range.expand(tempLower) + expect(result).assertEqual('[30, 40]') + }) + + /** + * @tc.name: testExpand005 + * @tc.desc: Creates the smallest range that includes the current range and a given value. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testExpand005', 0, function () { + var result = range.expand(tempUpper) + expect(result).assertEqual('[30, 40]') + }) + + /** + * @tc.name: testInstersect001 + * @tc.desc: Returns the intersection of a given range and the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testInstersect001', 0, function () { + var result = range.intersect(rangeFir) + expect(result).assertEqual('[35, 39]') + }) + + /** + * @tc.name: testInstersect002 + * @tc.desc: Returns the intersection of a given range and the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testInstersect002', 0, function () { + var result = range.intersect(rangeSec) + expect(result).assertEqual('[30, 40]') + }) + + /** + * @tc.name: testInstersect003 + * @tc.desc: Returns the intersection of a given range and the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testInstersect003', 0, function () { + var result = range.intersect(rangeThi) + expect(result).assertEqual('[30, 35]') + }) + + /** + * @tc.name: testInstersect004 + * @tc.desc: Returns the intersection of a given range and the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testInstersect004', 0, function () { + var result = range.intersect(rangeFif) + expect(result).assertEqual('[35, 40]') + }) + + /** + * @tc.name: testInstersect005 + * @tc.desc: Returns the intersection of a given range and the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testInstersect005', 0, function () { + var result = range.intersect(range) + expect(result).assertEqual('[30, 40]') + }) + + /** + * @tc.name: testInstersect001 + * @tc.desc: Returns the intersection of the current range and the range specified by + the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testInstersect001', 0, function () { + var result = range.intersect(tempMiDF, tempMidS) + expect(result).assertEqual('[35, 39]') + }) + + /** + * @tc.name: testInstersect002 + * @tc.desc: Returns the intersection of the current range and the range specified by + the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testInstersect002', 0, function () { + var result = range.intersect(tempLess, tempMore) + expect(result).assertEqual('[30, 40]') + }) + + /** + * @tc.name: testInstersect003 + * @tc.desc: Returns the intersection of the current range and the range specified by + the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testInstersect003', 0, function () { + var result = range.intersect(tempLess, tempMiDF) + expect(result).assertEqual('[30, 35]') + }) + + /** + * @tc.name: testInstersect004 + * @tc.desc: Returns the intersection of the current range and the range specified by + the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testInstersect004', 0, function () { + var result = range.intersect(tempMiDF, tempMore) + expect(result).assertEqual('[35, 40]') + }) + + /** + * @tc.name: testInstersect005 + * @tc.desc: Returns the intersection of the current range and the range specified by + the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testInstersect005', 0, function () { + var result = range.intersect(tempLower, tempUpper) + expect(result).assertEqual('[30, 40]') + }) + + /** + * @tc.name: testToString001 + * @tc.desc: Obtains a string representation of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testToString001', 0, function () { + var result = range.toString() + expect(result).assertEqual('[30, 40]') + }) + + /** + * @tc.name: testToString002 + * @tc.desc: Obtains a string representation of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testToString002', 0, function () { + var result = rangeFir.toString() + expect(result).assertEqual('[35, 39]') + }) + + /** + * @tc.name: testToString003 + * @tc.desc: Obtains a string representation of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testToString003', 0, function () { + var result = rangeSec.toString() + expect(result).assertEqual('[20, 45]') + }) + + /** + * @tc.name: testToString004 + * @tc.desc: Obtains a string representation of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testToString004', 0, function () { + var result = rangeThi.toString() + expect(result).assertEqual('[20, 35]') + }) + + /** + * @tc.name: testToString005 + * @tc.desc: Obtains a string representation of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ + it('testToString005', 0, function () { + var result = rangeFif.toString() + expect(result).assertEqual('[35, 45]') + }) +}) + +describe('Base64Test', function () { + + /** + * @tc.name: testEncodeSync001 + * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeSync001', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([115,49,51]); + var rarray = new Uint8Array([99,122,69,122]); + var result = that.encodeSync(array); + for (var i = 0; i < 4; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + /** + * @tc.name: testEncodeSync002 + * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeSync002', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); + var rarray = new Uint8Array([81,109,70,122,90,84,89,48,73,69,53,118,90,71,85,117,97,110,77,61]); + var result = that.encodeSync(array); + for (var i = 0; i < 20; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + /** + * @tc.name: testEncodeSync003 + * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeSync003', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105, + 110,32,78,111,100,101,46,106,115]); + var rarray = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110, + 73,71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]); + var result = that.encodeSync(array); + for (var i = 0; i < 36; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + /** + * @tc.name: testEncodeSync004 + * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeSync004', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([168, 174, 155, 255]); + var rarray = new Uint8Array([113,75,54,98,47,119,61,61]); + var result = that.encodeSync(array); + for (var i = 0; i < 8; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + /** + * @tc.name: testEncodeSync005 + * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeSync005', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([66, 97, 115, 101, 54, 52]); + var rarray = new Uint8Array([81, 109, 70, 122, 90, 84, 89, 48]); + var result = that.encodeSync(array); + for (var i = 0; i <8; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + /** + * @tc.name: testEncodeToStringSync001 + * @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeToStringSync001', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([115,49,51]); + var result = that.encodeToStringSync(array) + expect(result).assertEqual('czEz') + }) + + /** + * @tc.name: testEncodeToStringSync002 + * @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeToStringSync002', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); + var result = that.encodeToStringSync(array); + expect(result).assertEqual('QmFzZTY0IE5vZGUuanM=') + }) + + /** + * @tc.name: testEncodeToStringSync003 + * @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeToStringSync003', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110, + 32,78,111,100,101,46,106,115]); + var result = that.encodeToStringSync(array); + expect(result).assertEqual('QmFzZTY0IEVuY29kaW5nIGluIE5vZGUuanM=') + }) + + /** + * @tc.name: testEncodeToStringSync004 + * @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeToStringSync004', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([168, 174, 155, 255]); + var result = that.encodeToStringSync(array); + expect(result).assertEqual('qK6b/w==') + }) + + /** + * @tc.name: testEncodeToStringSync005 + * @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeToStringSync005', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([66, 97, 115, 101, 54, 52]); + var result = that.encodeToStringSync(array); + expect(result).assertEqual('QmFzZTY0') + }) + + /** + * @tc.name: testDecodeSync001 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecodeSync001', 0, function () { + var that = new util.Base64() + var buff = 'czEz'; + var rarray = new Uint8Array([115,49,51]); + var result = that.decodeSync(buff); + for (var i = 0; i < 3; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + /** + * @tc.name: testDecodeSync002 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecodeSync002', 0, function () { + var that = new util.Base64() + var buff = 'QmFzZTY0IE5vZGUuanM='; + var rarray = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); + var result = that.decodeSync(buff); + for (var i = 0; i < 14; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + /** + * @tc.name: testDecodeSync003 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecodeSync003', 0, function () { + var that = new util.Base64() + var buff = 'QmFzZTY0IEVuY29kaW5nIGluIE5vZGUuanM='; + var rarray = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32, + 105,110,32,78,111,100,101,46,106,115]); + var result = that.decodeSync(buff); + for (var i = 0; i < 26; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + /** + * @tc.name: testDecodeSync004 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecodeSync004', 0, function () { + var that = new util.Base64() + var buff = 'qK6b/w=='; + var rarray = new Uint8Array([168, 174, 155, 255]); + var result = that.decodeSync(buff); + for (var i = 0; i < 4; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + /** + * @tc.name: testDecodeSync005 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecodeSync005', 0, function () { + var that = new util.Base64() + var buff = 'QmFzZTY0'; + var rarray = new Uint8Array([66, 97, 115, 101, 54, 52]); + var result = that.decodeSync(buff); + for (var i = 0; i <6; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + /** + * @tc.name: testDecodeSync001 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecodeSync001', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([99,122,69,122]); + var rarray = new Uint8Array([115,49,51]); + var result = that.decodeSync(array); + for (var i = 0; i < 3; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + /** + * @tc.name: testDecodeSync002 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecodeSync002', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,53,118,90,71,85,117,97,110,77,61]); + var rarray = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); + var result = that.decodeSync(array); + for (var i = 0; i < 14; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + /** + * @tc.name: testDecodeSync003 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecodeSync003', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87, + 53,110,73,71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]); + var rarray = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105, + 110,32,78,111,100,101,46,106,115]); + var result = that.decodeSync(array); + for (var i = 0; i < 26; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + /** + * @tc.name: testDecodeSync004 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecodeSync004', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([113,75,54,98,47,119,61,61]); + var rarray = new Uint8Array([168, 174, 155, 255]); + var result = that.decodeSync(array); + for (var i = 0; i < 4; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + /** + * @tc.name: testDecodeSync005 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecodeSync005', 0, function () { + var that = new util.Base64() + var array = new Uint8Array([81, 109, 70, 122, 90, 84, 89, 48]); + var rarray = new Uint8Array([66, 97, 115, 101, 54, 52]); + var result = that.decodeSync(array); + for (var i = 0; i <6; i++) { + expect(result[i]).assertEqual(rarray[i]); + } + }) + + //base64 EncodeAsync test + /** + * @tc.name: testEncode001 + * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly + allocated u8 array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncode001', 0, async function () { + var that = await new util.Base64(); + var array = new Uint8Array([115,49,51]); + var rarray = new Uint8Array([99,122,69,122]); + that.encode(array).then(val=>{ + for (var i = 0; i < rarray.length; i++) { + expect(val[i]).assertEqual(rarray[i]) + } + }) + }) + + /** + * @tc.name: testEncode002 + * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly + allocated u8 array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncode002', 0, async function () { + var that = new util.Base64() + var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); + var rarray = new Uint8Array([81,109,70,122,90,84,89,48,73,69,53,118,90,71,85,117,97,110,77,61]); + that.encode(array).then(val=>{ + for (var i = 0; i < rarray.length; i++) { + expect(val[i]).assertEqual(rarray[i]) + } + }) + }) + + /** + * @tc.name: testEncode003 + * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncode003', 0, async function () { + var that = new util.Base64() + var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32, + 78,111,100,101,46,106,115]); + var rarray = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73, + 71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]); + that.encode(array).then(val=>{ + for (var i = 0; i < rarray.length; i++) { + expect(val[i]).assertEqual(rarray[i]) + } + }) + }) + + /** + * @tc.name: testEncode004 + * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncode004', 0, async function () { + var that = new util.Base64() + var array = new Uint8Array([168, 174, 155, 255]); + var rarray = new Uint8Array([113,75,54,98,47,119,61,61]); + that.encode(array).then(val=>{ + for (var i = 0; i < rarray.length; i++) { + expect(val[i]).assertEqual(rarray[i]) + } + }) + }) + + /** + * @tc.name: testEncode005 + * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 + array using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncode005', 0, async function () { + var that = new util.Base64() + var array = new Uint8Array([66, 97, 115, 101, 54, 52]); + var rarray = new Uint8Array([81, 109, 70, 122, 90, 84, 89, 48]); + that.encode(array).then(val=>{ + for (var i = 0; i < rarray.length; i++) { + expect(val[i]).assertEqual(rarray[i]) + } + }) + }) + + /** + * @tc.name: testEncodeToString001 + * @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeToString001', 0, async function () { + var that = new util.Base64() + var array = new Uint8Array([115,49,51]); + that.encodeToString(array).then(val=>{ + expect(val).assertEqual('czEz') + }) + }) + + /** + * @tc.name: testEncodeToString002 + * @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeToString002', 0, async function () { + var that = new util.Base64() + var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); + that.encodeToString(array).then(val=>{ + expect(val).assertEqual('QmFzZTY0IE5vZGUuanM=') + }) + }) + + /** + * @tc.name: testEncodeToString003 + * @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeToString003', 0, async function () { + var that = new util.Base64() + var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73,71,108, + 117,73,69,53,118,90,71,85,117,97,110,77,61]); + that.encodeToString(array).then(val=>{ + expect(val).assertEqual('QmFzZTY0IEVuY29kaW5nIGluIE5vZGUuanM=') + }) + }) + + /** + * @tc.name: testEncodeToString004 + * @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeToString004', 0, async function () { + var that = new util.Base64() + var array = new Uint8Array([168, 174, 155, 255]); + that.encodeToString(array).then(val=>{ + expect(val).assertEqual('qK6b/w==') + }) + }) + + /** + * @tc.name: testEncodeToString005 + * @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testEncodeToString005', 0, async function () { + var that = new util.Base64() + var array = new Uint8Array([66, 97, 115, 101, 54, 52]); + that.encodeToString(array).then(val=>{ + expect(val).assertEqual('QmFzZTY0') + }) + }) + + /** + * @tc.name: testDecode001 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecode001', 0, async function () { + var that = new util.Base64() + var buff = 'czEz'; + var array = new Uint8Array([115,49,51]); + that.decode(buff).then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testDecode002 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecode002', 0, async function () { + var that = new util.Base64() + var buff = 'QmFzZTY0IE5vZGUuanM='; + var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); + that.decode(buff).then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testDecode003 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecode003', 0, async function () { + var that = new util.Base64() + var buff = 'QmFzZTY0IEVuY29kaW5nIGluIE5vZGUuanM='; + var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78, + 111,100,101,46,106,115]); + that.decode(buff).then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testDecode004 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecode004', 0, async function () { + var that = new util.Base64() + var buff = 'qK6b/w=='; + var array = new Uint8Array([168, 174, 155, 255]); + that.decode(buff).then(val=>{ + for (var i = 0; i < array.length; i++) { + expect(val[i]).assertEqual(array[i]) + } + }) + }) + + /** + * @tc.name: testDecode005 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecode005', 0, async function () { + var that = new util.Base64() + var buff = 'QmFzZTY0'; + var rarray = new Uint8Array([66, 97, 115, 101, 54, 52]); + that.decode(buff).then(val=>{ + for (var i = 0; i < rarray.length; i++) { + expect(val[i]).assertEqual(rarray[i]) + } + }) + }) + + /** + * @tc.name: testDecode001 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecode001', 0, async function () { + var that = new util.Base64() + var array = new Uint8Array([99,122,69,122]); + var rarray = new Uint8Array([115,49,51]); + that.decode(array).then(val=>{ + for (var i = 0; i < rarray.length; i++) { + expect(val[i]).assertEqual(rarray[i]) + } + }) + }) + + /** + * @tc.name: testDecode002 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecode002', 0, async function () { + var that = new util.Base64() + var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,53,118,90,71,85,117,97,110,77,61]); + var rarray = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); + that.decode(array).then(val=>{ + for (var i = 0; i < rarray.length; i++) { + expect(val[i]).assertEqual(rarray[i]) + } + }) + }) + + /** + * @tc.name: testDecode003 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecode003', 0, async function () { + var that = new util.Base64() + var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73,71,108, + 117,73,69,53,118,90,71,85,117,97,110,77,61]); + var rarray = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111, + 100,101,46,106,115]); + that.decode(array).then(val=>{ + for (var i = 0; i < rarray.length; i++) { + expect(val[i]).assertEqual(rarray[i]) + } + }) + }) + + /** + * @tc.name: testDecode004 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array + into a newly allocated u8 array. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecode004', 0, async function () { + var that = new util.Base64() + var array = new Uint8Array([113,75,54,98,47,119,61,61]); + var rarray = new Uint8Array([168, 174, 155, 255]); + that.decode(array).then(val=>{ + for (var i = 0; i < rarray.length; i++) { + expect(val[i]).assertEqual(rarray[i]) + } + }) + }) + + /** + * @tc.name: testDecode005 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. + * @tc.require: AR000GFB2Q + * @tc.author: bihu + */ + it('testDecode005', 0, async function () { + var that = new util.Base64() + var array = new Uint8Array([81, 109, 70, 122, 90, 84, 89, 48]); + var rarray = new Uint8Array([66, 97, 115, 101, 54, 52]); + that.decode(array).then(val=>{ + for (var i = 0; i < rarray.length; i++) { + expect(val[i]).assertEqual(rarray[i]) + } + }) + }) +}) + +describe('RationalNumberFunTest', function () { + + /** + * @tc.name: testRationalNumberCreateRationalFromString001 + * @tc.desc: Creates a RationalNumber object based on a given string. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberCreateRationalFromString001', 0, function () { + var pro = new util.RationalNumber(1, 2) + var res = pro.createRationalFromString('-1:2') + var result1 = res.valueOf() + expect(result1).assertEqual(-0.5) + }) + + /** + * @tc.name: testRationalNumberCreateRationalFromString002 + * @tc.desc: Creates a RationalNumber object based on a given string. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberCreateRationalFromString002', 0, function () { + var pro = new util.RationalNumber(1, 2) + var res = pro.createRationalFromString('+3/4') + var result1 = res.valueOf() + expect(result1).assertEqual(0.75) + }) + + /** + * @tc.name: testRationalNumberCreateRationalFromString003 + * @tc.desc: Creates a RationalNumber object based on a given string. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberCreateRationalFromString003', 0, function () { + var pro = new util.RationalNumber(1, 2) + var res = pro.createRationalFromString('+3:-4') + var result1 = res.valueOf() + expect(result1).assertEqual(-0.75) + }) + + /** + * @tc.name: testRationalNumberCreateRationalFromString004 + * @tc.desc: Creates a RationalNumber object based on a given string. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberCreateRationalFromString004', 0, function () { + var pro = new util.RationalNumber(1, 2) + var res = pro.createRationalFromString('+2:4') + var result1 = res.valueOf() + expect(result1).assertEqual(0.5) + }) + + /** + * @tc.name: testRationalNumberCreateRationalFromString005 + * @tc.desc: Creates a RationalNumber object based on a given string. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberCreateRationalFromString005', 0, function () { + var pro = new util.RationalNumber(1, 2) + var res = pro.createRationalFromString('+2:-4') + var result1 = res.valueOf() + expect(result1).assertEqual(-0.5) + }) + + /** + * @tc.name: testRationalNumberCompare001 + * @tc.desc: Compares the current RationalNumber object with a given object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberCompare001', 0, function () { + var pro = new util.RationalNumber(2, 1) + var proc = new util.RationalNumber(3, 4) + var res = pro.compareTo(proc) + expect(res).assertEqual(1) + }) + + /** + * @tc.name: testRationalNumberCompare002 + * @tc.desc: Compares the current RationalNumber object with a given object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberCompare002', 0, function () { + var pro = new util.RationalNumber(2, 1) + var proc = new util.RationalNumber(0, 0) + var res = pro.compareTo(proc) + expect(res).assertEqual(-1) + }) + + /** + * @tc.name: testRationalNumberCompare003 + * @tc.desc: Compares the current RationalNumber object with a given object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberCompare003', 0, function () { + var pro = new util.RationalNumber(2, 1) + var proc = new util.RationalNumber(8, 3) + var res = pro.compareTo(proc) + expect(res).assertEqual(-1) + }) + + /** + * @tc.name: testRationalNumberCompare004 + * @tc.desc: Compares the current RationalNumber object with a given object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberCompare004', 0, function () { + var pro = new util.RationalNumber(2, 1) + var proc = new util.RationalNumber(2, 1) + var res = pro.compareTo(proc) + expect(res).assertEqual(0) + }) + + /** + * @tc.name: testRationalNumberCompare005 + * @tc.desc: Compares the current RationalNumber object with a given object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberCompare005', 0, function () { + var pro = new util.RationalNumber(0, 0) + var proc = new util.RationalNumber(2, 1) + var res = pro.compareTo(proc) + expect(res).assertEqual(1) + }) + + /** + * @tc.name: testRationalNumberEquals001 + * @tc.desc: Checks whether a given object is the same as the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberEquals001', 0, function () { + var pro = new util.RationalNumber(2, 1) + var proc = new util.RationalNumber(3, 4) + var res = pro.equals(proc) + expect(res).assertEqual(false) + }) + + /** + * @tc.name: testRationalNumberEquals002 + * @tc.desc: Checks whether a given object is the same as the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberEquals002', 0, function () { + var pro = new util.RationalNumber(2, 1) + var proc = new util.RationalNumber(4, 2) + var res = pro.equals(proc) + expect(res).assertEqual(true) + }) + + /** + * @tc.name: testRationalNumberEquals003 + * @tc.desc: Checks whether a given object is the same as the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberEquals003', 0, function () { + var pro = new util.RationalNumber(0, 1) + var proc = new util.RationalNumber(0, 2) + var res = pro.equals(proc) + expect(res).assertEqual(true) + }) + + /** + * @tc.name: testRationalNumberEquals004 + * @tc.desc: Checks whether a given object is the same as the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberEquals004', 0, function () { + var pro = new util.RationalNumber(0, 0) + var proc = new util.RationalNumber(0, 2) + var res = pro.equals(proc) + expect(res).assertEqual(false) + }) + + /** + * @tc.name: testRationalNumberEquals005 + * @tc.desc: Checks whether a given object is the same as the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberEquals005', 0, function () { + var pro = new util.RationalNumber(-2, 0) + var proc = new util.RationalNumber(2, 0) + var res = pro.equals(proc) + expect(res).assertEqual(false) + }) + + /** + * @tc.name: testRationalNumberValueOf001 + * @tc.desc: Obtains the value of the current RationalNumber object as a number. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberValueOf001', 0, function () { + var pro = new util.RationalNumber(2, 1) + var res = pro.valueOf() + expect(res).assertEqual(2) + }) + + /** + * @tc.name: testRationalNumberValueOf002 + * @tc.desc: Obtains the value of the current RationalNumber object as a number. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberValueOf002', 0, function () { + var pro = new util.RationalNumber(2, 10) + var res = pro.valueOf() + expect(res).assertEqual(0.2) + }) + + /** + * @tc.name: testRationalNumberValueOf003 + * @tc.desc: Obtains the value of the current RationalNumber object as a number. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberValueOf003', 0, function () { + var pro = new util.RationalNumber(1, 2) + var res = pro.valueOf() + expect(res).assertEqual(0.5) + }) + + /** + * @tc.name: testRationalNumberValueOf004 + * @tc.desc: Obtains the value of the current RationalNumber object as a number. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberValueOf004', 0, function () { + var pro = new util.RationalNumber(4, 2) + var res = pro.valueOf() + expect(res).assertEqual(2) + }) + + /** + * @tc.name: testRationalNumberValueOf005 + * @tc.desc: Obtains the value of the current RationalNumber object as a number. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberValue005', 0, function () { + var pro = new util.RationalNumber(4, 1) + var res = pro.valueOf() + expect(res).assertEqual(4) + }) + + /** + * @tc.name: testRationalNumberGetCommonDivisor001 + * @tc.desc: Obtains the greatest common divisor of two specified numbers. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetCommonDivisor001', 0, function () { + var pro = new util.RationalNumber(0, 0) + var res = pro.getCommonDivisor(4, 8) + expect(res).assertEqual(4) + }) + + /** + * @tc.name: testRationalNumberGetCommonDivisor002 + * @tc.desc: Obtains the greatest common divisor of two specified numbers. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetCommonDivisor002', 0, function () { + var pro = new util.RationalNumber(0, 0) + var res = pro.getCommonDivisor(10, 15) + expect(res).assertEqual(5) + }) + + /** + * @tc.name: testRationalNumberGetCommonDivisor003 + * @tc.desc: Obtains the greatest common divisor of two specified numbers. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetCommonDivisor003', 0, function () { + var pro = new util.RationalNumber(0, 0) + var res = pro.getCommonDivisor(8, 4) + expect(res).assertEqual(4) + }) + + /** + * @tc.name: testRationalNumberGetCommonDivisor004 + * @tc.desc: Obtains the greatest common divisor of two specified numbers. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetCommonDivisor004', 0, function () { + var pro = new util.RationalNumber(0, 0) + var res = pro.getCommonDivisor(8, 16) + expect(res).assertEqual(8) + }) + + /** + * @tc.name: testRationalNumberGetCommonDivisor005 + * @tc.desc: Obtains the greatest common divisor of two specified numbers. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetCommonDivisor005', 0, function () { + var pro = new util.RationalNumber(0, 0) + var res = pro.getCommonDivisor(2, 16) + expect(res).assertEqual(2) + }) + + /** + * @tc.name: testRationalNumberGetDenominator001 + * @tc.desc: Obtains the denominator of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetDenominator001', 0, function () { + var pro = new util.RationalNumber(2, 1) + var res = pro.getDenominator() + expect(res).assertEqual(1) + }) + + /** + * @tc.name: testRationalNumberGetDenominator002 + * @tc.desc: Obtains the denominator of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetDenominator002', 0, function () { + var pro = new util.RationalNumber(2, 3) + var res = pro.getDenominator() + expect(res).assertEqual(3) + }) + + /** + * @tc.name: testRationalNumberGetDenominator003 + * @tc.desc: Obtains the denominator of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetDenominator003', 0, function () { + var pro = new util.RationalNumber(2, 0) + var res = pro.getDenominator() + expect(res).assertEqual(0) + }) + + /** + * @tc.name: testRationalNumberGetDenominator004 + * @tc.desc: Obtains the denominator of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetDenominator004', 0, function () { + var pro = new util.RationalNumber(10, 5) + var res = pro.getDenominator() + expect(res).assertEqual(1) + }) + + /** + * @tc.name: testRationalNumberGetDenominator005 + * @tc.desc: Obtains the denominator of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetDenominator005', 0, function () { + var pro = new util.RationalNumber(6, 3) + var res = pro.getDenominator() + expect(res).assertEqual(1) + }) + + /** + * @tc.name: testRationalNumberGetNumerator001 + * @tc.desc: Obtains the numerator of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetNumerator001', 0, function () { + var pro = new util.RationalNumber(-2, 1) + var res = pro.getNumerator() + expect(res).assertEqual(-2) + }) + + /** + * @tc.name: testRationalNumberGetNumerator002 + * @tc.desc: Obtains the numerator of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetNumerator002', 0, function () { + var pro = new util.RationalNumber(0, 3) + var res = pro.getNumerator() + expect(res).assertEqual(0) + }) + + /** + * @tc.name: testRationalNumberGetNumerator003 + * @tc.desc: Obtains the numerator of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetNumerator003', 0, function () { + var pro = new util.RationalNumber(2, 4) + var res = pro.getNumerator() + expect(res).assertEqual(1) + }) + + /** + * @tc.name: testRationalNumberGetNumerator004 + * @tc.desc: Obtains the numerator of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetNumerator004', 0, function () { + var pro = new util.RationalNumber(3, 6) + var res = pro.getNumerator() + expect(res).assertEqual(1) + }) + + /** + * @tc.name: testRationalNumberGetNumerator005 + * @tc.desc: Obtains the numerator of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberGetNumerator005', 0, function () { + var pro = new util.RationalNumber(10, 5) + var res = pro.getNumerator() + expect(res).assertEqual(2) + }) + + /** + * @tc.name: testRationalNumberIsFinite001 + * @tc.desc: Checks whether the current RationalNumber object represents a finite value. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsFinite001', 0, function () { + var pro = new util.RationalNumber(-2, 1) + var res = pro.isFinite() + expect(res).assertEqual(true) + }) + + /** + * @tc.name: testRationalNumberIsFinite002 + * @tc.desc: Checks whether the current RationalNumber object represents a finite value. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsFinite002', 0, function () { + var pro = new util.RationalNumber(0, 3) + var res = pro.isFinite() + expect(res).assertEqual(true) + }) + + /** + * @tc.name: testRationalNumberIsFinite003 + * @tc.desc: Checks whether the current RationalNumber object represents a finite value. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsFinite003', 0, function () { + var pro = new util.RationalNumber(2, 0) + var res = pro.isFinite() + expect(res).assertEqual(false) + }) + + /** + * @tc.name: testRationalNumberIsFinite004 + * @tc.desc: Checks whether the current RationalNumber object represents a finite value. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsFinite004', 0, function () { + var pro = new util.RationalNumber(1, 3) + var res = pro.isFinite() + expect(res).assertEqual(true) + }) + + /** + * @tc.name: testRationalNumberIsFinite005 + * @tc.desc: Checks whether the current RationalNumber object represents a finite value. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsFinite005', 0, function () { + var pro = new util.RationalNumber(10, 5) + var res = pro.isFinite() + expect(res).assertEqual(true) + }) + + /** + * @tc.name: testRationalNumberIsNaN001 + * @tc.desc: Checks whether the current RationalNumber object represents a finite value. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsNaN001', 0, function () { + var pro = new util.RationalNumber(-2, 1) + var res = pro.isNaN() + expect(res).assertEqual(false) + }) + + /** + * @tc.name: testRationalNumberIsNaN002 + * @tc.desc: Checks whether the current RationalNumber object represents a Not-a-Number (NaN) value. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsNaN002', 0, function () { + var pro = new util.RationalNumber(0, 3) + var res = pro.isNaN() + expect(res).assertEqual(false) + }) + + /** + * @tc.name: testRationalNumberIsNaN003 + * @tc.desc: Checks whether the current RationalNumber object represents a Not-a-Number (NaN) value. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsNaN003', 0, function () { + var pro = new util.RationalNumber(0, 0) + var res = pro.isNaN() + expect(res).assertEqual(true) + }) + + /** + * @tc.name: testRationalNumberIsNaN004 + * @tc.desc: Checks whether the current RationalNumber object represents a Not-a-Number (NaN) value. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsNaN004', 0, function () { + var pro = new util.RationalNumber(10, 0) + var res = pro.isNaN() + expect(res).assertEqual(false) + }) + + /** + * @tc.name: testRationalNumberIsNaN005 + * @tc.desc: Checks whether the current RationalNumber object represents a Not-a-Number (NaN) value. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsNaN005', 0, function () { + var pro = new util.RationalNumber(10, 1) + var res = pro.isNaN() + expect(res).assertEqual(false) + }) + + /** + * @tc.name: testRationalNumberIsZero001 + * @tc.desc: Checks whether the current RationalNumber object represents the value 0. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsZero001', 0, function () { + var pro = new util.RationalNumber(-2, 1) + var res = pro.isZero() + expect(res).assertEqual(false) + }) + + /** + * @tc.name: testRationalNumberIsZero002 + * @tc.desc: Checks whether the current RationalNumber object represents the value 0. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsZero002', 0, function () { + var pro = new util.RationalNumber(0, 3) + var res = pro.isZero() + expect(res).assertEqual(true) + }) + + /** + * @tc.name: testRationalNumberIsZero003 + * @tc.desc: Checks whether the current RationalNumber object represents the value 0. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsZero003', 0, function () { + var pro = new util.RationalNumber(0, 0) + var res = pro.isZero() + expect(res).assertEqual(false) + }) + + /** + * @tc.name: testRationalNumberIsZero004 + * @tc.desc: Checks whether the current RationalNumber object represents the value 0. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsZero004', 0, function () { + var pro = new util.RationalNumber(10, 2) + var res = pro.isZero() + expect(res).assertEqual(false) + }) + + /** + * @tc.name: testRationalNumberIsZero005 + * @tc.desc: Checks whether the current RationalNumber object represents the value 0. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberIsZero005', 0, function () { + var pro = new util.RationalNumber(1, 1) + var res = pro.isZero() + expect(res).assertEqual(false) + }) + + /** + * @tc.name: testRationalNumberToString001 + * @tc.desc: Obtains a string representation of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberToString001', 0, function () { + var pro = new util.RationalNumber(-2, 1) + var res = pro.toString() + expect(res).assertEqual("-2/1") + }) + + /** + * @tc.name: testRationalNumberToString002 + * @tc.desc: Obtains a string representation of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberToString002', 0, function () { + var pro = new util.RationalNumber(0, 0) + var res = pro.toString() + expect(res).assertEqual("NaN") + }) + + /** + * @tc.name: testRationalNumberToString003 + * @tc.desc: Obtains a string representation of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberToString003', 0, function () { + var pro = new util.RationalNumber(3, 0) + var res = pro.toString() + expect(res).assertEqual("Infinity") + }) + + /** + * @tc.name: testRationalNumberToString004 + * @tc.desc: Obtains a string representation of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberToString004', 0, function () { + var pro = new util.RationalNumber(-3, 0) + var res = pro.toString() + expect(res).assertEqual("-Infinity") + }) + + /** + * @tc.name: testRationalNumberToString005 + * @tc.desc: Obtains a string representation of the current RationalNumber object. + * @tc.require: AR000GFB5A + * @tc.author: liuqiang + */ + it('testRationalNumberToString005', 0, function () { + var pro = new util.RationalNumber(2, 3) + var res = pro.toString() + expect(res).assertEqual('2/3') + }) +}) + +describe('LruBufferFunTest', function () { + + /** + * @tc.name: testLruBufferUpdateGetCapacity001 + * @tc.desc: Updates the buffer capacity to a specified capacity. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferUpdateGetCapacity001', 0, function () { + var that = new util.LruBuffer() + that.updateCapacity(10) + var result = that.getCapacity() + expect(result).assertEqual(10) + }) + + /** + * @tc.name: testLruBufferUpdateGetCapacity002 + * @tc.desc: Updates the buffer capacity to a specified capacity. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferUpdateGetCapacity002', 0, function () { + var that = new util.LruBuffer() + that.updateCapacity(2147483646) + var result = that.getCapacity() + expect(result).assertEqual(2147483646) + }) + + /** + * @tc.name: testLruBufferUpdateGetCapacity003 + * @tc.desc: Updates the buffer capacity to a specified capacity. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferUpdateGetCapacity003', 0, function () { + var that = new util.LruBuffer(100) + that.updateCapacity(20) + var result = that.getCapacity() + expect(result).assertEqual(20) + }) + + /** + * @tc.name: testLruBufferUpdateGetCapacity004 + * @tc.desc: Updates the buffer capacity to a specified capacity. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferUpdateGetCapacity004', 0, function () { + var that = new util.LruBuffer(50) + that.updateCapacity(2) + var result = that.getCapacity() + expect(result).assertEqual(2) + }) + + /** + * @tc.name: testLruBufferUpdateGetCapacity005 + * @tc.desc: Updates the buffer capacity to a specified capacity. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferUpdateGetCapacity005', 0, function () { + var that = new util.LruBuffer(200) + that.updateCapacity(100) + var result = that.getCapacity() + expect(result).assertEqual(100) + }) + + /** + * @tc.name: testLruBufferGet001 + * @tc.desc: Obtains the value associated with a specified key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGet001', 0, function () { + var that = new util.LruBuffer(100) + that.put(1,2) + var result = that.get(1) + expect(result).assertEqual(2) + }) + + /** + * @tc.name: testLruBufferGet002 + * @tc.desc: Obtains the value associated with a specified key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGet002', 0, function () { + var that = new util.LruBuffer(100) + that.put(1,2) + var result = that.get(5) + expect(result).assertEqual(undefined) + }) + + /** + * @tc.name: testLruBufferGet003 + * @tc.desc: Obtains the value associated with a specified key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGet003', 0, function () { + var that = new util.LruBuffer(100) + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + var result1 = that.get(20) + var result2 = that.get('abcd') + var result3 = that.get(2) + expect(result1).assertEqual(undefined) + expect(result2).assertEqual(15) + expect(result3).assertEqual(10) + }) + + /** + * @tc.name: testLruBufferGet004 + * @tc.desc: Obtains the value associated with a specified key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGet004', 0, function () { + var that = new util.LruBuffer() + that.put('1111','bcjdshc') + that.put(20,'cdjcaxb') + that.put('abcd',15) + var result1 = that.get('1111') + var result2 = that.get(20) + var result3 = that.get('abcd') + var result4 = that.get(25) + expect(result1).assertEqual('bcjdshc') + expect(result2).assertEqual('cdjcaxb') + expect(result3).assertEqual(15) + expect(result4).assertEqual(undefined) + }) + + /** + * @tc.name: testLruBufferGet005 + * @tc.desc: Obtains the value associated with a specified key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGet005', 0, function () { + var that = new util.LruBuffer() + that.put('1111','bcjdshc') + that.put(20,'cdjcaxb') + that.updateCapacity(2) + that.put('abcd',15) + var result1 = that.get('1111') + var result2 = that.get(20) + var result3 = that.get('abcd') + var result4 = that.get(25) + expect(result1).assertEqual(undefined) + expect(result2).assertEqual('cdjcaxb') + expect(result3).assertEqual(15) + expect(result4).assertEqual(undefined) + }) + + /** + * @tc.name: testLruBufferPut001 + * @tc.desc: Adds a key-value pair to the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferPut001', 0, function () { + var that = new util.LruBuffer() + var temp = that.put('1111','bcjdshc') + expect(temp).assertEqual(undefined) + }) + + /** + * @tc.name: testLruBufferPut002 + * @tc.desc: Adds a key-value pair to the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferPut002', 0, function () { + var that = new util.LruBuffer() + var temp1 = that.put('1111','bcjdshc') + var temp2 = that.put('1111',13) + expect(temp2).assertEqual('bcjdshc') + }) + + /** + * @tc.name: testLruBufferPut003 + * @tc.desc: Adds a key-value pair to the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferPut003', 0, function () { + var that = new util.LruBuffer() + var temp = that.put('1111','bcjdshc') + var temp1 = that.put(1,12) + var temp2 = that.put(2,5) + var temp3 = that.put(2,'adasfdad') + var temp4 = that.put('abc',10) + expect(temp1).assertEqual(undefined) + expect(temp2).assertEqual(undefined) + expect(temp3).assertEqual(5) + expect(temp4).assertEqual(undefined) + }) + + /** + * @tc.name: testLruBufferPut004 + * @tc.desc: Adds a key-value pair to the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferPut004', 0, function () { + var that = new util.LruBuffer() + var temp = that.put('1111','bcjdshc') + var temp1 = that.put(1,12) + var temp2 = that.put(2,5) + that.updateCapacity(2) + var temp3 = that.put(2,'adasfdad') + var temp4 = that.put('1111',10) + expect(temp).assertEqual(undefined) + expect(temp1).assertEqual(undefined) + expect(temp2).assertEqual(undefined) + expect(temp3).assertEqual(5) + expect(temp4).assertEqual(undefined) + }) + + /** + * @tc.name: testLruBufferPut005 + * @tc.desc: Adds a key-value pair to the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferPut005', 0, function () { + var that = new util.LruBuffer() + var temp = that.put('1111','bcjdshc') + var temp1 = that.put(1,12) + var temp2 = that.put(2,5) + var temp3 = that.put(1,10) + var temp4 = that.put(2,22) + var temp5 = that.put(2,30) + expect(temp).assertEqual(undefined) + expect(temp1).assertEqual(undefined) + expect(temp2).assertEqual(undefined) + expect(temp3).assertEqual(12) + expect(temp4).assertEqual(5) + expect(temp5).assertEqual(22) + }) + + /** + * @tc.name: testLruBufferGetCreateCount001 + * @tc.desc: Obtains the number of times createDefault(Object) returned a value. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetCreateCount001', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.get(3) + that.get(5) + that.get(10) + var result = that.getCreateCount() + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferGetCreateCount002 + * @tc.desc: Obtains the number of times createDefault(Object) returned a value. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetCreateCount002', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.get(6) + that.get(8) + that.get(20) + var result = that.getCreateCount() + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferGetCreateCount003 + * @tc.desc: Obtains the number of times createDefault(Object) returned a value. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetCreateCount003', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.get('abc') + that.get('cndk') + var result = that.getCreateCount() + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferGetCreateCount004 + * @tc.desc: Obtains the number of times createDefault(Object) returned a value. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetCreateCount004', 0, function () { + var that = new util.LruBuffer() + that.put(5,2) + that.put(10,10) + that.put('abcd','abcd') + that.get(3) + that.get(20) + that.get(12) + var result = that.getCreateCount() + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferGetCreateCount005 + * @tc.desc: Obtains the number of times createDefault(Object) returned a value. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetCreateCount005', 0, function () { + var that = new util.LruBuffer() + that.put('xsjk','bcjds') + that.put('ajc',10) + that.put('abcd',15) + that.get(2) + that.get(10) + that.get(30) + var result = that.getCreateCount() + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferGetMissCount001 + * @tc.desc: Obtains the number of times that the queried values are not matched. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetMissCount001', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.get(3) + that.get(5) + that.get(10) + var result = that.getMissCount() + expect(result).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferGetMissCount002 + * @tc.desc: Obtains the number of times that the queried values are not matched. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetMissCount002', 0, function () { + var that = new util.LruBuffer() + that.put(5,2) + that.put(1,10) + that.put('abcd','bcjsc') + that.get(2) + that.get(10) + that.get(15) + var result = that.getMissCount() + expect(result).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferGetMissCount003 + * @tc.desc: Obtains the number of times that the queried values are not matched. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetMissCount003', 0, function () { + var that = new util.LruBuffer() + that.put(10,10) + that.put(3,20) + that.put(12,16) + that.get(1) + that.get(2) + that.get(6) + var result = that.getMissCount() + expect(result).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferGetMissCount004 + * @tc.desc: Obtains the number of times that the queried values are not matched. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetMissCount004', 0, function () { + var that = new util.LruBuffer() + that.put('acb','asdc') + that.put('vfb',1) + that.put('abcd','abcd') + that.get(3) + that.get(5) + that.get(10) + var result = that.getMissCount() + expect(result).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferGetMissCount005 + * @tc.desc: Obtains the number of times that the queried values are not matched. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetMissCount005', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.get(3) + that.get(5) + that.get(10) + that.contains(2) + that.contains(6) + var result = that.getMissCount() + expect(result).assertEqual(4) + }) + + /** + * @tc.name: testLruBufferGetMissCount006 + * @tc.desc: Obtains the number of times that the queried values are not matched. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetMissCount006', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.get(1) + that.get(2) + that.get('abcd') + var result = that.getMissCount() + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferGetRemovalCount001 + * @tc.desc: Obtains the number of times that values are evicted from the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetRemovalCount001', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.put(3,20) + that.put(5,30) + var result = that.getRemovalCount() + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferGetRemovalCount002 + * @tc.desc: Obtains the number of times that values are evicted from the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetRemovalCount002', 0, function () { + var that = new util.LruBuffer() + that.put(10,2) + that.put(3,2) + that.put(15,15) + that.put(1,20) + var result = that.getRemovalCount() + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferGetRemovalCount003 + * @tc.desc: Obtains the number of times that values are evicted from the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetRemovalCount003', 0, function () { + var that = new util.LruBuffer() + that.put('abc',2) + that.put('abcd','abcd') + that.put(3,2) + var result = that.getRemovalCount() + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferGetRemovalCount004 + * @tc.desc: Obtains the number of times that values are evicted from the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetRemovalCount004', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.updateCapacity(2) + that.put(3,20) + that.put(5,30) + var result = that.getRemovalCount() + expect(result).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferGetRemovalCount005 + * @tc.desc: Obtains the number of times that values are evicted from the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetRemovalCount005', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.updateCapacity(3) + that.put('string',20) + that.put('abc',30) + that.put(10,20) + var result = that.getRemovalCount() + expect(result).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferGetMatchCount001 + * @tc.desc: Obtains the number of times that the queried values are successfully matched. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetMatchCount001', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.get(1) + that.get(2) + that.get('abcd') + var result = that.getMatchCount() + expect(result).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferGetMatchCount002 + * @tc.desc: Obtains the number of times that the queried values are successfully matched. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetMatchCount002', 0, function () { + var that = new util.LruBuffer() + that.put(10,2) + that.put(2,1) + that.put('abcd',15) + that.get(10) + that.get(2) + that.get('abcd') + that.get('string') + var result = that.getMatchCount() + expect(result).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferGetMatchCount003 + * @tc.desc: Obtains the number of times that the queried values are successfully matched. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetMatchCount003', 0, function () { + var that = new util.LruBuffer() + that.put(0,1) + that.put(30,10) + that.put('abcd',15) + that.get(0) + that.get(30) + that.get('abcd') + var result = that.getMatchCount() + expect(result).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferGetMatchCount004 + * @tc.desc: Obtains the number of times that the queried values are successfully matched. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetMatchCount004', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.get(1) + that.get(2) + that.get('abcd') + that.contains(2) + that.contains('abcd') + that.contains(20) + var result = that.getMatchCount() + expect(result).assertEqual(5) + }) + + /** + * @tc.name: testLruBufferGetMatchCount005 + * @tc.desc: Obtains the number of times that the queried values are successfully matched. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetMatchCount005', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.put('string','string') + that.get(1) + that.get(2) + that.get('abcd') + that.get('string') + that.contains(2) + that.contains('abcd') + that.contains('string') + that.contains(10) + var result = that.getMatchCount() + expect(result).assertEqual(7) + }) + + /** + * @tc.name: testLruBufferGetMatchCount006 + * @tc.desc: Obtains the number of times that the queried values are successfully matched. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetMatchCount006', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.get(5) + var result = that.getMatchCount() + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferGetPutCount001 + * @tc.desc: Obtains the number of times that values are added to the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetPutCount001', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + var result = that.getPutCount() + expect(result).assertEqual(1) + }) + + /** + * @tc.name: testLruBufferGetPutCount002 + * @tc.desc: Obtains the number of times that values are added to the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetPutCount002', 0, function () { + var that = new util.LruBuffer() + that.put(5,3) + that.put(2,10) + var result = that.getPutCount() + expect(result).assertEqual(2) + }) + + /** + * @tc.name: testLruBufferGetPutCount003 + * @tc.desc: Obtains the number of times that values are added to the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetPutCount003', 0, function () { + var that = new util.LruBuffer() + that.put('string',2) + that.put('abcd',1) + that.put('ab','a') + var result = that.getPutCount() + expect(result).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferGetPutCount004 + * @tc.desc: Obtains the number of times that values are added to the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetPutCount004', 0, function () { + var that = new util.LruBuffer() + that.put('string','string') + that.put('ac','abc') + that.put('abcd',15) + var result = that.getPutCount() + expect(result).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferGetPutCount005 + * @tc.desc: Obtains the number of times that values are added to the buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetPutCount005', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.updateCapacity(2) + that.put('abcd','abc') + var result = that.getPutCount() + expect(result).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferGetCapacity001 + * @tc.desc: Obtains the capacity of the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetCapacity001', 0, function () { + var that = new util.LruBuffer() + var result = that.getCapacity() + expect(result).assertEqual(64) + }) + + /** + * @tc.name: testLruBufferGetCapacity002 + * @tc.desc: Obtains the capacity of the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetCapacity002', 0, function () { + var that = new util.LruBuffer(2) + var result = that.getCapacity() + expect(result).assertEqual(2) + }) + + /** + * @tc.name: testLruBufferGetCapacity003 + * @tc.desc: Obtains the capacity of the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetCapacity003', 0, function () { + var that = new util.LruBuffer(100) + var result = that.getCapacity() + expect(result).assertEqual(100) + }) + + /** + * @tc.name: testLruBufferGetCapacity004 + * @tc.desc: Obtains the capacity of the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetCapacity004', 0, function () { + var that = new util.LruBuffer() + that.updateCapacity(50) + var result = that.getCapacity() + expect(result).assertEqual(50) + }) + + /** + * @tc.name: testLruBufferGetCapacity005 + * @tc.desc: Obtains the capacity of the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetCapacity005', 0, function () { + var that = new util.LruBuffer(100) + that.updateCapacity(10) + var result = that.getCapacity() + expect(result).assertEqual(10) + }) + + /** + * @tc.name: testLruBufferLength001 + * @tc.desc: Obtains the total number of values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferLength001', 0, function () { + var that = new util.LruBuffer() + var result = that.length + expect(result).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferLength002 + * @tc.desc: Obtains the total number of values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferLength002', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + var result = that.length + expect(result).assertEqual(1) + }) + + /** + * @tc.name: testLruBufferLength003 + * @tc.desc: Obtains the total number of values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferLength003', 0, function () { + var that = new util.LruBuffer() + that.put('abc',2) + that.put('string','string') + var result = that.length + expect(result).assertEqual(2) + }) + + /** + * @tc.name: testLruBufferLength004 + * @tc.desc: Obtains the total number of values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferLength004', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.put('abcd',20) + var result = that.length + expect(result).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferLength005 + * @tc.desc: Obtains the total number of values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferLength005', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.put('abcd',20) + that.updateCapacity(3); + that.put(5,33); + that.put(25,35); + var result = that.length + expect(result).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferClear001 + * @tc.desc: Clears key-value pairs from the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferClear001', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + var result1 = that.length + that.clear() + var result2 = that.length + expect(result1).assertEqual(1) + expect(result2).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferClear002 + * @tc.desc: Clears key-value pairs from the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferClear002', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put(5,33); + that.put(25,35); + var result1 = that.length + that.clear() + var result2 = that.length + expect(result1).assertEqual(4) + expect(result2).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferClear003 + * @tc.desc: Clears key-value pairs from the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferClear003', 0, function () { + var that = new util.LruBuffer() + that.put('abc',2) + that.put(2,'abc') + that.put('ancd','abcd') + that.put(10,35) + var result1 = that.length + that.clear() + var result2 = that.length + expect(result1).assertEqual(4) + expect(result2).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferClear004 + * @tc.desc: Clears key-value pairs from the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferClear004', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put(5,33); + that.updateCapacity(3); + var result1 = that.length + that.clear() + var result2 = that.length + expect(result1).assertEqual(3) + expect(result2).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferClear005 + * @tc.desc: Clears key-value pairs from the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferClear005', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put(5,33); + that.put('abcd','string'); + that.updateCapacity(2); + var result1 = that.length + that.clear() + var result2 = that.length + expect(result1).assertEqual(2) + expect(result2).assertEqual(0) + }) + + /** + * @tc.name: testLruBufferIsEmpty001 + * @tc.desc: Checks whether the current buffer is empty. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferIsEmpty001', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + var result = that.isEmpty() + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testLruBufferIsEmpty002 + * @tc.desc: Checks whether the current buffer is empty. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferIsEmpty002', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + var result = that.isEmpty() + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testLruBufferIsEmpty003 + * @tc.desc: Checks whether the current buffer is empty. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferIsEmpty003', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put(5,33) + var result = that.isEmpty() + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testLruBufferIsEmpty004 + * @tc.desc: Checks whether the current buffer is empty. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferIsEmpty004', 0, function () { + var that = new util.LruBuffer() + that.put('abc',2) + that.put('string',10) + that.put('ab','abc') + var result = that.isEmpty() + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testLruBufferIsEmpty005 + * @tc.desc: Checks whether the current buffer is empty. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferIsEmpty005', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put(5,33); + that.clear() + var result = that.isEmpty() + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testLruBufferContains001 + * @tc.desc: Checks whether the current buffer contains a specified key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferContains001', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + var result = that.contains(1) + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testLruBufferContains002 + * @tc.desc: Checks whether the current buffer contains a specified key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferContains002', 0, function () { + var that = new util.LruBuffer() + that.put(0,5) + var result = that.contains(0) + expect(result).assertEqual(true) + }) + + /** + * @tc.name: testLruBufferContains003 + * @tc.desc: Checks whether the current buffer contains a specified key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferContains003', 0, function () { + var that = new util.LruBuffer() + that.put('abc','abc') + var result = that.contains(1) + expect(result).assertEqual(false) + }) + + /** + * @tc.name: testLruBufferContains004 + * @tc.desc: Checks whether the current buffer contains a specified key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferContains004', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put('abcd',20) + var result1 = that.contains(1) + var result2 = that.contains(20) + expect(result1).assertEqual(true) + expect(result2).assertEqual(false) + }) + + /** + * @tc.name: testLruBufferContains005 + * @tc.desc: Checks whether the current buffer contains a specified key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferContains005', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put('string','string') + var result1 = that.contains(1) + var result2 = that.contains('string') + var result3 = that.contains(0) + expect(result1).assertEqual(true) + expect(result2).assertEqual(true) + expect(result3).assertEqual(false) + }) + + /** + * @tc.name: testLruBufferRemove001 + * @tc.desc: Deletes a specified key and its associated value from the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferRemove001', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + var result = that.remove(1) + expect(result).assertEqual(2) + }) + + /** + * @tc.name: testLruBufferRemove002 + * @tc.desc: Deletes a specified key and its associated value from the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferRemove002', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put('abcd',20) + var result1 = that.remove(1) + var result2 = that.remove('abcd') + expect(result1).assertEqual(2) + expect(result2).assertEqual(20) + }) + + /** + * @tc.name: testLruBufferRemove003 + * @tc.desc: Deletes a specified key and its associated value from the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferRemove003', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + var result1 = that.remove(1) + var result2 = that.remove(5) + expect(result1).assertEqual(2) + expect(result2).assertEqual(undefined) + }) + + /** + * @tc.name: testLruBufferRemove004 + * @tc.desc: Deletes a specified key and its associated value from the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferRemove004', 0, function () { + var that = new util.LruBuffer() + that.put(0,'abc') + that.put('abcd',20) + var result1 = that.remove(1) + var result2 = that.remove('abcd') + expect(result1).assertEqual(undefined) + expect(result2).assertEqual(20) + }) + + /** + * @tc.name: testLruBufferRemove005 + * @tc.desc: Deletes a specified key and its associated value from the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferRemove005', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + var result1 = that.remove(1) + var result2 = that.remove(3) + var result3 = that.get(3) + expect(result1).assertEqual(2) + expect(result2).assertEqual(10) + expect(result3).assertEqual(undefined) + }) + + /** + * @tc.name: testLruBufferCreateDefault001 + * @tc.desc: Executes subsequent operations if miss to compute a value for the specific key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferCreateDefault001', 0, function () { + var that = new util.LruBuffer() + var result = that.createDefault(1) + expect(result).assertEqual(undefined) + }) + + /** + * @tc.name: testLruBufferCreateDefault002 + * @tc.desc: Executes subsequent operations if miss to compute a value for the specific key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferCreateDefault002', 0, function () { + var that = new util.LruBuffer() + var result = that.createDefault(0) + expect(result).assertEqual(undefined) + }) + + /** + * @tc.name: testLruBufferCreateDefault003 + * @tc.desc: Executes subsequent operations if miss to compute a value for the specific key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferCreateDefault003', 0, function () { + var that = new util.LruBuffer() + var result = that.createDefault('string') + expect(result).assertEqual(undefined) + }) + + /** + * @tc.name: testLruBufferCreateDefault004 + * @tc.desc: Executes subsequent operations if miss to compute a value for the specific key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferCreateDefault004', 0, function () { + var that = new util.LruBuffer() + var result = that.createDefault(10) + expect(result).assertEqual(undefined) + }) + + /** + * @tc.name: testLruBufferCreateDefault005 + * @tc.desc: Executes subsequent operations if miss to compute a value for the specific key. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferCreateDefault005', 0, function () { + var that = new util.LruBuffer() + var result1 = that.createDefault('abc') + var result2 = that.createDefault('ab') + expect(result1).assertEqual(undefined) + expect(result2).assertEqual(undefined) + }) + + /** + * @tc.name: testLruBufferKeys001 + * @tc.desc: Obtains a list of keys for the values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferKeys001', 0, function () { + var that = new util.LruBuffer() + that.put('string','abc') + var result = that.keys() + expect(result[0]).assertEqual('string') + }) + + /** + * @tc.name: testLruBufferKeys002 + * @tc.desc: Obtains a list of keys for the values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferKeys002', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + var result = that.keys() + expect(result[0]).assertEqual(1) + expect(result[1]).assertEqual(3) + expect(result[2]).assertEqual(5) + expect(result[3]).assertEqual('abc') + }) + + /** + * @tc.name: testLruBufferKeys003 + * @tc.desc: Obtains a list of keys for the values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferKeys003', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + var result = that.keys() + expect(result[0]).assertEqual(1) + expect(result[1]).assertEqual(5) + expect(result[2]).assertEqual('abc') + expect(result[3]).assertEqual(3) + }) + + /** + * @tc.name: testLruBufferKeys004 + * @tc.desc: Obtains a list of keys for the values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferKeys004', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + that.contains(1) + var result = that.keys() + expect(result[0]).assertEqual(5) + expect(result[1]).assertEqual('abc') + expect(result[2]).assertEqual(3) + expect(result[3]).assertEqual(1) + }) + + /** + * @tc.name: testLruBufferKeys005 + * @tc.desc: Obtains a list of keys for the values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferKeys005', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + that.remove(5) + that.contains(3) + that.get(1) + that.contains('abc') + var result = that.keys() + expect(result[0]).assertEqual(3) + expect(result[1]).assertEqual(1) + expect(result[2]).assertEqual('abc') + }) + + /** + * @tc.name: testLruBufferValues001 + * @tc.desc: Obtains a list of all values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferValues001', 0, function () { + var that = new util.LruBuffer() + that.put('string','abc') + var result = that.values() + expect(result[0]).assertEqual('abc') + }) + + /** + * @tc.name: testLruBufferValues002 + * @tc.desc: Obtains a list of all values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferValues002', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + var result = that.values() + expect(result[0]).assertEqual(2) + expect(result[1]).assertEqual(10) + expect(result[2]).assertEqual(15) + expect(result[3]).assertEqual(20) + }) + + /** + * @tc.name: testLruBufferValues003 + * @tc.desc: Obtains a list of all values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferValues003', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + var result = that.values() + expect(result[0]).assertEqual(2) + expect(result[1]).assertEqual(15) + expect(result[2]).assertEqual(20) + expect(result[3]).assertEqual(10) + }) + + /** + * @tc.name: testLruBufferValues004 + * @tc.desc: Obtains a list of all values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferValues004', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + that.contains(1) + var result = that.values() + expect(result[0]).assertEqual(15) + expect(result[1]).assertEqual(20) + expect(result[2]).assertEqual(10) + expect(result[3]).assertEqual(2) + }) + + /** + * @tc.name: testLruBufferValues005 + * @tc.desc: Obtains a list of all values in the current buffer. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferValues005', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + that.remove(5) + that.contains(3) + that.get(1) + that.contains('abc') + var result = that.values() + expect(result[0]).assertEqual(10) + expect(result[1]).assertEqual(2) + expect(result[2]).assertEqual(20) + }) + + /** + * @tc.name: testLruBufferToString001 + * @tc.desc: Returns a string representation of the object. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferToString001', 0, function () { + var that = new util.LruBuffer() + that.put('1111','bcjdshc') + that.put(1,2) + var result = that.toString() + expect(result).assertEqual('Lrubuffer[ maxSize = 64, hits = 0, misses = 0, hitRate = 0% ]') + }) + + /** + * @tc.name: testLruBufferToString002 + * @tc.desc: Returns a string representation of the object. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferToString002', 0, function () { + var that = new util.LruBuffer() + that.put('1111','bcjdshc') + that.put(1,2) + that.get(1) + that.get('1111') + var result = that.toString() + expect(result).assertEqual('Lrubuffer[ maxSize = 64, hits = 2, misses = 0, hitRate = 100% ]') + }) + + /** + * @tc.name: testLruBufferToString003 + * @tc.desc: Returns a string representation of the object. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferToString003', 0, function () { + var that = new util.LruBuffer(100) + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + var result = that.toString() + expect(result).assertEqual('Lrubuffer[ maxSize = 100, hits = 1, misses = 0, hitRate = 100% ]') + }) + + /** + * @tc.name: testLruBufferToString004 + * @tc.desc: Returns a string representation of the object. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferToString004', 0, function () { + var that = new util.LruBuffer(100) + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + that.get(2) + var result = that.toString() + expect(result).assertEqual('Lrubuffer[ maxSize = 100, hits = 1, misses = 1, hitRate = 50% ]') + }) + + /** + * @tc.name: testLruBufferToString005 + * @tc.desc: Returns a string representation of the object. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferToString005', 0, function () { + var that = new util.LruBuffer(100) + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + that.get(2) + that.get(1) + that.contains(5) + var result = that.toString() + expect(result).assertEqual('Lrubuffer[ maxSize = 100, hits = 3, misses = 1, hitRate = 75% ]') + }) + + /** + * @tc.name: testLruBufferEntries001 + * @tc.desc: Returns an array of key-value pairs of enumeratable properties of a given object. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferEntries001', 0, function () { + var that = new util.LruBuffer() + that.put('string','abc') + var i=0; + var arr={}; + for (let entry of that.entries()) { + arr[i]=entry[0]; + i++; + arr[i]=entry[1]; + i++; + } + expect(arr[1]).assertEqual('abc'); + }) + + /** + * @tc.name: testLruBufferEntries002 + * @tc.desc: Returns an array of key-value pairs of enumeratable properties of a given object. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferEntries002', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + var i=0; + var arr={}; + for (let entry of that.entries()) { + arr[i]=entry[0]; + i++; + arr[i]=entry[1]; + i++; + } + expect(arr[1]).assertEqual(2); + }) + + /** + * @tc.name: testLruBufferEntries003 + * @tc.desc: Returns an array of key-value pairs of enumeratable properties of a given object. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferEntries003', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + var i=0; + var arr={}; + for (let entry of that.entries()) { + arr[i]=entry[0]; + i++; + arr[i]=entry[1]; + i++; + } + expect(arr[0]).assertEqual(1); + }) + + /** + * @tc.name: testLruBufferEntries004 + * @tc.desc: Returns an array of key-value pairs of enumeratable properties of a given object. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferEntries004', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + that.contains(1) + var i=0; + var arr={}; + for (let entry of that.entries()) { + arr[i]=entry[0]; + i++; + arr[i]=entry[1]; + i++; + } + expect(arr[1]).assertEqual(15) + expect(arr[3]).assertEqual(20) + }) + + /** + * @tc.name: testLruBufferEntries005 + * @tc.desc: Returns an array of key-value pairs of enumeratable properties of a given object. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferEntries005', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + that.remove(5) + that.contains(3) + that.get(1) + that.contains('abc') + var i=0; + var arr={}; + for (let entry of that.entries()) { + arr[i]=entry[0]; + i++; + arr[i]=entry[1]; + i++; + } + expect(arr[1]).assertEqual(10) + expect(arr[3]).assertEqual(2) + expect(arr[5]).assertEqual(20) + }) + + /** + * @tc.name: testLruBuffer[Symbol.iterator]001 + * @tc.desc: Returns a two - dimensional array in the form of key - value pairs. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBuffer[Symbol.iterator]001', 0, function () { + var that = new util.LruBuffer() + that.put('string','abc') + that.put('abc',20) + var i=0; + var arr={}; + for (let entry of that[Symbol.iterator]()) { + arr[i]=entry[0]; + i++; + arr[i]=entry[1]; + i++; + } + expect(arr[1]).assertEqual('abc'); + }) + + /** + * @tc.name: testLruBuffer[Symbol.iterator]002 + * @tc.desc: Returns a two - dimensional array in the form of key - value pairs. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBuffer[Symbol.iterator]002', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + var i=0; + var arr={}; + for (let entry of that[Symbol.iterator]()) { + arr[i]=entry[0]; + i++; + arr[i]=entry[1]; + i++; + } + expect(arr[1]).assertEqual(2); + }) + + /** + * @tc.name: testLruBuffer[Symbol.iterator]003 + * @tc.desc: Returns a two - dimensional array in the form of key - value pairs. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBuffer[Symbol.iterator]003', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + var i=0; + var arr={}; + for (let entry of that[Symbol.iterator]()) { + arr[i]=entry[0]; + i++; + arr[i]=entry[1]; + i++; + } + expect(arr[0]).assertEqual(1); + }) + + /** + * @tc.name: testLruBuffer[Symbol.iterator]004 + * @tc.desc: Returns a two - dimensional array in the form of key - value pairs. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBuffer[Symbol.iterator]004', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + that.contains(1) + var i=0; + var arr={}; + for (let entry of that[Symbol.iterator]()) { + arr[i]=entry[0]; + i++; + arr[i]=entry[1]; + i++; + } + expect(arr[1]).assertEqual(15) + expect(arr[3]).assertEqual(20) + }) + + /** + * @tc.name: testLruBuffer[Symbol.iterator]005 + * @tc.desc: Returns a two - dimensional array in the form of key - value pairs. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBuffer[Symbol.iterator]005', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(3,10) + that.put(5,15) + that.put('abc',20) + that.get(3) + that.remove(5) + that.contains(3) + that.get(1) + that.contains('abc') + var i=0; + var arr={}; + for (let entry of that[Symbol.iterator]()) { + arr[i]=entry[0]; + i++; + arr[i]=entry[1]; + i++; + } + expect(arr[1]).assertEqual(10) + expect(arr[3]).assertEqual(2) + expect(arr[5]).assertEqual(20) + }) + + /** + * @tc.name: testLruBufferAfterRemoval001 + * @tc.desc: Executes subsequent operations after a value is deleted. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferAfterRemoval001', 0, function () { + var arr = []; + class ChildLruBuffer extends util.LruBuffer + { + constructor() + { + super(); + } + static getInstance() + { + if(this.instance == null) + { + this.instance = new ChildLruBuffer(); + } + return this.instance; + } + afterRemoval(isEvict, key, value, newValue) + { + if (isEvict === false) + { + arr = [key, value, newValue]; + } + } + } + ChildLruBuffer.getInstance().afterRemoval(false,10,30,null) + expect(arr[0]).assertEqual(10) + }) + + /** + * @tc.name: testLruBufferAfterRemoval002 + * @tc.desc: Executes subsequent operations after a value is deleted. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferAfterRemoval002', 0, function () { + var arr = []; + class ChildLruBuffer extends util.LruBuffer + { + constructor() + { + super(); + } + static getInstance() + { + if(this.instance == null) + { + this.instance = new ChildLruBuffer(); + } + return this.instance; + } + afterRemoval(isEvict, key, value, newValue) + { + if (isEvict === false) + { + arr = [key, value, newValue]; + } + } + } + ChildLruBuffer.getInstance().afterRemoval(false,'string',10,null) + expect(arr[0]).assertEqual('string') + }) + + /** + * @tc.name: testLruBufferAfterRemoval003 + * @tc.desc: Executes subsequent operations after a value is deleted. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferAfterRemoval003', 0, function () { + var arr = []; + class ChildLruBuffer extends util.LruBuffer + { + constructor() + { + super(); + } + static getInstance() + { + if(this.instance == null) + { + this.instance = new ChildLruBuffer(); + } + return this.instance; + } + afterRemoval(isEvict, key, value, newValue) + { + if (isEvict === false) + { + arr = [key, value, newValue]; + } + } + } + ChildLruBuffer.getInstance().afterRemoval(false,10,30,12) + expect(arr[2]).assertEqual(12) + }) + + /** + * @tc.name: testLruBufferAfterRemoval004 + * @tc.desc: Executes subsequent operations after a value is deleted. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferAfterRemoval004', 0, function () { + var arr = []; + class ChildLruBuffer extends util.LruBuffer + { + constructor() + { + super(); + } + static getInstance() + { + if(this.instance == null) + { + this.instance = new ChildLruBuffer(); + } + return this.instance; + } + afterRemoval(isEvict, key, value, newValue) + { + if (isEvict === false) + { + arr = [key, value, newValue]; + } + } + } + ChildLruBuffer.getInstance().afterRemoval(false,'abc',30,'string') + expect(arr[1]).assertEqual(30) + }) + + /** + * @tc.name: testLruBufferAfterRemoval005 + * @tc.desc: Executes subsequent operations after a value is deleted. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferAfterRemoval005', 0, function () { + var arr = []; + class ChildLruBuffer extends util.LruBuffer + { + constructor() + { + super(); + } + static getInstance() + { + if(this.instance == null) + { + this.instance = new ChildLruBuffer(); + } + return this.instance; + } + afterRemoval(isEvict, key, value, newValue) + { + if (isEvict === true) + { + arr = [key, value, newValue]; + } + } + } + ChildLruBuffer.getInstance().afterRemoval(true,'abc','ab','string') + expect(arr[2]).assertEqual('string') + }) +}) + +describe('TypesTest', function() { + + /** + * @tc.name: testIsAnyArrayBuffer001 + * @tc.desc: Check whether the entered value is of arraybuffer or sharedarraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAnyArrayBuffer001', 0, function() { + var proc = new util.Types(); + var result = proc.isAnyArrayBuffer(new ArrayBuffer([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsAnyArrayBuffer002 + * @tc.desc: Check whether the entered value is of arraybuffer or sharedarraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAnyArrayBuffer002', 0, function() { + var proc = new util.Types(); + var result = proc.isAnyArrayBuffer(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsAnyArrayBuffer003 + * @tc.desc: Check whether the entered value is of arraybuffer or sharedarraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAnyArrayBuffer003', 0, function() { + var proc = new util.Types(); + var result = proc.isAnyArrayBuffer(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsAnyArrayBuffer004 + * @tc.desc: Check whether the entered value is of arraybuffer or sharedarraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAnyArrayBuffer004', 0, function() { + var proc = new util.Types(); + var buf = new ArrayBuffer(); + var result = proc.isAnyArrayBuffer(buf); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsAnyArrayBuffer005 + * @tc.desc: Check whether the entered value is of arraybuffer or sharedarraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAnyArrayBuffer005', 0, function() { + var proc = new util.Types(); + var result = proc.isAnyArrayBuffer(new Boolean(false)); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArrayBufferView001 + * @tc.desc: Check whether the entered value is napi_ int8_ array or napi_ uint8_ array + or naPi_ uint8_ clamped_ array or naPi_ int16_ array or naPi_ uint16_ array or napi_ int32_ array or napi_ + uint32_ array or napi_ float32_ array or napi_ float64_ array array or DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBufferView001', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBufferView(new Int8Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsArrayBufferView002 + * @tc.desc: Check whether the entered value is napi_ int8_ array or napi_ uint8_ array + or naPi_ uint8_ clamped_ array or naPi_ int16_ array or naPi_ uint16_ array or napi_ + int32_ array or napi_ uint32_ array or napi_ float32_ array or napi_ float64_ array array or DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBufferView002', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBufferView(new Int32Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsArrayBufferView003 + * @tc.desc: Check whether the entered value is napi_ int8_ array or napi_ uint8_ + array or naPi_ uint8_ clamped_ array or naPi_ int16_ array or naPi_ uint16_ array or napi_ int32_ array or + napi_ uint32_ array or napi_ float32_ array or napi_ float64_ array array or DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBufferView003', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBufferView(new DataView(new ArrayBuffer(16))); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsArrayBufferView004 + * @tc.desc: Check whether the entered value is napi_ int8_ array or napi_ uint8_ array or naPi_ uint8_ + clamped_ array or naPi_ int16_ array or naPi_ uint16_ array or napi_ int32_ array or napi_ uint32_ array or + napi_ float32_ array or napi_ float64_ array array or DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBufferView004', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBufferView(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArrayBufferView005 + * @tc.desc: Check whether the entered value is napi_ int8_ array or napi_ uint8_ array or naPi_ uint8_ + clamped_ array or naPi_ int16_ array or naPi_ uint16_ array or napi_ int32_ array or napi_ uint32_ array or + napi_ float32_ array or napi_ float64_ array array or DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBufferView005', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBufferView(new Int16Array()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsArgumentsObject001 + * @tc.desc: Check whether the entered value is an arguments object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArgumentsObject001', 0, function() { + var proc = new util.Types(); + function foo() { + var result = proc.isArgumentsObject(arguments); + expect(result).assertEqual(true); + } + var f = foo(); + }) + + /** + * @tc.name: testIsArgumentsObject002 + * @tc.desc: Check whether the entered value is an arguments object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArgumentsObject002', 0, function() { + var proc = new util.Types(); + var result = proc.isArgumentsObject(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArgumentsObject003 + * @tc.desc: Check whether the entered value is an arguments object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArgumentsObject003', 0, function() { + var proc = new util.Types(); + var result = proc.isArgumentsObject(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArgumentsObject004 + * @tc.desc: Check whether the entered value is an arguments object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArgumentsObject004', 0, function() { + var proc = new util.Types(); + var result = proc.isArgumentsObject(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArgumentsObject005 + * @tc.desc: Check whether the entered value is an arguments object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArgumentsObject005', 0, function() { + var proc = new util.Types(); + var result = proc.isArgumentsObject(new Boolean()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArrayBuffer001 + * @tc.desc: Check whether the entered value is of arraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBuffer001', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBuffer(new ArrayBuffer([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsArrayBuffer002 + * @tc.desc: Check whether the entered value is of arraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBuffer002', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBuffer(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArrayBuffer003 + * @tc.desc: Check whether the entered value is of arraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBuffer003', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBuffer(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArrayBuffer004 + * @tc.desc: Check whether the entered value is of arraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBuffer004', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBuffer(new Int8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArrayBuffer005 + * @tc.desc: Check whether the entered value is of arraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBuffer005', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBuffer(new Int16Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsAsyncFunction001 + * @tc.desc: Check whether the value entered is an asynchronous function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAsyncFunction001', 0, function() { + var proc = new util.Types(); + var result = proc.isAsyncFunction(async function foo() {}); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsAsyncFunction002 + * @tc.desc: Check whether the value entered is an asynchronous function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAsyncFunction002', 0, function() { + var proc = new util.Types(); + var result = proc.isAsyncFunction(function foo() {}); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsAsyncFunction003 + * @tc.desc: Check whether the value entered is an asynchronous function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAsyncFunction003', 0, function() { + var proc = new util.Types(); + var result = proc.isAsyncFunction(new Int8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsAsyncFunction004 + * @tc.desc: Check whether the value entered is an asynchronous function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAsyncFunction004', 0, function() { + var proc = new util.Types(); + var result = proc.isAsyncFunction(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsAsyncFunction005 + * @tc.desc: Check whether the value entered is an asynchronous function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAsyncFunction005', 0, function() { + var proc = new util.Types(); + var result = proc.isAsyncFunction(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBigInt64Array001 + * @tc.desc: Check whether the entered value is of bigint64array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBigInt64Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isBigInt64Array(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBigUint64Array001 + * @tc.desc: Check whether the entered value is of biguint64array array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBigUint64Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isBigUint64Array(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBooleanObject001 + * @tc.desc: Check whether the entered value is a Boolean object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBooleanObject001', 0, function() { + var proc = new util.Types(); + var result = proc.isBooleanObject(new Boolean(false)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsBooleanObject002 + * @tc.desc: Check whether the entered value is a Boolean object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBooleanObject002', 0, function() { + var proc = new util.Types(); + var result = proc.isBooleanObject(new Boolean(true)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsBooleanObject003 + * @tc.desc: Check whether the entered value is a Boolean object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBooleanObject003', 0, function() { + var proc = new util.Types(); + var result = proc.isBooleanObject(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBooleanObject004 + * @tc.desc: Check whether the entered value is a Boolean object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBooleanObject004', 0, function() { + var proc = new util.Types(); + var result = proc.isBooleanObject(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBooleanObject005 + * @tc.desc: Check whether the entered value is a Boolean object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBooleanObject005', 0, function() { + var proc = new util.Types(); + var result = proc.isBooleanObject(Boolean(true)); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBoxedPrimitive001 + * @tc.desc: Check whether the entered value is a Boolean or number or string or symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBoxedPrimitive001', 0, function() { + var proc = new util.Types(); + var result = proc.isBoxedPrimitive(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBoxedPrimitive002 + * @tc.desc: Check whether the entered value is a Boolean or number or string or symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBoxedPrimitive002', 0, function() { + var proc = new util.Types(); + var result = proc.isBoxedPrimitive(new Boolean(false)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsBoxedPrimitive003 + * @tc.desc: Check whether the entered value is a Boolean or number or string or symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBoxedPrimitive003', 0, function() { + var proc = new util.Types(); + var result = proc.isBoxedPrimitive(Symbol('foo')); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBoxedPrimitive004 + * @tc.desc: Check whether the entered value is a Boolean or number or string or symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBoxedPrimitive004', 0, function() { + var proc = new util.Types(); + var result = proc.isBoxedPrimitive(Object(Symbol('foo'))); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsBoxedPrimitive005 + * @tc.desc: Check whether the entered value is a Boolean or number or string or symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBoxedPrimitive005', 0, function() { + var proc = new util.Types(); + var result = proc.isBoxedPrimitive(new Boolean(true)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsDataView001 + * @tc.desc: Check whether the entered value is of DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDataView001', 0, function() { + var proc = new util.Types(); + const ab = new ArrayBuffer(20); + var result = proc.isDataView(new DataView(ab)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsDataView002 + * @tc.desc: Check whether the entered value is of DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDataView002', 0, function() { + var proc = new util.Types(); + var result = proc.isDataView(new Int8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsDataView003 + * @tc.desc: Check whether the entered value is of DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDataView003', 0, function() { + var proc = new util.Types(); + var result = proc.isDataView(new Float64Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsDataView004 + * @tc.desc: Check whether the entered value is of DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDataView004', 0, function() { + var proc = new util.Types(); + var result = proc.isDataView(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsDataView005 + * @tc.desc: Check whether the entered value is of DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDataView005', 0, function() { + var proc = new util.Types(); + var result = proc.isDataView(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsDate001 + * @tc.desc: Check whether the entered value is of type date. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDate001', 0, function() { + var proc = new util.Types(); + var result = proc.isDate(new Date()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsDate002 + * @tc.desc: Check whether the entered value is of type date. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDate002', 0, function() { + var proc = new util.Types(); + var result = proc.isDate(new Int8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsDate003 + * @tc.desc: Check whether the entered value is of type date. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDate003', 0, function() { + var proc = new util.Types(); + var result = proc.isDate(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsDate004 + * @tc.desc: Check whether the entered value is of type date. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDate004', 0, function() { + var proc = new util.Types(); + var result = proc.isDate(new Int16Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsDate005 + * @tc.desc: Check whether the entered value is of type date. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDate005', 0, function() { + var proc = new util.Types(); + var result = proc.isDate(new Float64Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsExternal001 + * @tc.desc: Check whether the entered value is a native external value type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsExternal001', 0, function() { + var proc = new util.Types(); + const data = util.createExternalType(); + var result = proc.isExternal(data); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsExternal002 + * @tc.desc: Check whether the entered value is a native external value type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsExternal002', 0, function() { + var proc = new util.Types(); + var result = proc.isExternal(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsExternal003 + * @tc.desc: Check whether the entered value is a native external value type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsExternal003', 0, function() { + var proc = new util.Types(); + var result = proc.isExternal(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsExternal004 + * @tc.desc: Check whether the entered value is a native external value type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsExternal004', 0, function() { + var proc = new util.Types(); + var result = proc.isExternal(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsExternal005 + * @tc.desc: Check whether the entered value is a native external value type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsExternal005', 0, function() { + var proc = new util.Types(); + var result = proc.isExternal(new Int16Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat32Array001 + * @tc.desc: Check whether the entered value is of float32array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat32Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat32Array(new Float32Array()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsFloat32Array002 + * @tc.desc: Check whether the entered value is of float32array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat32Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat32Array(new Int8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat32Array003 + * @tc.desc: Check whether the entered value is of float32array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat32Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat32Array(new Int16Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat32Array004 + * @tc.desc: Check whether the entered value is of float32array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat32Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat32Array(new Float64Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat32Array005 + * @tc.desc: Check whether the entered value is of float32array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat32Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat32Array(new Uint8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat64Array001 + * @tc.desc: Check whether the entered value is of float64array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat64Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat64Array(new Float64Array()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsFloat64Array002 + * @tc.desc: Check whether the entered value is of float64array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat64Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat64Array(new Int8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat64Array003 + * @tc.desc: Check whether the entered value is of float64array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat64Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat64Array(new Float32Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat64Array004 + * @tc.desc: Check whether the entered value is of float64array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat64Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat64Array(new Uint8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat64Array005 + * @tc.desc: Check whether the entered value is of float64array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat64Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat64Array(new Int16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorFunction001 + * @tc.desc: Check whether the input value is a generator function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsGeneratorFunction001', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorFunction(function* foo() {}); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsGeneratorFunction002 + * @tc.desc: Check whether the input value is a generator function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsGeneratorFunction002', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorFunction(function foo() {}); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorFunction003 + * @tc.desc: Check whether the input value is a generator function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsGeneratorFunction003', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorFunction(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorFunction004 + * @tc.desc: Check whether the input value is a generator function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsGeneratorFunction004', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorFunction(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorFunction005 + * @tc.desc: Check whether the input value is a generator function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsGeneratorFunction005', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorFunction(new Int8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorObject001 + * @tc.desc: Check whether the entered value is a generator object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsGeneratorObject001', 0, function() { + var proc = new util.Types(); + function* foo() {} + const generator = foo(); + var result = proc.isGeneratorObject(generator); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsGeneratorObject002 + * @tc.desc: Check whether the entered value is a generator object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsGeneratorObject002', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorObject(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorObject003 + * @tc.desc: Check whether the entered value is a generator object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsGeneratorObject003', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorObject(new Int16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorObject004 + * @tc.desc: Check whether the entered value is a generator object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsGeneratorObject004', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorObject(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorObject005 + * @tc.desc: Check whether the entered value is a generator object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsGeneratorObject005', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorObject(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt8Array001 + * @tc.desc: Check whether the entered value is of int8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt8Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isInt8Array(new Int8Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsInt8Array002 + * @tc.desc: Check whether the entered value is of int8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt8Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isInt8Array(new ArrayBuffer([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt8Array003 + * @tc.desc: Check whether the entered value is of int8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt8Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isInt8Array(new Int32Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt8Array004 + * @tc.desc: Check whether the entered value is of int8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt8Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isInt8Array(new Float64Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt8Array005 + * @tc.desc: Check whether the entered value is of int8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt8Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isInt8Array(new Uint8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt16Array001 + * @tc.desc: Check whether the entered value is the int16array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt16Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isInt16Array(new Int16Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsInt16Array002 + * @tc.desc: Check whether the entered value is the int16array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt16Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isInt16Array(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt16Array003 + * @tc.desc: Check whether the entered value is the int16array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt16Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isInt16Array(new Int32Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt16Array004 + * @tc.desc: Check whether the entered value is the int16array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt16Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isInt16Array(new Uint8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt16Array005 + * @tc.desc: Check whether the entered value is the int16array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt16Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isInt16Array(new Float64Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt32Array001 + * @tc.desc: Check whether the entered value is the int32array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt32Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isInt32Array(new Int32Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsInt32Array002 + * @tc.desc: Check whether the entered value is the int32array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt32Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isInt32Array(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt32Array003 + * @tc.desc: Check whether the entered value is the int32array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt32Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isInt32Array(new Int16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt32Array004 + * @tc.desc: Check whether the entered value is the int32array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt32Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isInt32Array(new Float64Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt32Array005 + * @tc.desc: Check whether the entered value is the int32array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt32Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isInt32Array(new Uint8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsMap001 + * @tc.desc: Check whether the entered value is of map type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMap001', 0, function() { + var proc = new util.Types(); + var result = proc.isMap(new Map()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsMap002 + * @tc.desc: Check whether the entered value is of map type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMap002', 0, function() { + var proc = new util.Types(); + var result = proc.isMap(new Set()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsMap003 + * @tc.desc: Check whether the entered value is of map type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMap003', 0, function() { + var proc = new util.Types(); + var result = proc.isMap(new String()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsMap004 + * @tc.desc: Check whether the entered value is of map type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMap004', 0, function() { + var proc = new util.Types(); + var result = proc.isMap(new Object()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsMap005 + * @tc.desc: Check whether the entered value is of map type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMap005', 0, function() { + var proc = new util.Types(); + var result = proc.isMap(new Boolean()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsMapIterator001 + * @tc.desc: Check whether the entered value is the iterator type of map. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMapIterator001', 0, function() { + var proc = new util.Types(); + const map = new Map(); + var result = proc.isMapIterator(map.keys()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsMapIterator002 + * @tc.desc: Check whether the entered value is the iterator type of map. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMapIterator002', 0, function() { + var proc = new util.Types(); + const map = new Map(); + var result = proc.isMapIterator(map.values()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsMapIterator003 + * @tc.desc: Check whether the entered value is the iterator type of map. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMapIterator003', 0, function() { + var proc = new util.Types(); + const map = new Map(); + var result = proc.isMapIterator(map.entries()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsMapIterator004 + * @tc.desc: Check whether the entered value is the iterator type of map. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMapIterator004', 0, function() { + var proc = new util.Types(); + const map = new Map(); + var result = proc.isMapIterator(map[Symbol.iterator]()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsMapIterator005 + * @tc.desc: Check whether the entered value is the iterator type of map. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMapIterator005', 0, function() { + var proc = new util.Types(); + const map = new Map(); + var result = proc.isMapIterator(map); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsModuleNamespaceObject001 + * @tc.desc: Check whether the entered value is the module namespace object object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsModuleNamespaceObject001', 0, function() { + var proc = new util.Types(); + var result = proc.isModuleNamespaceObject(util); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsModuleNamespaceObject002 + * @tc.desc: Check whether the entered value is the module namespace object object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsModuleNamespaceObject002', 0, function() { + var proc = new util.Types(); + var result = proc.isModuleNamespaceObject(url); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsModuleNamespaceObject003 + * @tc.desc: Check whether the entered value is the module namespace object object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsModuleNamespaceObject003', 0, function() { + var proc = new util.Types(); + var result = proc.isModuleNamespaceObject(file); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsModuleNamespaceObject004 + * @tc.desc: Check whether the entered value is the module namespace object object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsModuleNamespaceObject004', 0, function() { + var proc = new util.Types(); + var result = proc.isModuleNamespaceObject(process); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsModuleNamespaceObject005 + * @tc.desc: Check whether the entered value is the module namespace object object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsModuleNamespaceObject005', 0, function() { + var proc = new util.Types(); + var result = proc.isModuleNamespaceObject(app); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsNativeError001 + * @tc.desc: Check whether the value entered is of type error. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNativeError001', 0, function() { + var proc = new util.Types(); + var result = proc.isNativeError(new TypeError()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsNativeError002 + * @tc.desc: Check whether the value entered is of type error. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNativeError002', 0, function() { + var proc = new util.Types(); + var result = proc.isNativeError(new Error()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsNativeError003 + * @tc.desc: Check whether the value entered is of type error. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNativeError003', 0, function() { + var proc = new util.Types(); + var result = proc.isNativeError(new RangeError()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsNativeError004 + * @tc.desc: Check whether the value entered is of type error. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNativeError004', 0, function() { + var proc = new util.Types(); + var result = proc.isNativeError(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsNativeError005 + * @tc.desc: Check whether the value entered is of type error. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNativeError005', 0, function() { + var proc = new util.Types(); + var result = proc.isNativeError(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsNumberObject001 + * @tc.desc: Check whether the entered value is of the number object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNumberObject001', 0, function() { + var proc = new util.Types(); + var result = proc.isNumberObject(new Number(0)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsNumberObject002 + * @tc.desc: Check whether the entered value is of the number object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNumberObject002', 0, function() { + var proc = new util.Types(); + var result = proc.isNumberObject(new Number(10)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsNumberObject003 + * @tc.desc: Check whether the entered value is of the number object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNumberObject003', 0, function() { + var proc = new util.Types(); + var result = proc.isNumberObject(new Number(200)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsNumberObject004 + * @tc.desc: Check whether the entered value is of the number object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNumberObject004', 0, function() { + var proc = new util.Types(); + var result = proc.isNumberObject(0); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsNumberObject005 + * @tc.desc: Check whether the entered value is of the number object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNumberObject005', 0, function() { + var proc = new util.Types(); + var result = proc.isNumberObject(100); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsPromise001 + * @tc.desc: Check whether the entered value is of promise type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsPromise001', 0, function() { + var proc = new util.Types(); + var result = proc.isPromise(Promise.resolve(42)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsPromise002 + * @tc.desc: Check whether the entered value is of promise type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsPromise002', 0, function() { + var proc = new util.Types(); + var result = proc.isPromise(Promise.resolve(33)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsPromise003 + * @tc.desc: Check whether the entered value is of promise type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsPromise003', 0, function() { + var proc = new util.Types(); + var result = proc.isPromise(Promise.resolve(44)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsPromise004 + * @tc.desc: Check whether the entered value is of promise type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsPromise004', 0, function() { + var proc = new util.Types(); + var err = Error(33); + var result = proc.isPromise(Promise.reject(err)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsPromise005 + * @tc.desc: Check whether the entered value is of promise type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsPromise005', 0, function() { + var proc = new util.Types(); + var err = Error(23); + var result = proc.isPromise(Promise.reject(err)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsProxy001 + * @tc.desc: Check whether the value entered is of proxy type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsProxy001', 0, function() { + var proc = new util.Types(); + const target = {}; + const proxy = new Proxy(target, {}); + var result = proc.isProxy(proxy); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsProxy002 + * @tc.desc: Check whether the value entered is of proxy type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsProxy002', 0, function() { + var proc = new util.Types(); + const target = {}; + const proxy = new Proxy(target, {}); + var result = proc.isProxy(target); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsProxy003 + * @tc.desc: Check whether the value entered is of proxy type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsProxy003', 0, function() { + var proc = new util.Types(); + const handler = { + get: function(obj, prop) { + return prop in obj ? obj[prop] : 37; + } + }; + const p = new Proxy({}, handler); + var result = proc.isProxy(p); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsProxy004 + * @tc.desc: Check whether the value entered is of proxy type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsProxy004', 0, function() { + var proc = new util.Types(); + const handler = { + get: function(obj, prop) { + return prop in obj ? obj[prop] : 121; + } + }; + const p = new Proxy({}, handler); + var result = proc.isProxy(p); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsProxy005 + * @tc.desc: Check whether the value entered is of proxy type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsProxy005', 0, function() { + var proc = new util.Types(); + const handler = { + get: function(obj, prop) { + return prop in obj ? obj[prop] : 121; + } + }; + const p = new Proxy({}, handler); + var result = proc.isProxy(handler); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsRegExp001 + * @tc.desc: Check whether the entered value is of type regexp. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsRegExp001', 0, function() { + var proc = new util.Types(); + var result = proc.isRegExp(new RegExp('abc')); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsRegExp002 + * @tc.desc: Check whether the entered value is of type regexp. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsRegExp002', 0, function() { + var proc = new util.Types(); + var result = proc.isRegExp(/abc/); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsRegExp003 + * @tc.desc: Check whether the entered value is of type regexp. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsRegExp003', 0, function() { + var proc = new util.Types(); + var result = proc.isRegExp(new RegExp('fgd')); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsRegExp004 + * @tc.desc: Check whether the entered value is of type regexp. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsRegExp004', 0, function() { + var proc = new util.Types(); + var result = proc.isRegExp(new RegExp('123')); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsRegExp005 + * @tc.desc: Check whether the entered value is of type regexp. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsRegExp005', 0, function() { + var proc = new util.Types(); + var result = proc.isRegExp(new RegExp(/ab+c/, 'i')); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSet001 + * @tc.desc: Check whether the entered value is of type set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSet001', 0, function() { + var proc = new util.Types(); + var result = proc.isSet(new Set()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSet002 + * @tc.desc: Check whether the entered value is of type set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSet002', 0, function() { + var proc = new util.Types(); + var result = proc.isSet(new Map()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSet003 + * @tc.desc: Check whether the entered value is of type set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSet003', 0, function() { + var proc = new util.Types(); + var result = proc.isSet(new String()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSet004 + * @tc.desc: Check whether the entered value is of type set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSet004', 0, function() { + var proc = new util.Types(); + var result = proc.isSet(new Boolean()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSet005 + * @tc.desc: Check whether the entered value is of type set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSet005', 0, function() { + var proc = new util.Types(); + var result = proc.isSet(new WeakSet()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSetIterator001 + * @tc.desc: Check whether the entered value is the iterator type of set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSetIterator001', 0, function() { + var proc = new util.Types(); + const set = new Set(); + var result = proc.isSetIterator(set.keys()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSetIterator002 + * @tc.desc: Check whether the entered value is the iterator type of set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSetIterator002', 0, function() { + var proc = new util.Types(); + const set = new Set(); + var result = proc.isSetIterator(set.values()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSetIterator003 + * @tc.desc: Check whether the entered value is the iterator type of set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSetIterator003', 0, function() { + var proc = new util.Types(); + const set = new Set(); + var result = proc.isSetIterator(set.entries()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSetIterator004 + * @tc.desc: Check whether the entered value is the iterator type of set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSetIterator004', 0, function() { + var proc = new util.Types(); + const set = new Set(); + var result = proc.isSetIterator(set[Symbol.iterator]()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSetIterator005 + * @tc.desc: Check whether the entered value is the iterator type of set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSetIterator005', 0, function() { + var proc = new util.Types(); + const set = new Set(); + var result = proc.isSetIterator(set); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSharedArrayBuffer001 + * @tc.desc: Check whether the entered value is of type sharedarraybuffer. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSharedArrayBuffer001', 0, function() { + var proc = new util.Types(); + var result = proc.isSharedArrayBuffer(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSharedArrayBuffer002 + * @tc.desc: Check whether the entered value is of type sharedarraybuffer. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSharedArrayBuffer002', 0, function() { + var proc = new util.Types(); + var result = proc.isSharedArrayBuffer(new Int16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSharedArrayBuffer003 + * @tc.desc: Check whether the entered value is of type sharedarraybuffer. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSharedArrayBuffer003', 0, function() { + var proc = new util.Types(); + var result = proc.isSharedArrayBuffer(new Int32Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSharedArrayBuffer004 + * @tc.desc: Check whether the entered value is of type sharedarraybuffer. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSharedArrayBuffer004', 0, function() { + var proc = new util.Types(); + var result = proc.isSharedArrayBuffer(new ArrayBuffer([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSharedArrayBuffer005 + * @tc.desc: Check whether the entered value is of type sharedarraybuffer. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSharedArrayBuffer005', 0, function() { + var proc = new util.Types(); + var result = proc.isSharedArrayBuffer(new Uint8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsStringObject001 + * @tc.desc: Check whether the entered value is a string object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsStringObject001', 0, function() { + var proc = new util.Types(); + var result = proc.isStringObject(new String('foo')); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsStringObject002 + * @tc.desc: Check whether the entered value is a string object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsStringObject002', 0, function() { + var proc = new util.Types(); + var result = proc.isStringObject(new String('twoo')); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsStringObject003 + * @tc.desc: Check whether the entered value is a string object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsStringObject003', 0, function() { + var proc = new util.Types(); + var result = proc.isStringObject(new String('fdfsfd')); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsStringObject004 + * @tc.desc: Check whether the entered value is a string object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsStringObject004', 0, function() { + var proc = new util.Types(); + var result = proc.isStringObject('ffds111'); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsStringObject005 + * @tc.desc: Check whether the entered value is a string object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsStringObject005', 0, function() { + var proc = new util.Types(); + var result = proc.isStringObject('foo'); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSymbolObject001 + * @tc.desc: Check whether the entered value is a symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSymbolObject001', 0, function() { + var proc = new util.Types(); + const symbols = Symbol('foo'); + var result = proc.isSymbolObject(Object(symbols)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSymbolObject002 + * @tc.desc: Check whether the entered value is a symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSymbolObject002', 0, function() { + var proc = new util.Types(); + const symbols = Symbol('s12'); + var result = proc.isSymbolObject(Object(symbols)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSymbolObject003 + * @tc.desc: Check whether the entered value is a symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSymbolObject003', 0, function() { + var proc = new util.Types(); + const symbols = Symbol('sads'); + var result = proc.isSymbolObject(Object(symbols)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSymbolObject004 + * @tc.desc: Check whether the entered value is a symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSymbolObject004', 0, function() { + var proc = new util.Types(); + const symbols = Symbol('asdd'); + var result = proc.isSymbolObject(symbols); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSymbolObject005 + * @tc.desc: Check whether the entered value is a symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSymbolObject005', 0, function() { + var proc = new util.Types(); + const symbols = Symbol('foo'); + var result = proc.isSymbolObject(symbols); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsTypedArray001 + * @tc.desc: Check whether the entered value is a type contained in typedarray. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsTypedArray001', 0, function() { + var proc = new util.Types(); + var result = proc.isTypedArray(new Float64Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsTypedArray002 + * @tc.desc: Check whether the entered value is a type contained in typedarray. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsTypedArray002', 0, function() { + var proc = new util.Types(); + var result = proc.isTypedArray(new Uint8Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsTypedArray003 + * @tc.desc: Check whether the entered value is a type contained in typedarray. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsTypedArray003', 0, function() { + var proc = new util.Types(); + var result = proc.isTypedArray(new Uint16Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsTypedArray004 + * @tc.desc: Check whether the entered value is a type contained in typedarray. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsTypedArray004', 0, function() { + var proc = new util.Types(); + var result = proc.isTypedArray(new Uint32Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsTypedArray005 + * @tc.desc: Check whether the entered value is a type contained in typedarray. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsTypedArray005', 0, function() { + var proc = new util.Types(); + var result = proc.isTypedArray(new ArrayBuffer()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8Array001 + * @tc.desc: Check whether the entered value is the uint8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8Array(new Uint8Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsUint8Array002 + * @tc.desc: Check whether the entered value is the uint8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8Array(new Uint16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8Array003 + * @tc.desc: Check whether the entered value is the uint8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8Array(new Uint32Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8Array004 + * @tc.desc: Check whether the entered value is the uint8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8Array(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8Array005 + * @tc.desc: Check whether the entered value is the uint8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8Array(new Int16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8ClampedArray001 + * @tc.desc: Check whether the entered value is the uint8clapedarray array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8ClampedArray001', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8ClampedArray(new Uint8ClampedArray([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsUint8ClampedArray002 + * @tc.desc: Check whether the entered value is the uint8clapedarray array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8ClampedArray002', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8ClampedArray(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8ClampedArray003 + * @tc.desc: Check whether the entered value is the uint8clapedarray array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8ClampedArray003', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8ClampedArray(new Int16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8ClampedArray004 + * @tc.desc: Check whether the entered value is the uint8clapedarray array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8ClampedArray004', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8ClampedArray(new Int32Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8ClampedArray005 + * @tc.desc: Check whether the entered value is the uint8clapedarray array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8ClampedArray005', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8ClampedArray(new Uint32Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint16Array001 + * @tc.desc: Check whether the entered value is the uint16array array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint16Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isUint16Array(new Uint16Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsUint16Array002 + * @tc.desc: Check whether the entered value is the uint16array array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint16Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isUint16Array(new Uint8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint16Array003 + * @tc.desc: Check whether the entered value is the uint16array array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint16Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isUint16Array(new Uint32Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint16Array004 + * @tc.desc: Check whether the entered value is the uint16array array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint16Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isUint16Array(new Uint8ClampedArray([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint16Array005 + * @tc.desc: Check whether the entered value is the uint16array array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint16Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isUint16Array(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint32Array001 + * @tc.desc: Check whether the entered value is the uint32array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint32Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isUint32Array(new Uint32Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsUint32Array002 + * @tc.desc: Check whether the entered value is the uint32array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint32Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isUint32Array(new Uint8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint32Array003 + * @tc.desc: Check whether the entered value is the uint32array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint32Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isUint32Array(new Uint16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint32Array004 + * @tc.desc: Check whether the entered value is the uint32array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint32Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isUint32Array(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint32Array005 + * @tc.desc: Check whether the entered value is the uint32array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint32Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isUint32Array(new Uint8ClampedArray([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakMap001 + * @tc.desc: Check whether the entered value is of type weakmap. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakMap001', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakMap(new WeakMap()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsWeakMap002 + * @tc.desc: Check whether the entered value is of type weakmap. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakMap002', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakMap(new Map()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakMap003 + * @tc.desc: Check whether the entered value is of type weakmap. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakMap003', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakMap(new Set()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakMap004 + * @tc.desc: Check whether the entered value is of type weakmap. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakMap004', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakMap(new String()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakMap005 + * @tc.desc: Check whether the entered value is of type weakmap. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakMap005', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakMap(new WeakSet()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakSet001 + * @tc.desc: Check whether the entered value is of type weakset. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakSet001', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakSet(new WeakSet()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsWeakSet002 + * @tc.desc: Check whether the entered value is of type weakset. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakSet002', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakSet(new WeakMap()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakSet003 + * @tc.desc: Check whether the entered value is of type weakset. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakSet003', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakSet(new String()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakSet004 + * @tc.desc: Check whether the entered value is of type weakset. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakSet004', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakSet(new Set()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakSet005 + * @tc.desc: Check whether the entered value is of type weakset. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakSet005', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakSet(new Map()); + expect(result).assertEqual(false); + }) +}) diff --git a/compileruntime/util_lib_standard/src/main/js/test/TextCodr.test.js b/compileruntime/util_lib_standard/src/main/js/test/util.test.js.bak similarity index 57% rename from compileruntime/util_lib_standard/src/main/js/test/TextCodr.test.js rename to compileruntime/util_lib_standard/src/main/js/test/util.test.js.bak index 2910e1f2c3437810e7034b552d7ed5070918a9a0..b46e407cfb31b3c3360b509587c61344e2808900 100644 --- a/compileruntime/util_lib_standard/src/main/js/test/TextCodr.test.js +++ b/compileruntime/util_lib_standard/src/main/js/test/util.test.js.bak @@ -1,20 +1,23 @@ /* -* Copyright (C) 2021 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the 'License'); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an 'AS IS' BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License') + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite' import util from '@ohos.util' +import url from '@ohos.url' +import app from '@system.app' +import process from '@ohos.process' +import file from '@system.file'; class Temperature { constructor(value) { @@ -178,7 +181,7 @@ describe('TextEncoderTest', function () { /** * @tc.name: testUtilPromiseWrapper001 * @tc.desc: Takes a function following the common error-first callback style, - * taking an callback as the last argument, and return a version that returns promises. + taking an callback as the last argument, and return a version that returns promises. * @tc.require: AR000GFB4U * @tc.author: shikai */ @@ -199,7 +202,7 @@ describe('TextEncoderTest', function () { /** * @tc.name: testUtilPromiseWrapper002 * @tc.desc: Takes a function following the common error-first callback style, - * taking an callback as the last argument, and return a version that returns promises. + taking an callback as the last argument, and return a version that returns promises. * @tc.require: AR000GFB4U * @tc.author: shikai */ @@ -220,22 +223,20 @@ describe('TextEncoderTest', function () { /** * @tc.name: testUtilPromiseWrapper003 * @tc.desc: Takes a function following the common error-first callback style, - * taking an callback as the last argument, and return a version that returns promises. + taking an callback as the last argument, and return a version that returns promises. * @tc.require: AR000GFB4U * @tc.author: shikai */ it('testUtilPromiseWrapper003', 0, async function () { - const a = util.promiseWrapper(function() {})(); - const b = util.promiseWrapper(function() {})(); - expect(a).assertInstanceOf('Promise'); - expect(b).assertInstanceOf('Promise'); - + const a = util.promiseWrapper(function() {}); + const b = util.promiseWrapper(a); + expect(a).strictEqual(b); }) /** * @tc.name: testUtilPromiseWrapper004 * @tc.desc: Takes a function following the common error-first callback style, - * taking an callback as the last argument, and return a version that returns promises. + taking an callback as the last argument, and return a version that returns promises. * @tc.require: AR000GFB4U * @tc.author: shikai */ @@ -253,7 +254,7 @@ describe('TextEncoderTest', function () { /** * @tc.name: testUtilPromiseWrapper005 * @tc.desc: Takes a function following the common error-first callback style, - * taking an callback as the last argument, and return a version that returns promises. + taking an callback as the last argument, and return a version that returns promises. * @tc.require: AR000GFB4U * @tc.author: shikai */ @@ -274,7 +275,7 @@ describe('TextEncoderTest', function () { /** * @tc.name: testUtilPromiseWrapper006 * @tc.desc: Takes a function following the common error-first callback style, - * taking an callback as the last argument, and return a version that returns promises. + taking an callback as the last argument, and return a version that returns promises. * @tc.require: AR000GFB4U * @tc.author: shikai */ @@ -295,7 +296,7 @@ describe('TextEncoderTest', function () { /** * @tc.name: testUtilPromiseWrapper007 * @tc.desc: Takes a function following the common error-first callback style, - * taking an callback as the last argument, and return a version that returns promises. + taking an callback as the last argument, and return a version that returns promises. * @tc.require: AR000GFB4U * @tc.author: shikai */ @@ -311,8 +312,8 @@ describe('TextEncoderTest', function () { /** * @tc.name: testUtilCallbackWrapper001 - * @tc.desc: Takes an async function (or a function that returns a Promise) - * and returns a function following the error-first callback style. + * @tc.desc: Takes an async function (or a function that returns a Promise) and + returns a function following the error-first callback style. * @tc.require: AR000GFB4U * @tc.author: shikai */ @@ -321,23 +322,21 @@ describe('TextEncoderTest', function () { try { util.callbackWrapper(promiseFn); } catch(e) { - console.info('util_callbackWrapper_test_001 ' + e.message) - expect(e.message).assertEqual('original is not function'); + expect(e.message).strictEqual('original is not function'); } }) - /** * @tc.name: testUtilCallbackWrapper002 - * @tc.desc: Takes an async function (or a function that returns a Promise) - * and returns a function following the error-first callback style. + * @tc.desc: Takes an async function (or a function that returns a Promise) and + returns a function following the error-first callback style. * @tc.require: AR000GFB4U * @tc.author: shikai */ it('testUtilCallbackWrapper002', 0, async function () { async function promiseFn() { return Promise.resolve('value'); - }; + } var cb = util.callbackWrapper(promiseFn); cb((err, ret) => { expect(err).strictEqual(null); @@ -347,15 +346,15 @@ describe('TextEncoderTest', function () { /** * @tc.name: testUtilCallbackWrapper003 - * @tc.desc: Takes an async function (or a function that returns a Promise) - * and returns a function following the error-first callback style. + * @tc.desc: Takes an async function (or a function that returns a Promise) and + returns a function following the error-first callback style. * @tc.require: AR000GFB4U * @tc.author: shikai */ it('testUtilCallbackWrapper003', 0, async function () { async function promiseFn() { return 42; - }; + } var cb = util.callbackWrapper(promiseFn); cb((err, ret) => { expect(err).strictEqual(null); @@ -365,63 +364,61 @@ describe('TextEncoderTest', function () { /** * @tc.name: testUtilCallbackWrapper004 - * @tc.desc: Takes an async function (or a function that returns a Promise) - * and returns a function following the error-first callback style. + * @tc.desc: Takes an async function (or a function that returns a Promise) and + returns a function following the error-first callback style. * @tc.require: AR000GFB4U * @tc.author: shikai */ it('testUtilCallbackWrapper004', 0, async function () { async function promiseFn() { - return Promise.reject('value'); - }; + var err = Error('value'); + return Promise.reject(err); + + } var cb = util.callbackWrapper(promiseFn); cb((err, ret) => { - expect(err).strictEqual('value'); + expect(err.message).strictEqual('value'); expect(ret).strictEqual(undefined); }) }) /** * @tc.name: testUtilCallbackWrapper005 - * @tc.desc: Takes an async function (or a function that returns a Promise) - * and returns a function following the error-first callback style. + * @tc.desc: Takes an async function (or a function that returns a Promise) and + returns a function following the error-first callback style. * @tc.require: AR000GFB4U * @tc.author: shikai */ - it('testUtilCallbackWrapper005', 0, async function (done) { + it('testUtilCallbackWrapper005', 0, async function () { async function promiseFn(a, b) { return a + b; - }; + } var cb = util.callbackWrapper(promiseFn); cb(1, 2, (err, ret) => { - expect(err).assertEqual(null); - expect(ret).assertEqual(3); - done() + expect(err).strictEqual(null); + expect(ret).strictEqual(3); }) }) /** * @tc.name: testUtilCallbackWrapper006 - * @tc.desc: Takes an async function (or a function that returns a Promise) - * and returns a function following the error-first callback style. + * @tc.desc: Takes an async function (or a function that returns a Promise) and + returns a function following the error-first callback style. * @tc.require: AR000GFB4U * @tc.author: shikai */ it('testUtilCallbackWrapper006', 0, async function () { - async function promiseFn(a, b) { - return a + b; - }; + async function promiseFn(){ + return null; + } + var cb = util.callbackWrapper(promiseFn); try { - var cb = util.callbackWrapper(promiseFn); cb([1, 2]) - console.info('') } catch(err) { - console.info('util_callbackWrapper_test_006 ' + err.message) - expect(err.message).assertEqual('maybe is not function'); + expect(err.message).strictEqual('maybe is not function'); } }) - /** * @tc.name: testEncoding001 * @tc.desc: The source encoding's name, lowercased. @@ -959,170 +956,173 @@ describe('TextEncoderTest', function () { expect(result.read).assertEqual(0) expect(result.written).assertEqual(0) }) +}) + +describe('ScopeTest', function () { - * @tc.name: testGetLower001 - * @tc.desc: Obtains the lower bound of the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + /** + * @tc.name: testGetLower001 + * @tc.desc: Obtains the lower bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testGetLower001', 0, function () { var result = range.getLower() - console.info('test result =' + result) - expect(+result).assertEqual(30) + expect(result).assertEqual(30) }) /** - * @tc.name: testGetLower002 - * @tc.desc: Obtains the lower bound of the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testGetLower002 + * @tc.desc: Obtains the lower bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testGetLower002', 0, function () { var result = rangeFir.getLower() - expect(+result).assertEqual(35) + expect(result).assertEqual(35) }) /** - * @tc.name: testGetLower003 - * @tc.desc: Obtains the lower bound of the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testGetLower003 + * @tc.desc: Obtains the lower bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testGetLower003', 0, function () { var result = rangeSec.getLower() - expect(+result).assertEqual(20) + expect(result).assertEqual(20) }) /** - * @tc.name: testGetLower004 - * @tc.desc: Obtains the lower bound of the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testGetLower004 + * @tc.desc: Obtains the lower bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testGetLower004', 0, function () { var result = rangeThi.getLower() - expect(+result).assertEqual(20) + expect(result).assertEqual(20) }) /** - * @tc.name: testGetLower005 - * @tc.desc: Obtains the lower bound of the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testGetLower005 + * @tc.desc: Obtains the lower bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testGetLower005', 0, function () { var result = rangeFif.getLower() - expect(+result).assertEqual(35) + expect(result).assertEqual(35) }) /** - * @tc.name: testGetUpper001 - * @tc.desc: Obtains the upper bound of the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testGetUpper001 + * @tc.desc: Obtains the upper bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testGetUpper001', 0, function () { var result = range.getUpper() - expect(+result).assertEqual(40) + expect(result).assertEqual(40) }) /** - * @tc.name: testGetUpper002 - * @tc.desc: Obtains the upper bound of the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testGetUpper002 + * @tc.desc: Obtains the upper bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testGetUpper002', 0, function () { var result = rangeFir.getUpper() - expect(+result).assertEqual(39) + expect(result).assertEqual(39) }) /** - * @tc.name: testGetUpper003 - * @tc.desc: Obtains the upper bound of the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testGetUpper003 + * @tc.desc: Obtains the upper bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testGetUpper003', 0, function () { var result = rangeSec.getUpper() - expect(+result).assertEqual(45) + expect(result).assertEqual(45) }) /** - * @tc.name: testGetUpper004 - * @tc.desc: Obtains the upper bound of the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testGetUpper004 + * @tc.desc: Obtains the upper bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testGetUpper004', 0, function () { var result = rangeThi.getUpper() - expect(+result).assertEqual(35) + expect(result).assertEqual(35) }) /** - * @tc.name: testGetUpper005 - * @tc.desc: Obtains the upper bound of the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testGetUpper005 + * @tc.desc: Obtains the upper bound of the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testGetUpper005', 0, function () { var result = rangeFif.getUpper() - expect(+result).assertEqual(45) + expect(result).assertEqual(45) }) /** - * @tc.name: testClamp001 - * @tc.desc: Clamps a given value to the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testClamp001 + * @tc.desc: Clamps a given value to the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testClamp001', 0, function () { var result =range.clamp(tempLess) - expect(+result).assertEqual(30) + expect(result).assertEqual(30) }) /** - * @tc.name: testClamp002 - * @tc.desc: Clamps a given value to the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testClamp002 + * @tc.desc: Clamps a given value to the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testClamp002', 0, function () { var result =range.clamp(tempMiDF) - expect(+result).assertEqual(35) + expect(result).assertEqual(35) }) /** - * @tc.name: testClamp003 - * @tc.desc: Clamps a given value to the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testClamp003 + * @tc.desc: Clamps a given value to the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testClamp003', 0, function () { var result =range.clamp(tempMore) - expect(+result).assertEqual(40) + expect(result).assertEqual(40) }) /** - * @tc.name: testClamp004 - * @tc.desc: Clamps a given value to the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testClamp004 + * @tc.desc: Clamps a given value to the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testClamp004', 0, function () { var result =range.clamp(tempLower) - expect(+result).assertEqual(30) + expect(result).assertEqual(30) }) /** - * @tc.name: testClamp005 - * @tc.desc: Clamps a given value to the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testClamp005 + * @tc.desc: Clamps a given value to the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testClamp005', 0, function () { var result =range.clamp(tempUpper) - expect(+result).assertEqual(40) + expect(result).assertEqual(40) }) /** @@ -1236,279 +1236,283 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testExpand001 - * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand001 + * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand001', 0, function () { var result = range.expand(tempMiDF, tempMidS) - // console.info('test result type =' + Object.prototype.toString.call(result)) - expect(result + '').assertEqual('[30, 40]') + expect(result).assertEqual('[30, 40]') }) /** - * @tc.name: testExpand002 - * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand002 + * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand002', 0, function () { var result = range.expand(tempLess, tempMore) - expect(result + '').assertEqual('[20, 45]') + expect(result).assertEqual('[20, 45]') }) /** - * @tc.name: testExpand003 - * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand003 + * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand003', 0, function () { var result = range.expand(tempLess, tempMiDF) - expect(result + '').assertEqual('[20, 40]') + expect(result).assertEqual('[20, 40]') }) /** - * @tc.name: testExpand004 - * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand004 + * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand004', 0, function () { var result = range.expand(tempMiDF, tempMore) - expect(result + '').assertEqual('[30, 45]') + expect(result).assertEqual('[30, 45]') }) /** - * @tc.name: testExpand005 - * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand005 + * @tc.desc: Creates the smallest range that includes the current range and the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand005', 0, function () { var result = range.expand(tempLower, tempUpper) - expect(result + '').assertEqual('[30, 40]') + expect(result).assertEqual('[30, 40]') }) /** - * @tc.name: testExpand001 - * @tc.desc: Creates the smallest range that includes the current range and a given range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand001 + * @tc.desc: Creates the smallest range that includes the current range and a given range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand001', 0, function () { var result = range.expand(rangeFir) - expect(result + '').assertEqual('[30, 40]') + expect(result).assertEqual('[30, 40]') }) /** - * @tc.name: testExpand002 - * @tc.desc: Creates the smallest range that includes the current range and a given range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand002 + * @tc.desc: Creates the smallest range that includes the current range and a given range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand002', 0, function () { var result = range.expand(rangeSec) - expect(result + '').assertEqual('[20, 45]') + expect(result).assertEqual('[20, 45]') }) /** - * @tc.name: testExpand003 - * @tc.desc: Creates the smallest range that includes the current range and a given range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand003 + * @tc.desc: Creates the smallest range that includes the current range and a given range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand003', 0, function () { var result = range.expand(rangeThi) - expect(result + '').assertEqual('[20, 40]') + expect(result).assertEqual('[20, 40]') }) /** - * @tc.name: testExpand004 - * @tc.desc: Creates the smallest range that includes the current range and a given range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand004 + * @tc.desc: Creates the smallest range that includes the current range and a given range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand004', 0, function () { var result = range.expand(rangeFif) - expect(result + '').assertEqual('[30, 45]') + expect(result).assertEqual('[30, 45]') }) /** - * @tc.name: testExpand005 - * @tc.desc: Creates the smallest range that includes the current range and a given range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand005 + * @tc.desc: Creates the smallest range that includes the current range and a given range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand005', 0, function () { var result = range.expand(range) - expect(result + '').assertEqual('[30, 40]') + expect(result).assertEqual('[30, 40]') }) /** - * @tc.name: testExpand001 - * @tc.desc: Creates the smallest range that includes the current range and a given value. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand001 + * @tc.desc: Creates the smallest range that includes the current range and a given value. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand001', 0, function () { var result = range.expand(tempMiDF) - expect(result + '').assertEqual('[30, 40]') + expect(result).assertEqual('[30, 40]') }) /** - * @tc.name: testExpand002 - * @tc.desc: Creates the smallest range that includes the current range and a given value. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand002 + * @tc.desc: Creates the smallest range that includes the current range and a given value. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand002', 0, function () { var result = range.expand(tempLess) - expect(result + '').assertEqual('[20, 40]') + expect(result).assertEqual('[20, 40]') }) /** - * @tc.name: testExpand003 - * @tc.desc: Creates the smallest range that includes the current range and a given value. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand003 + * @tc.desc: Creates the smallest range that includes the current range and a given value. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand003', 0, function () { var result = range.expand(tempMore) - expect(result + '').assertEqual('[30, 45]') + expect(result).assertEqual('[30, 45]') }) /** - * @tc.name: testExpand004 - * @tc.desc: Creates the smallest range that includes the current range and a given value. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand004 + * @tc.desc: Creates the smallest range that includes the current range and a given value. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand004', 0, function () { var result = range.expand(tempLower) - expect(result + '').assertEqual('[30, 40]') + expect(result).assertEqual('[30, 40]') }) /** - * @tc.name: testExpand005 - * @tc.desc: Creates the smallest range that includes the current range and a given value. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testExpand005 + * @tc.desc: Creates the smallest range that includes the current range and a given value. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testExpand005', 0, function () { var result = range.expand(tempUpper) - expect(result + '').assertEqual('[30, 40]') + expect(result).assertEqual('[30, 40]') }) /** - * @tc.name: testInstersect001 - * @tc.desc: Returns the intersection of a given range and the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testInstersect001 + * @tc.desc: Returns the intersection of a given range and the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testInstersect001', 0, function () { var result = range.intersect(rangeFir) - expect(result + '').assertEqual('[35, 39]') + expect(result).assertEqual('[35, 39]') }) /** - * @tc.name: testInstersect002 - * @tc.desc: Returns the intersection of a given range and the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testInstersect002 + * @tc.desc: Returns the intersection of a given range and the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testInstersect002', 0, function () { var result = range.intersect(rangeSec) - expect(result + '').assertEqual('[30, 40]') + expect(result).assertEqual('[30, 40]') }) /** - * @tc.name: testInstersect003 - * @tc.desc: Returns the intersection of a given range and the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testInstersect003 + * @tc.desc: Returns the intersection of a given range and the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testInstersect003', 0, function () { var result = range.intersect(rangeThi) - expect(result + '').assertEqual('[30, 35]') + expect(result).assertEqual('[30, 35]') }) /** - * @tc.name: testInstersect004 - * @tc.desc: Returns the intersection of a given range and the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testInstersect004 + * @tc.desc: Returns the intersection of a given range and the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testInstersect004', 0, function () { var result = range.intersect(rangeFif) - expect(result + '').assertEqual('[35, 40]') + expect(result).assertEqual('[35, 40]') }) /** - * @tc.name: testInstersect005 - * @tc.desc: Returns the intersection of a given range and the current range. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testInstersect005 + * @tc.desc: Returns the intersection of a given range and the current range. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testInstersect005', 0, function () { var result = range.intersect(range) - expect(result + '').assertEqual('[30, 40]') + expect(result).assertEqual('[30, 40]') }) /** - * @tc.name: testInstersect001 - * @tc.desc: Returns the intersection of the current range and the range specified by the given lower and upper bounds. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testInstersect001 + * @tc.desc: Returns the intersection of the current range and the range specified by + the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testInstersect001', 0, function () { var result = range.intersect(tempMiDF, tempMidS) - expect(result + '').assertEqual('[35, 39]') + expect(result).assertEqual('[35, 39]') }) /** - * @tc.name: testInstersect002 - * @tc.desc: Returns the intersection of the current range and the range specified by the given lower and upper bounds. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testInstersect002 + * @tc.desc: Returns the intersection of the current range and the range specified by + the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testInstersect002', 0, function () { var result = range.intersect(tempLess, tempMore) - expect(result + '').assertEqual('[30, 40]') + expect(result).assertEqual('[30, 40]') }) /** - * @tc.name: testInstersect003 - * @tc.desc: Returns the intersection of the current range and the range specified by the given lower and upper bounds. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testInstersect003 + * @tc.desc: Returns the intersection of the current range and the range specified by + the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testInstersect003', 0, function () { var result = range.intersect(tempLess, tempMiDF) - expect(result + '').assertEqual('[30, 35]') + expect(result).assertEqual('[30, 35]') }) /** - * @tc.name: testInstersect004 - * @tc.desc: Returns the intersection of the current range and the range specified by the given lower and upper bounds. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testInstersect004 + * @tc.desc: Returns the intersection of the current range and the range specified by + the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testInstersect004', 0, function () { var result = range.intersect(tempMiDF, tempMore) - expect(result + '').assertEqual('[35, 40]') + expect(result).assertEqual('[35, 40]') }) /** - * @tc.name: testInstersect005 - * @tc.desc: Returns the intersection of the current range and the range specified by the given lower and upper bounds. - * @tc.require: AR000GFB4U - * @tc.author: jiangkai - */ + * @tc.name: testInstersect005 + * @tc.desc: Returns the intersection of the current range and the range specified by + the given lower and upper bounds. + * @tc.require: AR000GFB4U + * @tc.author: jiangkai + */ it('testInstersect005', 0, function () { var result = range.intersect(tempLower, tempUpper) - expect(result + '').assertEqual('[30, 40]') + expect(result).assertEqual('[30, 40]') }) /** @@ -1565,309 +1569,331 @@ describe('TextEncoderTest', function () { var result = rangeFif.toString() expect(result).assertEqual('[35, 45]') }) - }) +}) + +describe('Base64Test', function () { - describe('Base64Test', function () { /** - * @tc.name: testEncode001 - * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testEncodeSync001 + * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncode001', 0, function () { + it('testEncodeSync001', 0, function () { var that = new util.Base64() var array = new Uint8Array([115,49,51]); var rarray = new Uint8Array([99,122,69,122]); - var result = that.encode(array); + var result = that.encodeSync(array); for (var i = 0; i < 4; i++) { expect(result[i]).assertEqual(rarray[i]); } }) /** - * @tc.name: testEncode002 - * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testEncodeSync002 + * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncode002', 0, function () { + it('testEncodeSync002', 0, function () { var that = new util.Base64() var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); var rarray = new Uint8Array([81,109,70,122,90,84,89,48,73,69,53,118,90,71,85,117,97,110,77,61]); - var result = that.encode(array); + var result = that.encodeSync(array); for (var i = 0; i < 20; i++) { expect(result[i]).assertEqual(rarray[i]); } }) /** - * @tc.name: testEncode003 - * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testEncodeSync003 + * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncode003', 0, function () { + it('testEncodeSync003', 0, function () { var that = new util.Base64() - var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111,100,101,46,106,115]); - var rarray = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73,71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]); - var result = that.encode(array); + var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105, + 110,32,78,111,100,101,46,106,115]); + var rarray = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110, + 73,71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]); + var result = that.encodeSync(array); for (var i = 0; i < 36; i++) { expect(result[i]).assertEqual(rarray[i]); } }) /** - * @tc.name: testEncode004 - * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testEncodeSync004 + * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncode004', 0, function () { + it('testEncodeSync004', 0, function () { var that = new util.Base64() var array = new Uint8Array([168, 174, 155, 255]); var rarray = new Uint8Array([113,75,54,98,47,119,61,61]); - var result = that.encode(array); + var result = that.encodeSync(array); for (var i = 0; i < 8; i++) { expect(result[i]).assertEqual(rarray[i]); } }) /** - * @tc.name: testEncode005 - * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testEncodeSync005 + * @tc.desc: Encodes all bytes from the specified u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncode005', 0, function () { + it('testEncodeSync005', 0, function () { var that = new util.Base64() var array = new Uint8Array([66, 97, 115, 101, 54, 52]); var rarray = new Uint8Array([81, 109, 70, 122, 90, 84, 89, 48]); - var result = that.encode(array); + var result = that.encodeSync(array); for (var i = 0; i <8; i++) { expect(result[i]).assertEqual(rarray[i]); } }) /** - * @tc.name: testEncodeToString001 + * @tc.name: testEncodeToStringSync001 * @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeToString001', 0, function () { + it('testEncodeToStringSync001', 0, function () { var that = new util.Base64() var array = new Uint8Array([115,49,51]); - var result = that.encodeToString(array) + var result = that.encodeToStringSync(array) expect(result).assertEqual('czEz') }) /** - * @tc.name: testEncodeToString002 + * @tc.name: testEncodeToStringSync002 * @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeToString002', 0, function () { + it('testEncodeToStringSync002', 0, function () { var that = new util.Base64() var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); - var result = that.encodeToString(array); + var result = that.encodeToStringSync(array); expect(result).assertEqual('QmFzZTY0IE5vZGUuanM=') }) /** - * @tc.name: testEncodeToString003 + * @tc.name: testEncodeToStringSync003 * @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeToString003', 0, function () { + it('testEncodeToStringSync003', 0, function () { var that = new util.Base64() - var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111,100,101,46,106,115]); - var result = that.encodeToString(array); + var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110, + 32,78,111,100,101,46,106,115]); + var result = that.encodeToStringSync(array); expect(result).assertEqual('QmFzZTY0IEVuY29kaW5nIGluIE5vZGUuanM=') }) /** - * @tc.name: testEncodeToString004 + * @tc.name: testEncodeToStringSync004 * @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeToString004', 0, function () { + it('testEncodeToStringSync004', 0, function () { var that = new util.Base64() var array = new Uint8Array([168, 174, 155, 255]); - var result = that.encodeToString(array); + var result = that.encodeToStringSync(array); expect(result).assertEqual('qK6b/w==') }) /** - * @tc.name: testEncodeToString005 + * @tc.name: testEncodeToStringSync005 * @tc.desc: Encodes the specified byte array into a String using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeToString005', 0, function () { + it('testEncodeToStringSync005', 0, function () { var that = new util.Base64() var array = new Uint8Array([66, 97, 115, 101, 54, 52]); - var result = that.encodeToString(array); + var result = that.encodeToStringSync(array); expect(result).assertEqual('QmFzZTY0') }) /** - * @tc.name: testDecode001 - * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testDecodeSync001 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecode001', 0, function () { + it('testDecodeSync001', 0, function () { var that = new util.Base64() var buff = 'czEz'; var rarray = new Uint8Array([115,49,51]); - var result = that.decode(buff); + var result = that.decodeSync(buff); for (var i = 0; i < 3; i++) { expect(result[i]).assertEqual(rarray[i]); } }) /** - * @tc.name: testDecode002 - * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testDecodeSync002 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecode002', 0, function () { + it('testDecodeSync002', 0, function () { var that = new util.Base64() var buff = 'QmFzZTY0IE5vZGUuanM='; var rarray = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); - var result = that.decode(buff); + var result = that.decodeSync(buff); for (var i = 0; i < 14; i++) { expect(result[i]).assertEqual(rarray[i]); } }) /** - * @tc.name: testDecode003 - * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testDecodeSync003 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecode003', 0, function () { + it('testDecodeSync003', 0, function () { var that = new util.Base64() var buff = 'QmFzZTY0IEVuY29kaW5nIGluIE5vZGUuanM='; - var rarray = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111,100,101,46,106,115]); - var result = that.decode(buff); + var rarray = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32, + 105,110,32,78,111,100,101,46,106,115]); + var result = that.decodeSync(buff); for (var i = 0; i < 26; i++) { expect(result[i]).assertEqual(rarray[i]); } }) /** - * @tc.name: testDecode004 - * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testDecodeSync004 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecode004', 0, function () { + it('testDecodeSync004', 0, function () { var that = new util.Base64() var buff = 'qK6b/w=='; var rarray = new Uint8Array([168, 174, 155, 255]); - var result = that.decode(buff); + var result = that.decodeSync(buff); for (var i = 0; i < 4; i++) { expect(result[i]).assertEqual(rarray[i]); } }) /** - * @tc.name: testDecode005 - * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testDecodeSync005 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecode005', 0, function () { + it('testDecodeSync005', 0, function () { var that = new util.Base64() var buff = 'QmFzZTY0'; var rarray = new Uint8Array([66, 97, 115, 101, 54, 52]); - var result = that.decode(buff); + var result = that.decodeSync(buff); for (var i = 0; i <6; i++) { expect(result[i]).assertEqual(rarray[i]); } }) /** - * @tc.name: testDecode001 - * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testDecodeSync001 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecode001', 0, function () { + it('testDecodeSync001', 0, function () { var that = new util.Base64() var array = new Uint8Array([99,122,69,122]); var rarray = new Uint8Array([115,49,51]); - var result = that.decode(array); + var result = that.decodeSync(array); for (var i = 0; i < 3; i++) { expect(result[i]).assertEqual(rarray[i]); } }) /** - * @tc.name: testDecode002 - * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testDecodeSync002 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecode002', 0, function () { + it('testDecodeSync002', 0, function () { var that = new util.Base64() var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,53,118,90,71,85,117,97,110,77,61]); var rarray = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); - var result = that.decode(array); + var result = that.decodeSync(array); for (var i = 0; i < 14; i++) { expect(result[i]).assertEqual(rarray[i]); } }) /** - * @tc.name: testDecode003 - * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testDecodeSync003 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecode003', 0, function () { + it('testDecodeSync003', 0, function () { var that = new util.Base64() - var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73,71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]); - var rarray = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111,100,101,46,106,115]); - var result = that.decode(array); + var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87, + 53,110,73,71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]); + var rarray = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105, + 110,32,78,111,100,101,46,106,115]); + var result = that.decodeSync(array); for (var i = 0; i < 26; i++) { expect(result[i]).assertEqual(rarray[i]); } }) /** - * @tc.name: testDecode004 - * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testDecodeSync004 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecode004', 0, function () { + it('testDecodeSync004', 0, function () { var that = new util.Base64() var array = new Uint8Array([113,75,54,98,47,119,61,61]); var rarray = new Uint8Array([168, 174, 155, 255]); - var result = that.decode(array); + var result = that.decodeSync(array); for (var i = 0; i < 4; i++) { expect(result[i]).assertEqual(rarray[i]); } }) /** - * @tc.name: testDecode005 - * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 array using the Base64 encoding scheme. + * @tc.name: testDecodeSync005 + * @tc.desc: Decodes a Base64 encoded String or input u8 array into a newly-allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecode005', 0, function () { + it('testDecodeSync005', 0, function () { var that = new util.Base64() var array = new Uint8Array([81, 109, 70, 122, 90, 84, 89, 48]); var rarray = new Uint8Array([66, 97, 115, 101, 54, 52]); - var result = that.decode(array); + var result = that.decodeSync(array); for (var i = 0; i <6; i++) { expect(result[i]).assertEqual(rarray[i]); } @@ -1875,16 +1901,17 @@ describe('TextEncoderTest', function () { //base64 EncodeAsync test /** - * @tc.name: testEncodeAsync001 - * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme. + * @tc.name: testEncode001 + * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly + allocated u8 array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeAsync001', 0, async function () { + it('testEncode001', 0, async function () { var that = await new util.Base64(); var array = new Uint8Array([115,49,51]); var rarray = new Uint8Array([99,122,69,122]); - that.encodeAsync(array).then(val=>{ + that.encode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { expect(val[i]).assertEqual(rarray[i]) } @@ -1892,16 +1919,17 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testEncodeAsync002 - * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme. + * @tc.name: testEncode002 + * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly + allocated u8 array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeAsync002', 0, async function () { + it('testEncode002', 0, async function () { var that = new util.Base64() var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); var rarray = new Uint8Array([81,109,70,122,90,84,89,48,73,69,53,118,90,71,85,117,97,110,77,61]); - that.encodeAsync(array).then(val=>{ + that.encode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { expect(val[i]).assertEqual(rarray[i]) } @@ -1909,16 +1937,19 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testEncodeAsync003 - * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme. + * @tc.name: testEncode003 + * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeAsync003', 0, async function () { + it('testEncode003', 0, async function () { var that = new util.Base64() - var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111,100,101,46,106,115]); - var rarray = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73,71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]); - that.encodeAsync(array).then(val=>{ + var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32, + 78,111,100,101,46,106,115]); + var rarray = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73, + 71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]); + that.encode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { expect(val[i]).assertEqual(rarray[i]) } @@ -1926,16 +1957,17 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testEncodeAsync004 - * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme. + * @tc.name: testEncode004 + * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeAsync004', 0, async function () { + it('testEncode004', 0, async function () { var that = new util.Base64() var array = new Uint8Array([168, 174, 155, 255]); var rarray = new Uint8Array([113,75,54,98,47,119,61,61]); - that.encodeAsync(array).then(val=>{ + that.encode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { expect(val[i]).assertEqual(rarray[i]) } @@ -1943,16 +1975,17 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testEncodeAsync005 - * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 array using the Base64 encoding scheme. + * @tc.name: testEncode005 + * @tc.desc: Asynchronously encodes all bytes in the specified u8 array into the newly allocated u8 + array using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeAsync005', 0, async function () { + it('testEncode005', 0, async function () { var that = new util.Base64() var array = new Uint8Array([66, 97, 115, 101, 54, 52]); var rarray = new Uint8Array([81, 109, 70, 122, 90, 84, 89, 48]); - that.encodeAsync(array).then(val=>{ + that.encode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { expect(val[i]).assertEqual(rarray[i]) } @@ -1960,86 +1993,88 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testEncodeToStringAsync001 + * @tc.name: testEncodeToString001 * @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeToStringAsync001', 0, async function () { + it('testEncodeToString001', 0, async function () { var that = new util.Base64() var array = new Uint8Array([115,49,51]); - that.encodeToStringAsync(array).then(val=>{ + that.encodeToString(array).then(val=>{ expect(val).assertEqual('czEz') }) }) /** - * @tc.name: testEncodeToStringAsync002 + * @tc.name: testEncodeToString002 * @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeToStringAsync002', 0, async function () { + it('testEncodeToString002', 0, async function () { var that = new util.Base64() var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); - that.encodeToStringAsync(array).then(val=>{ + that.encodeToString(array).then(val=>{ expect(val).assertEqual('QmFzZTY0IE5vZGUuanM=') }) }) /** - * @tc.name: testEncodeToStringAsync003 + * @tc.name: testEncodeToString003 * @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeToStringAsync003', 0, async function () { + it('testEncodeToString003', 0, async function () { var that = new util.Base64() - var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73,71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]); - that.encodeToStringAsync(array).then(val=>{ + var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73,71,108, + 117,73,69,53,118,90,71,85,117,97,110,77,61]); + that.encodeToString(array).then(val=>{ expect(val).assertEqual('QmFzZTY0IEVuY29kaW5nIGluIE5vZGUuanM=') }) }) /** - * @tc.name: testEncodeToStringAsync004 + * @tc.name: testEncodeToString004 * @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeToStringAsync004', 0, async function () { + it('testEncodeToString004', 0, async function () { var that = new util.Base64() var array = new Uint8Array([168, 174, 155, 255]); - that.encodeToStringAsync(array).then(val=>{ + that.encodeToString(array).then(val=>{ expect(val).assertEqual('qK6b/w==') }) }) /** - * @tc.name: testEncodeToStringAsync005 + * @tc.name: testEncodeToString005 * @tc.desc: Asynchronously encodes the specified byte array into a String using the Base64 encoding scheme. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testEncodeToStringAsync005', 0, async function () { + it('testEncodeToString005', 0, async function () { var that = new util.Base64() var array = new Uint8Array([66, 97, 115, 101, 54, 52]); - that.encodeToStringAsync(array).then(val=>{ + that.encodeToString(array).then(val=>{ expect(val).assertEqual('QmFzZTY0') }) }) /** - * @tc.name: testDecodeAsync001 - * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array. + * @tc.name: testDecode001 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecodeAsync001', 0, async function () { + it('testDecode001', 0, async function () { var that = new util.Base64() var buff = 'czEz'; var array = new Uint8Array([115,49,51]); - that.decodeAsync(buff).then(val=>{ + that.decode(buff).then(val=>{ for (var i = 0; i < array.length; i++) { expect(val[i]).assertEqual(array[i]) } @@ -2047,16 +2082,17 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testDecodeAsync002 - * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array. + * @tc.name: testDecode002 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecodeAsync002', 0, async function () { + it('testDecode002', 0, async function () { var that = new util.Base64() var buff = 'QmFzZTY0IE5vZGUuanM='; var array = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); - that.decodeAsync(buff).then(val=>{ + that.decode(buff).then(val=>{ for (var i = 0; i < array.length; i++) { expect(val[i]).assertEqual(array[i]) } @@ -2064,16 +2100,18 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testDecodeAsync003 - * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array. + * @tc.name: testDecode003 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecodeAsync003', 0, async function () { + it('testDecode003', 0, async function () { var that = new util.Base64() var buff = 'QmFzZTY0IEVuY29kaW5nIGluIE5vZGUuanM='; - var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111,100,101,46,106,115]); - that.decodeAsync(buff).then(val=>{ + var array = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78, + 111,100,101,46,106,115]); + that.decode(buff).then(val=>{ for (var i = 0; i < array.length; i++) { expect(val[i]).assertEqual(array[i]) } @@ -2081,16 +2119,17 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testDecodeAsync004 - * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array. + * @tc.name: testDecode004 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecodeAsync004', 0, async function () { + it('testDecode004', 0, async function () { var that = new util.Base64() var buff = 'qK6b/w=='; var array = new Uint8Array([168, 174, 155, 255]); - that.decodeAsync(buff).then(val=>{ + that.decode(buff).then(val=>{ for (var i = 0; i < array.length; i++) { expect(val[i]).assertEqual(array[i]) } @@ -2098,16 +2137,17 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testDecodeAsync005 - * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array. + * @tc.name: testDecode005 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecodeAsync005', 0, async function () { + it('testDecode005', 0, async function () { var that = new util.Base64() var buff = 'QmFzZTY0'; var rarray = new Uint8Array([66, 97, 115, 101, 54, 52]); - that.decodeAsync(buff).then(val=>{ + that.decode(buff).then(val=>{ for (var i = 0; i < rarray.length; i++) { expect(val[i]).assertEqual(rarray[i]) } @@ -2115,16 +2155,17 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testDecodeAsync001 - * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array. + * @tc.name: testDecode001 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecodeAsync001', 0, async function () { + it('testDecode001', 0, async function () { var that = new util.Base64() var array = new Uint8Array([99,122,69,122]); var rarray = new Uint8Array([115,49,51]); - that.decodeAsync(array).then(val=>{ + that.decode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { expect(val[i]).assertEqual(rarray[i]) } @@ -2132,16 +2173,17 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testDecodeAsync002 - * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array. + * @tc.name: testDecode002 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecodeAsync002', 0, async function () { + it('testDecode002', 0, async function () { var that = new util.Base64() var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,53,118,90,71,85,117,97,110,77,61]); var rarray = new Uint8Array([66, 97, 115, 101, 54, 52, 32, 78, 111, 100, 101, 46, 106, 115]); - that.decodeAsync(array).then(val=>{ + that.decode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { expect(val[i]).assertEqual(rarray[i]) } @@ -2149,16 +2191,19 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testDecodeAsync003 - * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array. + * @tc.name: testDecode003 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecodeAsync003', 0, async function () { + it('testDecode003', 0, async function () { var that = new util.Base64() - var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73,71,108,117,73,69,53,118,90,71,85,117,97,110,77,61]); - var rarray = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111,100,101,46,106,115]); - that.decodeAsync(array).then(val=>{ + var array = new Uint8Array([81,109,70,122,90,84,89,48,73,69,86,117,89,50,57,107,97,87,53,110,73,71,108, + 117,73,69,53,118,90,71,85,117,97,110,77,61]); + var rarray = new Uint8Array([66,97,115,101,54,52,32,69,110,99,111,100,105,110,103,32,105,110,32,78,111, + 100,101,46,106,115]); + that.decode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { expect(val[i]).assertEqual(rarray[i]) } @@ -2166,16 +2211,17 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testDecodeAsync004 - * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array. + * @tc.name: testDecode004 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array + into a newly allocated u8 array. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecodeAsync004', 0, async function () { + it('testDecode004', 0, async function () { var that = new util.Base64() var array = new Uint8Array([113,75,54,98,47,119,61,61]); var rarray = new Uint8Array([168, 174, 155, 255]); - that.decodeAsync(array).then(val=>{ + that.decode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { expect(val[i]).assertEqual(rarray[i]) } @@ -2183,24 +2229,26 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testDecodeAsync005 - * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 array into a newly allocated u8 array. + * @tc.name: testDecode005 + * @tc.desc: Use the Base64 encoding scheme to asynchronously decode a Base64-encoded string or input u8 + array into a newly allocated u8 array. * @tc.require: AR000GFB2Q * @tc.author: bihu */ - it('testDecodeAsync005', 0, async function () { + it('testDecode005', 0, async function () { var that = new util.Base64() var array = new Uint8Array([81, 109, 70, 122, 90, 84, 89, 48]); var rarray = new Uint8Array([66, 97, 115, 101, 54, 52]); - that.decodeAsync(array).then(val=>{ + that.decode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { expect(val[i]).assertEqual(rarray[i]) } }) }) - }) +}) + +describe('RationalNumberFunTest', function () { - describe('RationalNumberFunTest', function () { /** * @tc.name: testRationalNumberCreateRationalFromString001 * @tc.desc: Creates a RationalNumber object based on a given string. @@ -2210,7 +2258,7 @@ describe('TextEncoderTest', function () { it('testRationalNumberCreateRationalFromString001', 0, function () { var pro = new util.RationalNumber(1, 2) var res = pro.createRationalFromString('-1:2') - var result1 = res.value() + var result1 = res.valueOf() expect(result1).assertEqual(-0.5) }) @@ -2223,7 +2271,7 @@ describe('TextEncoderTest', function () { it('testRationalNumberCreateRationalFromString002', 0, function () { var pro = new util.RationalNumber(1, 2) var res = pro.createRationalFromString('+3/4') - var result1 = res.value() + var result1 = res.valueOf() expect(result1).assertEqual(0.75) }) @@ -2236,7 +2284,7 @@ describe('TextEncoderTest', function () { it('testRationalNumberCreateRationalFromString003', 0, function () { var pro = new util.RationalNumber(1, 2) var res = pro.createRationalFromString('+3:-4') - var result1 = res.value() + var result1 = res.valueOf() expect(result1).assertEqual(-0.75) }) @@ -2249,7 +2297,7 @@ describe('TextEncoderTest', function () { it('testRationalNumberCreateRationalFromString004', 0, function () { var pro = new util.RationalNumber(1, 2) var res = pro.createRationalFromString('+2:4') - var result1 = res.value() + var result1 = res.valueOf() expect(result1).assertEqual(0.5) }) @@ -2262,7 +2310,7 @@ describe('TextEncoderTest', function () { it('testRationalNumberCreateRationalFromString005', 0, function () { var pro = new util.RationalNumber(1, 2) var res = pro.createRationalFromString('+2:-4') - var result1 = res.value() + var result1 = res.valueOf() expect(result1).assertEqual(-0.5) }) @@ -2397,62 +2445,62 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testRationalNumberValue001 + * @tc.name: testRationalNumberValueOf001 * @tc.desc: Obtains the value of the current RationalNumber object as a number. * @tc.require: AR000GFB5A * @tc.author: liuqiang */ - it('testRationalNumberValue001', 0, function () { + it('testRationalNumberValueOf001', 0, function () { var pro = new util.RationalNumber(2, 1) - var res = pro.value() + var res = pro.valueOf() expect(res).assertEqual(2) }) /** - * @tc.name: testRationalNumberValue002 + * @tc.name: testRationalNumberValueOf002 * @tc.desc: Obtains the value of the current RationalNumber object as a number. * @tc.require: AR000GFB5A * @tc.author: liuqiang */ - it('testRationalNumberValue002', 0, function () { + it('testRationalNumberValueOf002', 0, function () { var pro = new util.RationalNumber(2, 10) - var res = pro.value() + var res = pro.valueOf() expect(res).assertEqual(0.2) }) /** - * @tc.name: testRationalNumberValue003 + * @tc.name: testRationalNumberValueOf003 * @tc.desc: Obtains the value of the current RationalNumber object as a number. * @tc.require: AR000GFB5A * @tc.author: liuqiang */ - it('testRationalNumberValue003', 0, function () { + it('testRationalNumberValueOf003', 0, function () { var pro = new util.RationalNumber(1, 2) - var res = pro.value() + var res = pro.valueOf() expect(res).assertEqual(0.5) }) /** - * @tc.name: testRationalNumberValue004 + * @tc.name: testRationalNumberValueOf004 * @tc.desc: Obtains the value of the current RationalNumber object as a number. * @tc.require: AR000GFB5A * @tc.author: liuqiang */ - it('testRationalNumberValue004', 0, function () { + it('testRationalNumberValueOf004', 0, function () { var pro = new util.RationalNumber(4, 2) - var res = pro.value() + var res = pro.valueOf() expect(res).assertEqual(2) }) /** - * @tc.name: testRationalNumberValue005 + * @tc.name: testRationalNumberValueOf005 * @tc.desc: Obtains the value of the current RationalNumber object as a number. * @tc.require: AR000GFB5A * @tc.author: liuqiang */ it('testRationalNumberValue005', 0, function () { var pro = new util.RationalNumber(4, 1) - var res = pro.value() + var res = pro.valueOf() expect(res).assertEqual(4) }) @@ -2875,71 +2923,72 @@ describe('TextEncoderTest', function () { var res = pro.toString() expect(res).assertEqual('2/3') }) - }) +}) + +describe('LruBufferFunTest', function () { - describe('LruBufferFunTest', function () { /** - * @tc.name: testLruBufferUpdateCapacity001 + * @tc.name: testLruBufferUpdateGetCapacity001 * @tc.desc: Updates the buffer capacity to a specified capacity. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferUpdateCapacity001', 0, function () { + it('testLruBufferUpdateGetCapacity001', 0, function () { var that = new util.LruBuffer() that.updateCapacity(10) - var result = that.capacity() + var result = that.getCapacity() expect(result).assertEqual(10) }) /** - * @tc.name: testLruBufferUpdateCapacity002 + * @tc.name: testLruBufferUpdateGetCapacity002 * @tc.desc: Updates the buffer capacity to a specified capacity. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferUpdateCapacity002', 0, function () { + it('testLruBufferUpdateGetCapacity002', 0, function () { var that = new util.LruBuffer() - that.updateCapacity(80) - var result = that.capacity() - expect(result).assertEqual(80) + that.updateCapacity(2147483646) + var result = that.getCapacity() + expect(result).assertEqual(2147483646) }) /** - * @tc.name: testLruBufferUpdateCapacity003 + * @tc.name: testLruBufferUpdateGetCapacity003 * @tc.desc: Updates the buffer capacity to a specified capacity. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferUpdateCapacity003', 0, function () { + it('testLruBufferUpdateGetCapacity003', 0, function () { var that = new util.LruBuffer(100) that.updateCapacity(20) - var result = that.capacity() + var result = that.getCapacity() expect(result).assertEqual(20) }) /** - * @tc.name: testLruBufferUpdateCapacity004 + * @tc.name: testLruBufferUpdateGetCapacity004 * @tc.desc: Updates the buffer capacity to a specified capacity. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferUpdateCapacity004', 0, function () { + it('testLruBufferUpdateGetCapacity004', 0, function () { var that = new util.LruBuffer(50) that.updateCapacity(2) - var result = that.capacity() + var result = that.getCapacity() expect(result).assertEqual(2) }) /** - * @tc.name: testLruBufferUpdateCapacity005 + * @tc.name: testLruBufferUpdateGetCapacity005 * @tc.desc: Updates the buffer capacity to a specified capacity. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferUpdateCapacity005', 0, function () { + it('testLruBufferUpdateGetCapacity005', 0, function () { var that = new util.LruBuffer(200) that.updateCapacity(100) - var result = that.capacity() + var result = that.getCapacity() expect(result).assertEqual(100) }) @@ -3298,6 +3347,24 @@ describe('TextEncoderTest', function () { expect(result).assertEqual(4) }) + /** + * @tc.name: testLruBufferGetMissCount006 + * @tc.desc: Obtains the number of times that the queried values are not matched. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetMissCount006', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.get(1) + that.get(2) + that.get('abcd') + var result = that.getMissCount() + expect(result).assertEqual(0) + }) + /** * @tc.name: testLruBufferGetRemovalCount001 * @tc.desc: Obtains the number of times that values are evicted from the buffer. @@ -3483,6 +3550,22 @@ describe('TextEncoderTest', function () { expect(result).assertEqual(7) }) + /** + * @tc.name: testLruBufferGetMatchCount006 + * @tc.desc: Obtains the number of times that the queried values are successfully matched. + * @tc.require: AR000GFB59 + * @tc.author: lixingyang + */ + it('testLruBufferGetMatchCount006', 0, function () { + var that = new util.LruBuffer() + that.put(1,2) + that.put(2,10) + that.put('abcd',15) + that.get(5) + var result = that.getMatchCount() + expect(result).assertEqual(0) + }) + /** * @tc.name: testLruBufferGetPutCount001 * @tc.desc: Obtains the number of times that values are added to the buffer. @@ -3557,129 +3640,129 @@ describe('TextEncoderTest', function () { }) /** - * @tc.name: testLruBufferCapacity001 + * @tc.name: testLruBufferGetCapacity001 * @tc.desc: Obtains the capacity of the current buffer. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferCapacity001', 0, function () { + it('testLruBufferGetCapacity001', 0, function () { var that = new util.LruBuffer() - var result = that.capacity() + var result = that.getCapacity() expect(result).assertEqual(64) }) /** - * @tc.name: testLruBufferCapacity002 + * @tc.name: testLruBufferGetCapacity002 * @tc.desc: Obtains the capacity of the current buffer. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferCapacity002', 0, function () { + it('testLruBufferGetCapacity002', 0, function () { var that = new util.LruBuffer(2) - var result = that.capacity() + var result = that.getCapacity() expect(result).assertEqual(2) }) /** - * @tc.name: testLruBufferCapacity003 + * @tc.name: testLruBufferGetCapacity003 * @tc.desc: Obtains the capacity of the current buffer. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferCapacity003', 0, function () { + it('testLruBufferGetCapacity003', 0, function () { var that = new util.LruBuffer(100) - var result = that.capacity() + var result = that.getCapacity() expect(result).assertEqual(100) }) /** - * @tc.name: testLruBufferCapacity004 + * @tc.name: testLruBufferGetCapacity004 * @tc.desc: Obtains the capacity of the current buffer. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferCapacity004', 0, function () { + it('testLruBufferGetCapacity004', 0, function () { var that = new util.LruBuffer() that.updateCapacity(50) - var result = that.capacity() + var result = that.getCapacity() expect(result).assertEqual(50) }) /** - * @tc.name: testLruBufferCapacity005 + * @tc.name: testLruBufferGetCapacity005 * @tc.desc: Obtains the capacity of the current buffer. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferCapacity005', 0, function () { + it('testLruBufferGetCapacity005', 0, function () { var that = new util.LruBuffer(100) that.updateCapacity(10) - var result = that.capacity() + var result = that.getCapacity() expect(result).assertEqual(10) }) /** - * @tc.name: testLruBufferSize001 + * @tc.name: testLruBufferLength001 * @tc.desc: Obtains the total number of values in the current buffer. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferSize001', 0, function () { + it('testLruBufferLength001', 0, function () { var that = new util.LruBuffer() - var result = that.size() + var result = that.length expect(result).assertEqual(0) }) /** - * @tc.name: testLruBufferSize002 + * @tc.name: testLruBufferLength002 * @tc.desc: Obtains the total number of values in the current buffer. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferSize002', 0, function () { + it('testLruBufferLength002', 0, function () { var that = new util.LruBuffer() that.put(1,2) - var result = that.size() + var result = that.length expect(result).assertEqual(1) }) /** - * @tc.name: testLruBufferSize003 + * @tc.name: testLruBufferLength003 * @tc.desc: Obtains the total number of values in the current buffer. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferSize003', 0, function () { + it('testLruBufferLength003', 0, function () { var that = new util.LruBuffer() that.put('abc',2) that.put('string','string') - var result = that.size() + var result = that.length expect(result).assertEqual(2) }) /** - * @tc.name: testLruBufferSize004 + * @tc.name: testLruBufferLength004 * @tc.desc: Obtains the total number of values in the current buffer. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferSize004', 0, function () { + it('testLruBufferLength004', 0, function () { var that = new util.LruBuffer() that.put(1,2) that.put(2,10) that.put('abcd',15) that.put('abcd',20) - var result = that.size() + var result = that.length expect(result).assertEqual(3) }) /** - * @tc.name: testLruBufferSize005 + * @tc.name: testLruBufferLength005 * @tc.desc: Obtains the total number of values in the current buffer. * @tc.require: AR000GFB59 * @tc.author: lixingyang */ - it('testLruBufferSize005', 0, function () { + it('testLruBufferLength005', 0, function () { var that = new util.LruBuffer() that.put(1,2) that.put(2,10) @@ -3688,7 +3771,7 @@ describe('TextEncoderTest', function () { that.updateCapacity(3); that.put(5,33); that.put(25,35); - var result = that.size() + var result = that.length expect(result).assertEqual(3) }) @@ -3701,9 +3784,9 @@ describe('TextEncoderTest', function () { it('testLruBufferClear001', 0, function () { var that = new util.LruBuffer() that.put(1,2) - var result1 = that.size() + var result1 = that.length that.clear() - var result2 = that.size() + var result2 = that.length expect(result1).assertEqual(1) expect(result2).assertEqual(0) }) @@ -3720,9 +3803,9 @@ describe('TextEncoderTest', function () { that.put(2,10) that.put(5,33); that.put(25,35); - var result1 = that.size() + var result1 = that.length that.clear() - var result2 = that.size() + var result2 = that.length expect(result1).assertEqual(4) expect(result2).assertEqual(0) }) @@ -3739,9 +3822,9 @@ describe('TextEncoderTest', function () { that.put(2,'abc') that.put('ancd','abcd') that.put(10,35) - var result1 = that.size() + var result1 = that.length that.clear() - var result2 = that.size() + var result2 = that.length expect(result1).assertEqual(4) expect(result2).assertEqual(0) }) @@ -3758,9 +3841,9 @@ describe('TextEncoderTest', function () { that.put(2,10) that.put(5,33); that.updateCapacity(3); - var result1 = that.size() + var result1 = that.length that.clear() - var result2 = that.size() + var result2 = that.length expect(result1).assertEqual(3) expect(result2).assertEqual(0) }) @@ -3778,9 +3861,9 @@ describe('TextEncoderTest', function () { that.put(5,33); that.put('abcd','string'); that.updateCapacity(2); - var result1 = that.size() + var result1 = that.length that.clear() - var result2 = that.size() + var result2 = that.length expect(result1).assertEqual(2) expect(result2).assertEqual(0) }) @@ -4365,7 +4448,7 @@ describe('TextEncoderTest', function () { i++; arr[i]=entry[1]; i++; - }; + } expect(arr[1]).assertEqual('abc'); }) @@ -4388,7 +4471,7 @@ describe('TextEncoderTest', function () { i++; arr[i]=entry[1]; i++; - }; + } expect(arr[1]).assertEqual(2); }) @@ -4412,7 +4495,7 @@ describe('TextEncoderTest', function () { i++; arr[i]=entry[1]; i++; - }; + } expect(arr[0]).assertEqual(1); }) @@ -4437,7 +4520,7 @@ describe('TextEncoderTest', function () { i++; arr[i]=entry[1]; i++; - }; + } expect(arr[1]).assertEqual(15) expect(arr[3]).assertEqual(20) }) @@ -4466,7 +4549,7 @@ describe('TextEncoderTest', function () { i++; arr[i]=entry[1]; i++; - }; + } expect(arr[1]).assertEqual(10) expect(arr[3]).assertEqual(2) expect(arr[5]).assertEqual(20) @@ -4489,7 +4572,7 @@ describe('TextEncoderTest', function () { i++; arr[i]=entry[1]; i++; - }; + } expect(arr[1]).assertEqual('abc'); }) @@ -4512,7 +4595,7 @@ describe('TextEncoderTest', function () { i++; arr[i]=entry[1]; i++; - }; + } expect(arr[1]).assertEqual(2); }) @@ -4536,7 +4619,7 @@ describe('TextEncoderTest', function () { i++; arr[i]=entry[1]; i++; - }; + } expect(arr[0]).assertEqual(1); }) @@ -4561,7 +4644,7 @@ describe('TextEncoderTest', function () { i++; arr[i]=entry[1]; i++; - }; + } expect(arr[1]).assertEqual(15) expect(arr[3]).assertEqual(20) }) @@ -4590,7 +4673,7 @@ describe('TextEncoderTest', function () { i++; arr[i]=entry[1]; i++; - }; + } expect(arr[1]).assertEqual(10) expect(arr[3]).assertEqual(2) expect(arr[5]).assertEqual(20) @@ -4765,4 +4848,2307 @@ describe('TextEncoderTest', function () { ChildLruBuffer.getInstance().afterRemoval(true,'abc','ab','string') expect(arr[2]).assertEqual('string') }) -}) \ No newline at end of file +}) + +describe('TypesTest', function() { + + /** + * @tc.name: testIsAnyArrayBuffer001 + * @tc.desc: Check whether the entered value is of arraybuffer or sharedarraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAnyArrayBuffer001', 0, function() { + var proc = new util.Types(); + var result = proc.isAnyArrayBuffer(new ArrayBuffer([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsAnyArrayBuffer002 + * @tc.desc: Check whether the entered value is of arraybuffer or sharedarraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAnyArrayBuffer002', 0, function() { + var proc = new util.Types(); + var result = proc.isAnyArrayBuffer(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsAnyArrayBuffer003 + * @tc.desc: Check whether the entered value is of arraybuffer or sharedarraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAnyArrayBuffer003', 0, function() { + var proc = new util.Types(); + var result = proc.isAnyArrayBuffer(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsAnyArrayBuffer004 + * @tc.desc: Check whether the entered value is of arraybuffer or sharedarraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAnyArrayBuffer004', 0, function() { + var proc = new util.Types(); + var buf = new ArrayBuffer(); + var result = proc.isAnyArrayBuffer(buf); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsAnyArrayBuffer005 + * @tc.desc: Check whether the entered value is of arraybuffer or sharedarraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAnyArrayBuffer005', 0, function() { + var proc = new util.Types(); + var result = proc.isAnyArrayBuffer(new Boolean(false)); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArrayBufferView001 + * @tc.desc: Check whether the entered value is napi_ int8_ array or napi_ uint8_ array + or naPi_ uint8_ clamped_ array or naPi_ int16_ array or naPi_ uint16_ array or napi_ int32_ array or napi_ + uint32_ array or napi_ float32_ array or napi_ float64_ array array or DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBufferView001', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBufferView(new Int8Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsArrayBufferView002 + * @tc.desc: Check whether the entered value is napi_ int8_ array or napi_ uint8_ array + or naPi_ uint8_ clamped_ array or naPi_ int16_ array or naPi_ uint16_ array or napi_ + int32_ array or napi_ uint32_ array or napi_ float32_ array or napi_ float64_ array array or DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBufferView002', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBufferView(new Int32Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsArrayBufferView003 + * @tc.desc: Check whether the entered value is napi_ int8_ array or napi_ uint8_ + array or naPi_ uint8_ clamped_ array or naPi_ int16_ array or naPi_ uint16_ array or napi_ int32_ array or + napi_ uint32_ array or napi_ float32_ array or napi_ float64_ array array or DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBufferView003', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBufferView(new DataView(new ArrayBuffer(16))); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsArrayBufferView004 + * @tc.desc: Check whether the entered value is napi_ int8_ array or napi_ uint8_ array or naPi_ uint8_ + clamped_ array or naPi_ int16_ array or naPi_ uint16_ array or napi_ int32_ array or napi_ uint32_ array or + napi_ float32_ array or napi_ float64_ array array or DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBufferView004', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBufferView(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArrayBufferView005 + * @tc.desc: Check whether the entered value is napi_ int8_ array or napi_ uint8_ array or naPi_ uint8_ + clamped_ array or naPi_ int16_ array or naPi_ uint16_ array or napi_ int32_ array or napi_ uint32_ array or + napi_ float32_ array or napi_ float64_ array array or DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBufferView005', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBufferView(new Int16Array()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsArgumentsObject001 + * @tc.desc: Check whether the entered value is an arguments object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArgumentsObject001', 0, function() { + var proc = new util.Types(); + function foo() { + var result = proc.isArgumentsObject(arguments); + expect(result).assertEqual(true); + } + var f = foo(); + }) + + /** + * @tc.name: testIsArgumentsObject002 + * @tc.desc: Check whether the entered value is an arguments object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArgumentsObject002', 0, function() { + var proc = new util.Types(); + var result = proc.isArgumentsObject(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArgumentsObject003 + * @tc.desc: Check whether the entered value is an arguments object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArgumentsObject003', 0, function() { + var proc = new util.Types(); + var result = proc.isArgumentsObject(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArgumentsObject004 + * @tc.desc: Check whether the entered value is an arguments object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArgumentsObject004', 0, function() { + var proc = new util.Types(); + var result = proc.isArgumentsObject(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArgumentsObject005 + * @tc.desc: Check whether the entered value is an arguments object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArgumentsObject005', 0, function() { + var proc = new util.Types(); + var result = proc.isArgumentsObject(new Boolean()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArrayBuffer001 + * @tc.desc: Check whether the entered value is of arraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBuffer001', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBuffer(new ArrayBuffer([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsArrayBuffer002 + * @tc.desc: Check whether the entered value is of arraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBuffer002', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBuffer(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArrayBuffer003 + * @tc.desc: Check whether the entered value is of arraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBuffer003', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBuffer(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArrayBuffer004 + * @tc.desc: Check whether the entered value is of arraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBuffer004', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBuffer(new Int8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsArrayBuffer005 + * @tc.desc: Check whether the entered value is of arraybuffer type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsArrayBuffer005', 0, function() { + var proc = new util.Types(); + var result = proc.isArrayBuffer(new Int16Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsAsyncFunction001 + * @tc.desc: Check whether the value entered is an asynchronous function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAsyncFunction001', 0, function() { + var proc = new util.Types(); + var result = proc.isAsyncFunction(async function foo() {}); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsAsyncFunction002 + * @tc.desc: Check whether the value entered is an asynchronous function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAsyncFunction002', 0, function() { + var proc = new util.Types(); + var result = proc.isAsyncFunction(function foo() {}); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsAsyncFunction003 + * @tc.desc: Check whether the value entered is an asynchronous function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAsyncFunction003', 0, function() { + var proc = new util.Types(); + var result = proc.isAsyncFunction(new Int8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsAsyncFunction004 + * @tc.desc: Check whether the value entered is an asynchronous function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAsyncFunction004', 0, function() { + var proc = new util.Types(); + var result = proc.isAsyncFunction(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsAsyncFunction005 + * @tc.desc: Check whether the value entered is an asynchronous function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsAsyncFunction005', 0, function() { + var proc = new util.Types(); + var result = proc.isAsyncFunction(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBigInt64Array001 + * @tc.desc: Check whether the entered value is of bigint64array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBigInt64Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isBigInt64Array(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBigUint64Array001 + * @tc.desc: Check whether the entered value is of biguint64array array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBigUint64Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isBigUint64Array(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBooleanObject001 + * @tc.desc: Check whether the entered value is a Boolean object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBooleanObject001', 0, function() { + var proc = new util.Types(); + var result = proc.isBooleanObject(new Boolean(false)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsBooleanObject002 + * @tc.desc: Check whether the entered value is a Boolean object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBooleanObject002', 0, function() { + var proc = new util.Types(); + var result = proc.isBooleanObject(new Boolean(true)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsBooleanObject003 + * @tc.desc: Check whether the entered value is a Boolean object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBooleanObject003', 0, function() { + var proc = new util.Types(); + var result = proc.isBooleanObject(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBooleanObject004 + * @tc.desc: Check whether the entered value is a Boolean object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBooleanObject004', 0, function() { + var proc = new util.Types(); + var result = proc.isBooleanObject(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBooleanObject005 + * @tc.desc: Check whether the entered value is a Boolean object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBooleanObject005', 0, function() { + var proc = new util.Types(); + var result = proc.isBooleanObject(Boolean(true)); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBoxedPrimitive001 + * @tc.desc: Check whether the entered value is a Boolean or number or string or symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBoxedPrimitive001', 0, function() { + var proc = new util.Types(); + var result = proc.isBoxedPrimitive(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBoxedPrimitive002 + * @tc.desc: Check whether the entered value is a Boolean or number or string or symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBoxedPrimitive002', 0, function() { + var proc = new util.Types(); + var result = proc.isBoxedPrimitive(new Boolean(false)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsBoxedPrimitive003 + * @tc.desc: Check whether the entered value is a Boolean or number or string or symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBoxedPrimitive003', 0, function() { + var proc = new util.Types(); + var result = proc.isBoxedPrimitive(Symbol('foo')); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsBoxedPrimitive004 + * @tc.desc: Check whether the entered value is a Boolean or number or string or symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBoxedPrimitive004', 0, function() { + var proc = new util.Types(); + var result = proc.isBoxedPrimitive(Object(Symbol('foo'))); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsBoxedPrimitive005 + * @tc.desc: Check whether the entered value is a Boolean or number or string or symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsBoxedPrimitive005', 0, function() { + var proc = new util.Types(); + var result = proc.isBoxedPrimitive(new Boolean(true)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsDataView001 + * @tc.desc: Check whether the entered value is of DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDataView001', 0, function() { + var proc = new util.Types(); + const ab = new ArrayBuffer(20); + var result = proc.isDataView(new DataView(ab)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsDataView002 + * @tc.desc: Check whether the entered value is of DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDataView002', 0, function() { + var proc = new util.Types(); + var result = proc.isDataView(new Int8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsDataView003 + * @tc.desc: Check whether the entered value is of DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDataView003', 0, function() { + var proc = new util.Types(); + var result = proc.isDataView(new Float64Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsDataView004 + * @tc.desc: Check whether the entered value is of DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDataView004', 0, function() { + var proc = new util.Types(); + var result = proc.isDataView(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsDataView005 + * @tc.desc: Check whether the entered value is of DataView type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDataView005', 0, function() { + var proc = new util.Types(); + var result = proc.isDataView(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsDate001 + * @tc.desc: Check whether the entered value is of type date. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDate001', 0, function() { + var proc = new util.Types(); + var result = proc.isDate(new Date()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsDate002 + * @tc.desc: Check whether the entered value is of type date. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDate002', 0, function() { + var proc = new util.Types(); + var result = proc.isDate(new Int8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsDate003 + * @tc.desc: Check whether the entered value is of type date. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDate003', 0, function() { + var proc = new util.Types(); + var result = proc.isDate(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsDate004 + * @tc.desc: Check whether the entered value is of type date. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDate004', 0, function() { + var proc = new util.Types(); + var result = proc.isDate(new Int16Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsDate005 + * @tc.desc: Check whether the entered value is of type date. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsDate005', 0, function() { + var proc = new util.Types(); + var result = proc.isDate(new Float64Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsExternal001 + * @tc.desc: Check whether the entered value is a native external value type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsExternal001', 0, function() { + var proc = new util.Types(); + const data = util.createExternalType(); + var result = proc.isExternal(data); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsExternal002 + * @tc.desc: Check whether the entered value is a native external value type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsExternal002', 0, function() { + var proc = new util.Types(); + var result = proc.isExternal(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsExternal003 + * @tc.desc: Check whether the entered value is a native external value type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsExternal003', 0, function() { + var proc = new util.Types(); + var result = proc.isExternal(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsExternal004 + * @tc.desc: Check whether the entered value is a native external value type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsExternal004', 0, function() { + var proc = new util.Types(); + var result = proc.isExternal(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsExternal005 + * @tc.desc: Check whether the entered value is a native external value type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsExternal005', 0, function() { + var proc = new util.Types(); + var result = proc.isExternal(new Int16Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat32Array001 + * @tc.desc: Check whether the entered value is of float32array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat32Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat32Array(new Float32Array()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsFloat32Array002 + * @tc.desc: Check whether the entered value is of float32array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat32Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat32Array(new Int8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat32Array003 + * @tc.desc: Check whether the entered value is of float32array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat32Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat32Array(new Int16Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat32Array004 + * @tc.desc: Check whether the entered value is of float32array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat32Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat32Array(new Float64Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat32Array005 + * @tc.desc: Check whether the entered value is of float32array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat32Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat32Array(new Uint8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat64Array001 + * @tc.desc: Check whether the entered value is of float64array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat64Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat64Array(new Float64Array()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsFloat64Array002 + * @tc.desc: Check whether the entered value is of float64array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat64Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat64Array(new Int8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat64Array003 + * @tc.desc: Check whether the entered value is of float64array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat64Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat64Array(new Float32Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat64Array004 + * @tc.desc: Check whether the entered value is of float64array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat64Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat64Array(new Uint8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsFloat64Array005 + * @tc.desc: Check whether the entered value is of float64array array type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsFloat64Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isFloat64Array(new Int16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorFunction001 + * @tc.desc: Check whether the input value is a generator function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsGeneratorFunction001', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorFunction(function* foo() {}); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsGeneratorFunction002 + * @tc.desc: Check whether the input value is a generator function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsGeneratorFunction002', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorFunction(function foo() {}); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorFunction003 + * @tc.desc: Check whether the input value is a generator function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsGeneratorFunction003', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorFunction(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorFunction004 + * @tc.desc: Check whether the input value is a generator function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsGeneratorFunction004', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorFunction(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorFunction005 + * @tc.desc: Check whether the input value is a generator function type. + * @tc.require: AR000GFB59 + * @tc.author: wangjingwu + */ + it('testIsGeneratorFunction005', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorFunction(new Int8Array()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorObject001 + * @tc.desc: Check whether the entered value is a generator object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsGeneratorObject001', 0, function() { + var proc = new util.Types(); + function* foo() {} + const generator = foo(); + var result = proc.isGeneratorObject(generator); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsGeneratorObject002 + * @tc.desc: Check whether the entered value is a generator object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsGeneratorObject002', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorObject(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorObject003 + * @tc.desc: Check whether the entered value is a generator object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsGeneratorObject003', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorObject(new Int16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorObject004 + * @tc.desc: Check whether the entered value is a generator object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsGeneratorObject004', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorObject(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsGeneratorObject005 + * @tc.desc: Check whether the entered value is a generator object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsGeneratorObject005', 0, function() { + var proc = new util.Types(); + var result = proc.isGeneratorObject(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt8Array001 + * @tc.desc: Check whether the entered value is of int8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt8Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isInt8Array(new Int8Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsInt8Array002 + * @tc.desc: Check whether the entered value is of int8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt8Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isInt8Array(new ArrayBuffer([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt8Array003 + * @tc.desc: Check whether the entered value is of int8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt8Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isInt8Array(new Int32Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt8Array004 + * @tc.desc: Check whether the entered value is of int8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt8Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isInt8Array(new Float64Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt8Array005 + * @tc.desc: Check whether the entered value is of int8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt8Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isInt8Array(new Uint8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt16Array001 + * @tc.desc: Check whether the entered value is the int16array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt16Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isInt16Array(new Int16Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsInt16Array002 + * @tc.desc: Check whether the entered value is the int16array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt16Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isInt16Array(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt16Array003 + * @tc.desc: Check whether the entered value is the int16array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt16Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isInt16Array(new Int32Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt16Array004 + * @tc.desc: Check whether the entered value is the int16array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt16Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isInt16Array(new Uint8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt16Array005 + * @tc.desc: Check whether the entered value is the int16array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt16Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isInt16Array(new Float64Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt32Array001 + * @tc.desc: Check whether the entered value is the int32array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt32Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isInt32Array(new Int32Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsInt32Array002 + * @tc.desc: Check whether the entered value is the int32array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt32Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isInt32Array(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt32Array003 + * @tc.desc: Check whether the entered value is the int32array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt32Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isInt32Array(new Int16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt32Array004 + * @tc.desc: Check whether the entered value is the int32array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt32Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isInt32Array(new Float64Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsInt32Array005 + * @tc.desc: Check whether the entered value is the int32array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsInt32Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isInt32Array(new Uint8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsMap001 + * @tc.desc: Check whether the entered value is of map type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMap001', 0, function() { + var proc = new util.Types(); + var result = proc.isMap(new Map()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsMap002 + * @tc.desc: Check whether the entered value is of map type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMap002', 0, function() { + var proc = new util.Types(); + var result = proc.isMap(new Set()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsMap003 + * @tc.desc: Check whether the entered value is of map type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMap003', 0, function() { + var proc = new util.Types(); + var result = proc.isMap(new String()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsMap004 + * @tc.desc: Check whether the entered value is of map type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMap004', 0, function() { + var proc = new util.Types(); + var result = proc.isMap(new Object()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsMap005 + * @tc.desc: Check whether the entered value is of map type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMap005', 0, function() { + var proc = new util.Types(); + var result = proc.isMap(new Boolean()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsMapIterator001 + * @tc.desc: Check whether the entered value is the iterator type of map. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMapIterator001', 0, function() { + var proc = new util.Types(); + const map = new Map(); + var result = proc.isMapIterator(map.keys()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsMapIterator002 + * @tc.desc: Check whether the entered value is the iterator type of map. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMapIterator002', 0, function() { + var proc = new util.Types(); + const map = new Map(); + var result = proc.isMapIterator(map.values()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsMapIterator003 + * @tc.desc: Check whether the entered value is the iterator type of map. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMapIterator003', 0, function() { + var proc = new util.Types(); + const map = new Map(); + var result = proc.isMapIterator(map.entries()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsMapIterator004 + * @tc.desc: Check whether the entered value is the iterator type of map. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMapIterator004', 0, function() { + var proc = new util.Types(); + const map = new Map(); + var result = proc.isMapIterator(map[Symbol.iterator]()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsMapIterator005 + * @tc.desc: Check whether the entered value is the iterator type of map. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsMapIterator005', 0, function() { + var proc = new util.Types(); + const map = new Map(); + var result = proc.isMapIterator(map); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsModuleNamespaceObject001 + * @tc.desc: Check whether the entered value is the module namespace object object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsModuleNamespaceObject001', 0, function() { + var proc = new util.Types(); + var result = proc.isModuleNamespaceObject(util); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsModuleNamespaceObject002 + * @tc.desc: Check whether the entered value is the module namespace object object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsModuleNamespaceObject002', 0, function() { + var proc = new util.Types(); + var result = proc.isModuleNamespaceObject(url); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsModuleNamespaceObject003 + * @tc.desc: Check whether the entered value is the module namespace object object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsModuleNamespaceObject003', 0, function() { + var proc = new util.Types(); + var result = proc.isModuleNamespaceObject(file); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsModuleNamespaceObject004 + * @tc.desc: Check whether the entered value is the module namespace object object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsModuleNamespaceObject004', 0, function() { + var proc = new util.Types(); + var result = proc.isModuleNamespaceObject(process); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsModuleNamespaceObject005 + * @tc.desc: Check whether the entered value is the module namespace object object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsModuleNamespaceObject005', 0, function() { + var proc = new util.Types(); + var result = proc.isModuleNamespaceObject(app); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsNativeError001 + * @tc.desc: Check whether the value entered is of type error. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNativeError001', 0, function() { + var proc = new util.Types(); + var result = proc.isNativeError(new TypeError()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsNativeError002 + * @tc.desc: Check whether the value entered is of type error. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNativeError002', 0, function() { + var proc = new util.Types(); + var result = proc.isNativeError(new Error()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsNativeError003 + * @tc.desc: Check whether the value entered is of type error. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNativeError003', 0, function() { + var proc = new util.Types(); + var result = proc.isNativeError(new RangeError()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsNativeError004 + * @tc.desc: Check whether the value entered is of type error. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNativeError004', 0, function() { + var proc = new util.Types(); + var result = proc.isNativeError(true); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsNativeError005 + * @tc.desc: Check whether the value entered is of type error. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNativeError005', 0, function() { + var proc = new util.Types(); + var result = proc.isNativeError(false); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsNumberObject001 + * @tc.desc: Check whether the entered value is of the number object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNumberObject001', 0, function() { + var proc = new util.Types(); + var result = proc.isNumberObject(new Number(0)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsNumberObject002 + * @tc.desc: Check whether the entered value is of the number object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNumberObject002', 0, function() { + var proc = new util.Types(); + var result = proc.isNumberObject(new Number(10)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsNumberObject003 + * @tc.desc: Check whether the entered value is of the number object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNumberObject003', 0, function() { + var proc = new util.Types(); + var result = proc.isNumberObject(new Number(200)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsNumberObject004 + * @tc.desc: Check whether the entered value is of the number object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNumberObject004', 0, function() { + var proc = new util.Types(); + var result = proc.isNumberObject(0); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsNumberObject005 + * @tc.desc: Check whether the entered value is of the number object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsNumberObject005', 0, function() { + var proc = new util.Types(); + var result = proc.isNumberObject(100); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsPromise001 + * @tc.desc: Check whether the entered value is of promise type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsPromise001', 0, function() { + var proc = new util.Types(); + var result = proc.isPromise(Promise.resolve(42)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsPromise002 + * @tc.desc: Check whether the entered value is of promise type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsPromise002', 0, function() { + var proc = new util.Types(); + var result = proc.isPromise(Promise.resolve(33)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsPromise003 + * @tc.desc: Check whether the entered value is of promise type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsPromise003', 0, function() { + var proc = new util.Types(); + var result = proc.isPromise(Promise.resolve(44)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsPromise004 + * @tc.desc: Check whether the entered value is of promise type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsPromise004', 0, function() { + var proc = new util.Types(); + var err = Error(33); + var result = proc.isPromise(Promise.reject(err )); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsPromise005 + * @tc.desc: Check whether the entered value is of promise type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsPromise005', 0, function() { + var proc = new util.Types(); + var result = proc.isPromise(Promise.reject(23)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsProxy001 + * @tc.desc: Check whether the value entered is of proxy type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsProxy001', 0, function() { + var proc = new util.Types(); + const target = {}; + const proxy = new Proxy(target, {}); + var result = proc.isProxy(proxy); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsProxy002 + * @tc.desc: Check whether the value entered is of proxy type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsProxy002', 0, function() { + var proc = new util.Types(); + const target = {}; + const proxy = new Proxy(target, {}); + var result = proc.isProxy(target); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsProxy003 + * @tc.desc: Check whether the value entered is of proxy type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsProxy003', 0, function() { + var proc = new util.Types(); + const handler = { + get: function(obj, prop) { + return prop in obj ? obj[prop] : 37; + } + }; + const p = new Proxy({}, handler); + var result = proc.isProxy(p); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsProxy004 + * @tc.desc: Check whether the value entered is of proxy type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsProxy004', 0, function() { + var proc = new util.Types(); + const handler = { + get: function(obj, prop) { + return prop in obj ? obj[prop] : 121; + } + }; + const p = new Proxy({}, handler); + var result = proc.isProxy(p); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsProxy005 + * @tc.desc: Check whether the value entered is of proxy type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsProxy005', 0, function() { + var proc = new util.Types(); + const handler = { + get: function(obj, prop) { + return prop in obj ? obj[prop] : 121; + } + }; + const p = new Proxy({}, handler); + var result = proc.isProxy(handler); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsRegExp001 + * @tc.desc: Check whether the entered value is of type regexp. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsRegExp001', 0, function() { + var proc = new util.Types(); + var result = proc.isRegExp(new RegExp('abc')); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsRegExp002 + * @tc.desc: Check whether the entered value is of type regexp. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsRegExp002', 0, function() { + var proc = new util.Types(); + var result = proc.isRegExp(/abc/); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsRegExp003 + * @tc.desc: Check whether the entered value is of type regexp. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsRegExp003', 0, function() { + var proc = new util.Types(); + var result = proc.isRegExp(new RegExp('fgd')); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsRegExp004 + * @tc.desc: Check whether the entered value is of type regexp. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsRegExp004', 0, function() { + var proc = new util.Types(); + var result = proc.isRegExp(new RegExp('123')); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsRegExp005 + * @tc.desc: Check whether the entered value is of type regexp. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsRegExp005', 0, function() { + var proc = new util.Types(); + var result = proc.isRegExp(new RegExp(/ab+c/, 'i')); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSet001 + * @tc.desc: Check whether the entered value is of type set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSet001', 0, function() { + var proc = new util.Types(); + var result = proc.isSet(new Set()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSet002 + * @tc.desc: Check whether the entered value is of type set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSet002', 0, function() { + var proc = new util.Types(); + var result = proc.isSet(new Map()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSet003 + * @tc.desc: Check whether the entered value is of type set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSet003', 0, function() { + var proc = new util.Types(); + var result = proc.isSet(new String()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSet004 + * @tc.desc: Check whether the entered value is of type set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSet004', 0, function() { + var proc = new util.Types(); + var result = proc.isSet(new Boolean()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSet005 + * @tc.desc: Check whether the entered value is of type set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSet005', 0, function() { + var proc = new util.Types(); + var result = proc.isSet(new WeakSet()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSetIterator001 + * @tc.desc: Check whether the entered value is the iterator type of set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSetIterator001', 0, function() { + var proc = new util.Types(); + const set = new Set(); + var result = proc.isSetIterator(set.keys()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSetIterator002 + * @tc.desc: Check whether the entered value is the iterator type of set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSetIterator002', 0, function() { + var proc = new util.Types(); + const set = new Set(); + var result = proc.isSetIterator(set.values()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSetIterator003 + * @tc.desc: Check whether the entered value is the iterator type of set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSetIterator003', 0, function() { + var proc = new util.Types(); + const set = new Set(); + var result = proc.isSetIterator(set.entries()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSetIterator004 + * @tc.desc: Check whether the entered value is the iterator type of set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSetIterator004', 0, function() { + var proc = new util.Types(); + const set = new Set(); + var result = proc.isSetIterator(set[Symbol.iterator]()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSetIterator005 + * @tc.desc: Check whether the entered value is the iterator type of set. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSetIterator005', 0, function() { + var proc = new util.Types(); + const set = new Set(); + var result = proc.isSetIterator(set); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSharedArrayBuffer001 + * @tc.desc: Check whether the entered value is of type sharedarraybuffer. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSharedArrayBuffer001', 0, function() { + var proc = new util.Types(); + var result = proc.isSharedArrayBuffer(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSharedArrayBuffer002 + * @tc.desc: Check whether the entered value is of type sharedarraybuffer. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSharedArrayBuffer002', 0, function() { + var proc = new util.Types(); + var result = proc.isSharedArrayBuffer(new Int16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSharedArrayBuffer003 + * @tc.desc: Check whether the entered value is of type sharedarraybuffer. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSharedArrayBuffer003', 0, function() { + var proc = new util.Types(); + var result = proc.isSharedArrayBuffer(new Int32Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSharedArrayBuffer004 + * @tc.desc: Check whether the entered value is of type sharedarraybuffer. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSharedArrayBuffer004', 0, function() { + var proc = new util.Types(); + var result = proc.isSharedArrayBuffer(new ArrayBuffer([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSharedArrayBuffer005 + * @tc.desc: Check whether the entered value is of type sharedarraybuffer. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSharedArrayBuffer005', 0, function() { + var proc = new util.Types(); + var result = proc.isSharedArrayBuffer(new Uint8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsStringObject001 + * @tc.desc: Check whether the entered value is a string object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsStringObject001', 0, function() { + var proc = new util.Types(); + var result = proc.isStringObject(new String('foo')); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsStringObject002 + * @tc.desc: Check whether the entered value is a string object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsStringObject002', 0, function() { + var proc = new util.Types(); + var result = proc.isStringObject(new String('twoo')); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsStringObject003 + * @tc.desc: Check whether the entered value is a string object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsStringObject003', 0, function() { + var proc = new util.Types(); + var result = proc.isStringObject(new String('fdfsfd')); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsStringObject004 + * @tc.desc: Check whether the entered value is a string object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsStringObject004', 0, function() { + var proc = new util.Types(); + var result = proc.isStringObject('ffds111'); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsStringObject005 + * @tc.desc: Check whether the entered value is a string object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsStringObject005', 0, function() { + var proc = new util.Types(); + var result = proc.isStringObject('foo'); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSymbolObject001 + * @tc.desc: Check whether the entered value is a symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSymbolObject001', 0, function() { + var proc = new util.Types(); + const symbols = Symbol('foo'); + var result = proc.isSymbolObject(Object(symbols)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSymbolObject002 + * @tc.desc: Check whether the entered value is a symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSymbolObject002', 0, function() { + var proc = new util.Types(); + const symbols = Symbol('s12'); + var result = proc.isSymbolObject(Object(symbols)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSymbolObject003 + * @tc.desc: Check whether the entered value is a symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSymbolObject003', 0, function() { + var proc = new util.Types(); + const symbols = Symbol('sads'); + var result = proc.isSymbolObject(Object(symbols)); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsSymbolObject004 + * @tc.desc: Check whether the entered value is a symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSymbolObject004', 0, function() { + var proc = new util.Types(); + const symbols = Symbol('asdd'); + var result = proc.isSymbolObject(symbols); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsSymbolObject005 + * @tc.desc: Check whether the entered value is a symbol object type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsSymbolObject005', 0, function() { + var proc = new util.Types(); + const symbols = Symbol('foo'); + var result = proc.isSymbolObject(symbols); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsTypedArray001 + * @tc.desc: Check whether the entered value is a type contained in typedarray. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsTypedArray001', 0, function() { + var proc = new util.Types(); + var result = proc.isTypedArray(new Float64Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsTypedArray002 + * @tc.desc: Check whether the entered value is a type contained in typedarray. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsTypedArray002', 0, function() { + var proc = new util.Types(); + var result = proc.isTypedArray(new Uint8Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsTypedArray003 + * @tc.desc: Check whether the entered value is a type contained in typedarray. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsTypedArray003', 0, function() { + var proc = new util.Types(); + var result = proc.isTypedArray(new Uint16Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsTypedArray004 + * @tc.desc: Check whether the entered value is a type contained in typedarray. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsTypedArray004', 0, function() { + var proc = new util.Types(); + var result = proc.isTypedArray(new Uint32Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsTypedArray005 + * @tc.desc: Check whether the entered value is a type contained in typedarray. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsTypedArray005', 0, function() { + var proc = new util.Types(); + var result = proc.isTypedArray(new ArrayBuffer()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8Array001 + * @tc.desc: Check whether the entered value is the uint8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8Array(new Uint8Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsUint8Array002 + * @tc.desc: Check whether the entered value is the uint8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8Array(new Uint16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8Array003 + * @tc.desc: Check whether the entered value is the uint8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8Array(new Uint32Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8Array004 + * @tc.desc: Check whether the entered value is the uint8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8Array(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8Array005 + * @tc.desc: Check whether the entered value is the uint8array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8Array(new Int16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8ClampedArray001 + * @tc.desc: Check whether the entered value is the uint8clapedarray array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8ClampedArray001', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8ClampedArray(new Uint8ClampedArray([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsUint8ClampedArray002 + * @tc.desc: Check whether the entered value is the uint8clapedarray array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8ClampedArray002', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8ClampedArray(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8ClampedArray003 + * @tc.desc: Check whether the entered value is the uint8clapedarray array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8ClampedArray003', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8ClampedArray(new Int16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8ClampedArray004 + * @tc.desc: Check whether the entered value is the uint8clapedarray array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8ClampedArray004', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8ClampedArray(new Int32Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint8ClampedArray005 + * @tc.desc: Check whether the entered value is the uint8clapedarray array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint8ClampedArray005', 0, function() { + var proc = new util.Types(); + var result = proc.isUint8ClampedArray(new Uint32Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint16Array001 + * @tc.desc: Check whether the entered value is the uint16array array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint16Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isUint16Array(new Uint16Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsUint16Array002 + * @tc.desc: Check whether the entered value is the uint16array array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint16Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isUint16Array(new Uint8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint16Array003 + * @tc.desc: Check whether the entered value is the uint16array array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint16Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isUint16Array(new Uint32Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint16Array004 + * @tc.desc: Check whether the entered value is the uint16array array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint16Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isUint16Array(new Uint8ClampedArray([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint16Array005 + * @tc.desc: Check whether the entered value is the uint16array array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint16Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isUint16Array(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint32Array001 + * @tc.desc: Check whether the entered value is the uint32array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint32Array001', 0, function() { + var proc = new util.Types(); + var result = proc.isUint32Array(new Uint32Array([])); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsUint32Array002 + * @tc.desc: Check whether the entered value is the uint32array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint32Array002', 0, function() { + var proc = new util.Types(); + var result = proc.isUint32Array(new Uint8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint32Array003 + * @tc.desc: Check whether the entered value is the uint32array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint32Array003', 0, function() { + var proc = new util.Types(); + var result = proc.isUint32Array(new Uint16Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint32Array004 + * @tc.desc: Check whether the entered value is the uint32array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint32Array004', 0, function() { + var proc = new util.Types(); + var result = proc.isUint32Array(new Int8Array([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsUint32Array005 + * @tc.desc: Check whether the entered value is the uint32array array type. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsUint32Array005', 0, function() { + var proc = new util.Types(); + var result = proc.isUint32Array(new Uint8ClampedArray([])); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakMap001 + * @tc.desc: Check whether the entered value is of type weakmap. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakMap001', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakMap(new WeakMap()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsWeakMap002 + * @tc.desc: Check whether the entered value is of type weakmap. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakMap002', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakMap(new Map()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakMap003 + * @tc.desc: Check whether the entered value is of type weakmap. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakMap003', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakMap(new Set()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakMap004 + * @tc.desc: Check whether the entered value is of type weakmap. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakMap004', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakMap(new String()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakMap005 + * @tc.desc: Check whether the entered value is of type weakmap. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakMap005', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakMap(new WeakSet()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakSet001 + * @tc.desc: Check whether the entered value is of type weakset. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakSet001', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakSet(new WeakSet()); + expect(result).assertEqual(true); + }) + + /** + * @tc.name: testIsWeakSet002 + * @tc.desc: Check whether the entered value is of type weakset. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakSet002', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakSet(new WeakMap()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakSet003 + * @tc.desc: Check whether the entered value is of type weakset. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakSet003', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakSet(new String()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakSet004 + * @tc.desc: Check whether the entered value is of type weakset. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakSet004', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakSet(new Set()); + expect(result).assertEqual(false); + }) + + /** + * @tc.name: testIsWeakSet005 + * @tc.desc: Check whether the entered value is of type weakset. + * @tc.require: AR000GFB59 + * @tc.author: bihu + */ + it('testIsWeakSet005', 0, function() { + var proc = new util.Types(); + var result = proc.isWeakSet(new Map()); + expect(result).assertEqual(false); + }) +}) diff --git a/compileruntime/util_lib_standard/src/main/resources/base/media/icon.png b/compileruntime/util_lib_standard/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/compileruntime/util_lib_standard/src/main/resources/base/media/icon.png differ diff --git a/compileruntime/util_lib_standard/src/ohosTest/js/default/app.js b/compileruntime/util_lib_standard/src/ohosTest/js/default/app.js deleted file mode 100644 index 4952e62fd96d8dcf3eb348d293249c2a18176c85..0000000000000000000000000000000000000000 --- a/compileruntime/util_lib_standard/src/ohosTest/js/default/app.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export default { - onCreate() { - console.info('TestApplication onCreate'); - }, - onDestroy() { - console.info('TestApplication onDestroy'); - } -}; diff --git a/compileruntime/util_lib_standard/src/ohosTest/js/default/pages/index/index.css b/compileruntime/util_lib_standard/src/ohosTest/js/default/pages/index/index.css deleted file mode 100644 index 6fda792753f2e15f22b529c7b90a82185b2770bf..0000000000000000000000000000000000000000 --- a/compileruntime/util_lib_standard/src/ohosTest/js/default/pages/index/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.container { - flex-direction: column; - justify-content: center; - align-items: center; -} - -.title { - font-size: 100px; -} diff --git a/compileruntime/util_lib_standard/src/ohosTest/resources/base/element/string.json b/compileruntime/util_lib_standard/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index ee04e287523beb449e633f5be2900410f7be79af..0000000000000000000000000000000000000000 --- a/compileruntime/util_lib_standard/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "childprocess" - }, - { - "name": "mainability_description", - "value": "hap sample empty page" - } - ] -} diff --git a/compileruntime/xml_lib_standard/BUILD.gn b/compileruntime/xml_lib_standard/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a7baea774bff02a8b741ce9804e07a8b90d71acf --- /dev/null +++ b/compileruntime/xml_lib_standard/BUILD.gn @@ -0,0 +1,39 @@ +# Copyright (C) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") +ohos_js_hap_suite("xml_js_test") { + hap_profile = "./src/main/config.json" + js2abc = true + deps = [ + ":xml_js_assets", + ":xml_resources", + ] + + # shared_libraries = [ + # "//third_party/giflib:libgif", + # "//third_party/libpng:libpng", + # ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "XmlJSApiTest" + + # part_name = "prebuilt_hap" + # subsystem_name = "xts" +} +ohos_js_assets("xml_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("xml_resources") { + sources = [ "./src/main/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/compileruntime/xml_lib_standard/Test.json b/compileruntime/xml_lib_standard/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..f8b778ac9d3da7d97a5220c0d5188e6287fb9835 --- /dev/null +++ b/compileruntime/xml_lib_standard/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for startup xml js api Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.xml", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "XmlJSApiTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/compileruntime/xml_lib_standard/signature/openharmony_sx.p7b b/compileruntime/xml_lib_standard/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/compileruntime/xml_lib_standard/signature/openharmony_sx.p7b differ diff --git a/compileruntime/xml_lib_standard/src/main/config.json b/compileruntime/xml_lib_standard/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..b2b4772f8e5b15e2b00bf7fd01ce4ebb9086309b --- /dev/null +++ b/compileruntime/xml_lib_standard/src/main/config.json @@ -0,0 +1,61 @@ +{ + "app": { + "bundleName": "com.example.xml", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.xml", + "name": ".MyApplication", + "mainAbility": "com.example.xml.MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.xml.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": true + } + } + ] + } +} \ No newline at end of file diff --git a/compileruntime/xml_lib_standard/src/main/js/default/app.js b/compileruntime/xml_lib_standard/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..e423f4bce4698ec1d7dc86c3eea3990a5e7b1085 --- /dev/null +++ b/compileruntime/xml_lib_standard/src/main/js/default/app.js @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/compileruntime/url_lib_standard/src/ohosTest/js/default/i18n/en-US.json b/compileruntime/xml_lib_standard/src/main/js/default/i18n/en-US.json similarity index 77% rename from compileruntime/url_lib_standard/src/ohosTest/js/default/i18n/en-US.json rename to compileruntime/xml_lib_standard/src/main/js/default/i18n/en-US.json index 55561b83737c3c31d082fbfa11e5fc987a351104..e63c70d978a3a53be988388c87182f81785e170c 100644 --- a/compileruntime/url_lib_standard/src/ohosTest/js/default/i18n/en-US.json +++ b/compileruntime/xml_lib_standard/src/main/js/default/i18n/en-US.json @@ -2,7 +2,5 @@ "strings": { "hello": "Hello", "world": "World" - }, - "Files": { } } \ No newline at end of file diff --git a/compileruntime/url_lib_standard/src/ohosTest/js/default/i18n/zh-CN.json b/compileruntime/xml_lib_standard/src/main/js/default/i18n/zh-CN.json similarity index 77% rename from compileruntime/url_lib_standard/src/ohosTest/js/default/i18n/zh-CN.json rename to compileruntime/xml_lib_standard/src/main/js/default/i18n/zh-CN.json index cce1af06761a42add0cac1a0567aa3237eda8cb4..de6ee5748322f44942c1b003319d8e66c837675f 100644 --- a/compileruntime/url_lib_standard/src/ohosTest/js/default/i18n/zh-CN.json +++ b/compileruntime/xml_lib_standard/src/main/js/default/i18n/zh-CN.json @@ -2,7 +2,5 @@ "strings": { "hello": "您好", "world": "世界" - }, - "Files": { } } \ No newline at end of file diff --git a/compileruntime/xml_lib_standard/src/main/js/default/pages/index/index.css b/compileruntime/xml_lib_standard/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..2b1965821483f4f8c8b97c86ef07fe87ea767d01 --- /dev/null +++ b/compileruntime/xml_lib_standard/src/main/js/default/pages/index/index.css @@ -0,0 +1,44 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 40px; + color: #000000; + opacity: 0.9; +} + +@media screen and (device-type: tablet) and (orientation: landscape) { + .title { + font-size: 100px; + } +} + +@media screen and (device-type: wearable) { + .title { + font-size: 28px; + color: #FFFFFF; + } +} + +@media screen and (device-type: tv) { + .container { + background-image: url("../../common/images/Wallpaper.png"); + background-size: cover; + background-repeat: no-repeat; + background-position: center; + } + + .title { + font-size: 100px; + color: #FFFFFF; + } +} + +@media screen and (device-type: phone) and (orientation: landscape) { + .title { + font-size: 60px; + } +} diff --git a/compileruntime/util_lib_standard/src/ohosTest/js/default/pages/index/index.hml b/compileruntime/xml_lib_standard/src/main/js/default/pages/index/index.hml similarity index 67% rename from compileruntime/util_lib_standard/src/ohosTest/js/default/pages/index/index.hml rename to compileruntime/xml_lib_standard/src/main/js/default/pages/index/index.hml index f64b040a5ae394dbaa5e185e1ecd4f4556b92184..abeadefb6faa934b6dc51d6bbcf66b765485e5ad 100644 --- a/compileruntime/util_lib_standard/src/ohosTest/js/default/pages/index/index.hml +++ b/compileruntime/xml_lib_standard/src/main/js/default/pages/index/index.hml @@ -1,4 +1,4 @@ -
+
{{ $t('strings.hello') }} {{ title }} diff --git a/compileruntime/url_lib_standard/src/ohosTest/js/test/ExampleJsunit.test.js b/compileruntime/xml_lib_standard/src/main/js/default/pages/index/index.js similarity index 57% rename from compileruntime/url_lib_standard/src/ohosTest/js/test/ExampleJsunit.test.js rename to compileruntime/xml_lib_standard/src/main/js/default/pages/index/index.js index d043e7e9479ed2a8e2751397c67d43c2ee8f7a08..eff21d421cc56ef14e78acefcc6a8ff275f60551 100644 --- a/compileruntime/url_lib_standard/src/ohosTest/js/test/ExampleJsunit.test.js +++ b/compileruntime/xml_lib_standard/src/main/js/default/pages/index/index.js @@ -13,13 +13,26 @@ * limitations under the License. */ +import file from '@system.file' import app from '@system.app' -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +import device from '@system.device' +import router from '@system.router' +import {Core} from 'deccjsunit/lite' -describe('appInfoTest', function () { - it('app_info_test_001', 0, function () { - var info = app.getInfo() - expect(info.versionName).assertEqual('1.0') - expect(info.versionCode).assertEqual('3') - }) -}) \ No newline at end of file +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + core.init() + require('../../../test/List.test') + core.execute() + }, + onReady() { + }, +} \ No newline at end of file diff --git a/compileruntime/util_lib_standard/src/ohosTest/js/test/List.test.js b/compileruntime/xml_lib_standard/src/main/js/test/List.test.js similarity index 94% rename from compileruntime/util_lib_standard/src/ohosTest/js/test/List.test.js rename to compileruntime/xml_lib_standard/src/main/js/test/List.test.js index 86ae9fa262b8d3fa27e4ac734dbd529d37d0b7cd..c3a6fb3c86ed8e5b19848d7e92b63d1bc44db547 100644 --- a/compileruntime/util_lib_standard/src/ohosTest/js/test/List.test.js +++ b/compileruntime/xml_lib_standard/src/main/js/test/List.test.js @@ -13,4 +13,4 @@ * limitations under the License. */ -require('./ExampleJsunit.test.js') \ No newline at end of file +require('./xml.test.js') \ No newline at end of file diff --git a/compileruntime/xml_lib_standard/src/main/js/test/xml.test.js b/compileruntime/xml_lib_standard/src/main/js/test/xml.test.js new file mode 100644 index 0000000000000000000000000000000000000000..0aa50cea3884af6d0432a72ce8e72cb5eb676d69 --- /dev/null +++ b/compileruntime/xml_lib_standard/src/main/js/test/xml.test.js @@ -0,0 +1,1397 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite' +import xml from '@ohos.xml' +describe('XmlSerializerXmlPullParserTest', function () { + /** + * @tc.name: testSetDeclaration001 + * @tc.desc: Writes xml declaration with encoding. For example: . + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDeclaration001', 0, function () { + var arrayBuffer = new ArrayBuffer(2048); + var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8"); + thatSer.setDeclaration(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDeclaration002 + * @tc.desc: Writes xml declaration with encoding. For example: . + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDeclaration002', 0, function () { + var arrayBuffer = new ArrayBuffer(2048); + var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8"); + thatSer.setDeclaration(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDeclaration003 + * @tc.desc: Writes xml declaration with encoding. For example: . + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDeclaration003', 0, function () { + var arrayBuffer = new ArrayBuffer(2048); + var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8"); + thatSer.setDeclaration(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDeclaration004 + * @tc.desc: Writes xml declaration with encoding. For example: . + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDeclaration004', 0, function () { + var arrayBuffer = new ArrayBuffer(2048); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDeclaration(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDeclaration005 + * @tc.desc: Writes xml declaration with encoding. For example: . + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDeclaration005', 0, function () { + var arrayBuffer = new ArrayBuffer(2048); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDeclaration(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testStartElement001 + * @tc.desc: Writes a elemnet start tag with the given name. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testStartElement001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note1"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testStartElement002 + * @tc.desc: Writes a elemnet start tag with the given name. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testStartElement002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note1"); + thatSer.endElement(); + thatSer.startElement("note2"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testStartElement003 + * @tc.desc: Writes a elemnet start tag with the given name. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testStartElement003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note1"); + thatSer.startElement("note2"); + thatSer.endElement(); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testStartElement004 + * @tc.desc: Writes a elemnet start tag with the given name. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testStartElement004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note1"); + thatSer.startElement("note2"); + thatSer.startElement("note3"); + thatSer.endElement(); + thatSer.endElement(); + thatSer.endElement(); + var result = '\r\n \r\n \r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testStartElement005 + * @tc.desc: Writes a elemnet start tag with the given name. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testStartElement005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note1"); + thatSer.startElement("note2"); + thatSer.endElement(); + thatSer.startElement("note3"); + thatSer.endElement(); + thatSer.endElement(); + var result = '\r\n \r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetAttributes001 + * @tc.desc: Write an attribute. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetAttributes001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance1", "high1"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetAttributes002 + * @tc.desc: Write an attribute. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetAttributes002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance1", "high1"); + thatSer.setAttributes("importance2", "high2"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetAttributes003 + * @tc.desc: Write an attribute. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetAttributes003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance1", "high1"); + thatSer.setAttributes("importance2", "high2"); + thatSer.setAttributes("importance3", "high3"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetAttributes004 + * @tc.desc: Write an attribute. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetAttributes004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance1", "high1"); + thatSer.setAttributes("importance2", "high2"); + thatSer.setAttributes("importance3", "high3"); + thatSer.setAttributes("importance4", "high4"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetAttributes005 + * @tc.desc: Write an attribute. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetAttributes005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance1", "high1"); + thatSer.setAttributes("importance2", "high2"); + thatSer.setAttributes("importance3", "high3"); + thatSer.setAttributes("importance5", "high5"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testEndElement001 + * @tc.desc: Writes end tag of the element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testEndElement001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testEndElement002 + * @tc.desc: Writes end tag of the element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testEndElement002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance", "high"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testEndElement003 + * @tc.desc: Writes end tag of the element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testEndElement003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("impo", "hi"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testEndElement004 + * @tc.desc: Writes end tag of the element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testEndElement004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note1"); + thatSer.startElement("note2"); + thatSer.endElement(); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testEndElement005 + * @tc.desc: Writes end tag of the element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testEndElement005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note2"); + thatSer.setAttributes("importance", "high"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetText001 + * @tc.desc: Writes the text. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetText001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance", "high"); + thatSer.setText("Happy1"); + thatSer.endElement(); + var result = 'Happy1'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetText002 + * @tc.desc: Writes the text. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetText002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance", "high"); + thatSer.setText("Happy2"); + thatSer.endElement(); + var result = 'Happy2'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetText003 + * @tc.desc: Writes the text. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetText003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance", "high"); + thatSer.setText("Happy3"); + thatSer.endElement(); + var result = 'Happy3'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetText004 + * @tc.desc: Writes the text. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetText004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance", "high"); + thatSer.setText("Happy4"); + thatSer.endElement(); + var result = 'Happy4'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetText005 + * @tc.desc: Writes the text. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetText005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance", "high"); + thatSer.setText("Happy5"); + thatSer.endElement(); + var result = 'Happy5'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testAddEmptyElement001 + * @tc.desc: Add an empty element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testAddEmptyElement001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.addEmptyElement("a"); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testAddEmptyElement002 + * @tc.desc: Add an empty element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testAddEmptyElement002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.endElement(); + thatSer.addEmptyElement("b"); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testAddEmptyElement003 + * @tc.desc: Add an empty element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testAddEmptyElement003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.addEmptyElement("c"); + thatSer.startElement("note"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testAddEmptyElement004 + * @tc.desc: Add an empty element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testAddEmptyElement004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.addEmptyElement("d"); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testAddEmptyElement005 + * @tc.desc: Add an empty element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testAddEmptyElement005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.addEmptyElement("c"); + thatSer.addEmptyElement("d"); + thatSer.endElement(); + var result = '\r\n \r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetNamespace001 + * @tc.desc: Writes the namespace of the current element tag. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetNamespace001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDeclaration(); + thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); + thatSer.startElement("note"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetNamespace002 + * @tc.desc: Writes the namespace of the current element tag. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetNamespace002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDeclaration(); + thatSer.setNamespace("b", "http://www.w3.org/TR/html4/"); + thatSer.startElement("note"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetNamespace003 + * @tc.desc: Writes the namespace of the current element tag. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetNamespace003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDeclaration(); + thatSer.setNamespace("h", "http://www.111/"); + thatSer.startElement("note"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetNamespace004 + * @tc.desc: Writes the namespace of the current element tag. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetNamespace004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); + thatSer.startElement("note1"); + thatSer.startElement("note2"); + thatSer.endElement(); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetNamespace005 + * @tc.desc: Writes the namespace of the current element tag. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetNamespace005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); + thatSer.startElement("note1"); + thatSer.startElement("note2"); + thatSer.endElement(); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCommnet001 + * @tc.desc: Writes the commnet. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCommnet001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setCommnet("Hi!"); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCommnet002 + * @tc.desc: Writes the commnet. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCommnet002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setCommnet("Hello, World!"); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCommnet003 + * @tc.desc: Writes the commnet. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCommnet003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setCommnet("Hello, World!"); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCommnet004 + * @tc.desc: Writes the commnet. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCommnet004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setCommnet("Hello, World!"); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCommnet005 + * @tc.desc: Writes the commnet. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCommnet005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setCommnet("Hello, World!"); + thatSer.startElement("note"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDocType001 + * @tc.desc: Writes the DOCTYPE. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDocType001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDocType('root SYSTEM'); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDocType002 + * @tc.desc: Writes the DOCTYPE. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDocType002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"'); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDocType003 + * @tc.desc: Writes the DOCTYPE. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDocType003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.endElement(); + thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"'); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDocType004 + * @tc.desc: Writes the DOCTYPE. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDocType004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"'); + thatSer.startElement("note"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDocType005 + * @tc.desc: Writes the DOCTYPE. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDocType005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"'); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCData001 + * @tc.desc: Writes the CDATA. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCData001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setCData('root SYSTEM') + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCData002 + * @tc.desc: Writes the CDATA. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCData002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setCData('root SYSTEM "http://www.test.org/test.dtd"') + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCData003 + * @tc.desc: Writes the CDATA. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCData003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.endElement(); + thatSer.setCData('root SYSTEM "http://www.test.org/test.dtd"') + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCData004 + * @tc.desc: Writes the CDATA. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCData004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setCData('root SYSTEM "http://www.test.org/test.dtd"') + thatSer.startElement("note"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCData005 + * @tc.desc: Writes the CDATA. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCData005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setCData('root SYSTEM "http://www.test.org/test.dtd"') + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testParse001 + * @tc.desc: Starts parsing the XML file. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testParse001', 0, function () { + var strXml = + '' + + ']>' + + '' + + ' ' + + ' ' + + ' John & Hans' + + ' Happy' + + ' Happy' + + ' Work' + + ' Play' + + ' ' + + ' ' + + ' ' + + ' ' + + ' Apples' + + ' Bananas' + + ' ' + + ' ' + + ''; + var arrayBuffer = new ArrayBuffer(strXml.length*2); + var bufView = new Uint8Array(arrayBuffer); + var strLen = strXml.length; + for (var i = 0; i < strLen; ++i) { + bufView[i] = strXml.charCodeAt(i); + } + var that = new xml.XmlPullParser(arrayBuffer, 'UTF-8'); + var arr = {}; + var i = 0; + function func3(key, info){ + arr[i] = 'key:' + JSON.stringify(key) + info.getDepth() + info.getColumnNumber() + info.getLineNumber() + + info.getAttributeCount() + info.getName() + info.getNamespace() + info.getPrefix() + info.getText() + + info.isEmptyElementTag()+ info.isWhitespace(); + i++; + return true; + } + var options = {supportDoctype:true, ignoreNameSpace:false, tokenValueCallbackFunction:func3} + that.parse(options); + var str = ''; + for(var j = 0; j < i; ++j) { + str = str + arr[j]; + } + var str1 = 'key:00110falsetruekey:702220 note [\n]falsefalsekey:216022notefalsefalsekey: + 1016420 falsetruekey:51470\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\nfalsetruekey:101870 + falsetruekey:612870Hello, World!falsetruekey:1013270 falsetruekey:224170companyfalsetruekey:424670 John + falsefalsekey:925170amp;amp;falsetruekey:425670 Hansfalsefalsekey:326670companyfalsetruekey:1017070 + falsetruekey:227770titlefalsetruekey:428270 Happyfalsefalsekey:329070titlefalsetruekey:1019470 + falsetruekey:2210170titlefalsetruekey:4210670 Happyfalsefalsekey:3211470titlefalsetruekey:10111870 + falsetruekey:2212470todofalsetruekey:4212870 Workfalsefalsekey:3213570todofalsetruekey:10113970 + falsetruekey:2214570todofalsetruekey:4214970 Playfalsefalsekey:3215670todofalsetruekey:10116070 + falsetruekey:8117270go therefalsetruekey:10117670 falsetruekey:2217970afalsetruekey:2318370btruetruekey: + 3318370bfalsetruekey:3218770afalsetruekey:10119170 falsetruekey:2223870table + http://www.w3.org/TR/html4/hfalsefalsekey:10224670 + falsetruekey:2325270tr http://www.w3.org/TR/html4/hfalsetruekey:10326470 + falsetruekey:2427070td http://www.w3.org/TR/html4/hfalsetruekey:4427670 Applesfalsefalsekey:3428370td + http://www.w3.org/TR/html4/hfalsetruekey:10329570 + falsetruekey:2430170td http://www.w3.org/TR/html4/hfalsetruekey:4430870 Bananasfalsefalsekey:3431570td + http://www.w3.org/TR/html4/hfalsetruekey:10332370 falsetruekey:3333070tr + http://www.w3.org/TR/html4/hfalsetruekey:10233470 falsetruekey:3234470table + http://www.w3.org/TR/html4/hfalsetruekey:3135170notefalsetruekey:10351130falsetrue'; + expect(str).assertEqual(str1); + }) + + /** + * @tc.name: testParse002 + * @tc.desc: Starts parsing the XML file. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testParse002', 0, function () { + var strXml = + '' + + ']>' + + '' + + ' ' + + ' ' + + ' John & Hans' + + ' Happy' + + ' Happy' + + ' Work' + + ' Play' + + ' ' + + ' ' + + ' ' + + ' ' + + ' Apples' + + ' Bananas' + + ' ' + + ' ' + + ''; + var arrayBuffer = new ArrayBuffer(strXml.length*2); + var bufView = new Uint8Array(arrayBuffer); + var strLen = strXml.length; + for (var i = 0; i < strLen; ++i) { + bufView[i] = strXml.charCodeAt(i); + } + var that = new xml.XmlPullParser(arrayBuffer); + var arr = {}; + var i = 0; + function func3(key, info){ + arr[i] = 'key:' + JSON.stringify(key) + info.getDepth() + info.getColumnNumber() + info.getLineNumber() + + info.getAttributeCount() + info.getName() + info.getNamespace() + info.getPrefix() + info.getText() + + info.isEmptyElementTag()+ info.isWhitespace(); + i++; + return true; + } + var options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func3} + that.parse(options); + var str = ''; + for(var j = 0; j < i; ++j) { + str = str + arr[j]; + } + var str1 = 'key:00110falsetruekey:702220 note [\n]falsefalsekey:216022notefalsefalsekey:1016420 falsetruekey:51470\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\nfalsetruekey:101870 falsetruekey:612870Hello, World!falsetruekey:1013270 falsetruekey:224170companyfalsetruekey:424670 John falsefalsekey:925170amp;amp;falsetruekey:425670 Hansfalsefalsekey:326670companyfalsetruekey:1017070 falsetruekey:227770titlefalsetruekey:428270 Happyfalsefalsekey:329070titlefalsetruekey:1019470 falsetruekey:2210170titlefalsetruekey:4210670 Happyfalsefalsekey:3211470titlefalsetruekey:10111870 falsetruekey:2212470todofalsetruekey:4212870 Workfalsefalsekey:3213570todofalsetruekey:10113970 falsetruekey:2214570todofalsetruekey:4214970 Playfalsefalsekey:3215670todofalsetruekey:10116070 falsetruekey:8117270go therefalsetruekey:10117670 falsetruekey:2217970afalsetruekey:2318370btruetruekey:3318370bfalsetruekey:3218770afalsetruekey:10119170 falsetruekey:2223871h:tablefalsefalsekey:10224670 falsetruekey:2325270h:trfalsetruekey:10326470 falsetruekey:2427070h:tdfalsetruekey:4427670 Applesfalsefalsekey:3428370h:tdfalsetruekey:10329570 falsetruekey:2430170h:tdfalsetruekey:4430870 Bananasfalsefalsekey:3431570h:tdfalsetruekey:10332370 falsetruekey:3333070h:trfalsetruekey:10233470 falsetruekey:3234470h:tablefalsetruekey:3135170notefalsetruekey:10351130falsetrue' + expect(str).assertEqual(str1) + }) + + /** + * @tc.name: testParse003 + * @tc.desc: Starts parsing the XML file. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testParse003', 0, function () { + var strXml = + '' + + ']>' + + '' + + ' ' + + ' ' + + ' John & Hans' + + ' Happy' + + ' Happy' + + ' Work' + + ' Play' + + ' ' + + ' ' + + ' ' + + ' ' + + ' Apples' + + ' Bananas' + + ' ' + + ' ' + + ''; + var arrayBuffer = new ArrayBuffer(strXml.length*2); + var bufView = new Uint8Array(arrayBuffer); + var strLen = strXml.length; + for (var i = 0; i < strLen; ++i) { + bufView[i] = strXml.charCodeAt(i); + } + var that = new xml.XmlPullParser(arrayBuffer, 'UTF-8'); + var arr = {}; + var i = 0; + function func3(key, info){ + arr[i] = 'key:' + JSON.stringify(key) + info.getDepth() + info.getColumnNumber() + info.getLineNumber() + + info.getAttributeCount() + info.getName() + info.getNamespace() + info.getPrefix() + info.getText() + + info.isEmptyElementTag()+ info.isWhitespace(); + i++; + return true; + } + var options = {supportDoctype:false, ignoreNameSpace:true, tokenValueCallbackFunction:func3} + that.parse(options); + var str = ''; + for(var j = 0; j < i; ++j) { + str = str + arr[j]; + } + var str1 = 'key:00110falsetruekey:216022notefalsefalsekey:1016420 falsetruekey:51470\r\nfuncrion + matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\nfalsetruekey:101870 falsetruekey:612870Hello, World!falsetruekey: + 1013270 falsetruekey:224170companyfalsetruekey:424670 John falsefalsekey:925170amp;amp;falsetruekey:425670 + Hansfalsefalsekey:326670companyfalsetruekey:1017070 falsetruekey:227770titlefalsetruekey:428270 + Happyfalsefalsekey:329070titlefalsetruekey:1019470 falsetruekey:2210170titlefalsetruekey:4210670 + Happyfalsefalsekey:3211470titlefalsetruekey:10111870 falsetruekey:2212470todofalsetruekey:4212870 + Workfalsefalsekey:3213570todofalsetruekey:10113970 falsetruekey:2214570todofalsetruekey:4214970 + Playfalsefalsekey:3215670todofalsetruekey:10116070 falsetruekey:8117270go therefalsetruekey:10117670 + falsetruekey:2217970afalsetruekey:2318370btruetruekey:3318370bfalsetruekey:3218770afalsetruekey:10119170 + falsetruekey:2223871h:tablefalsefalsekey:10224670 falsetruekey:2325270h:trfalsetruekey:10326470 + falsetruekey:2427070h:tdfalsetruekey:4427670 Applesfalsefalsekey:3428370h:tdfalsetruekey:10329570 + falsetruekey:2430170h:tdfalsetruekey:4430870 Bananasfalsefalsekey:3431570h:tdfalsetruekey:10332370 + falsetruekey:3333070h:trfalsetruekey:10233470 falsetruekey:3234470h:tablefalsetruekey: + 3135170notefalsetruekey:10351130falsetrue' + expect(str).assertEqual(str1); + + }) + + /** + * @tc.name: testParse004 + * @tc.desc: Starts parsing the XML file. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testParse004', 0, function () { + var strXml = + '' + + ']>' + + '' + + ' ' + + ' ' + + ' John & Hans' + + ' Happy' + + ' Happy' + + ' Work' + + ' Play' + + ' ' + + ' ' + + ' ' + + ' ' + + ' Apples' + + ' Bananas' + + ' ' + + ' ' + + ''; + var arrayBuffer = new ArrayBuffer(strXml.length*2); + var bufView = new Uint8Array(arrayBuffer); + var strLen = strXml.length; + for (var i = 0; i < strLen; ++i) { + bufView[i] = strXml.charCodeAt(i); + } + var that = new xml.XmlPullParser(arrayBuffer, 'UTF-8'); + var str = ''; + function func2(name, value){ + str += name+':'+value; + return true; + } + var options = {supportDoctype:true, ignoreNameSpace:true, attributeValueCallbackFunction:func2} + that.parse(options); + var str1= 'importance: highxmlns:h: http://www.w3.org/TR/html4/' + expect(str).assertEqual(str1); + }) + + /** + * @tc.name: testParse005 + * @tc.desc: Starts parsing the XML file. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testParse005', 0, function () { + var strXml = + '' + + ']>' + + '' + + ' ' + + ' ' + + ' John & Hans' + + ' Happy' + + ' Happy' + + ' Work' + + ' Play' + + ' ' + + ' ' + + ' ' + + ' ' + + ' Apples' + + ' Bananas' + + ' ' + + ' ' + + ''; + var arrayBuffer = new ArrayBuffer(strXml.length*2); + var bufView = new Uint8Array(arrayBuffer); + var strLen = strXml.length; + for (var i = 0; i < strLen; ++i) { + bufView[i] = strXml.charCodeAt(i); + } + var that = new xml.XmlPullParser(arrayBuffer, 'UTF-8'); + var str1 = ''; + function func1(name, value){ + str1 += name+':'+value; + return true; + } + var options = {supportDoctype:true, ignoreNameSpace:true, tagValueCallbackFunction:func1} + that.parse(options); + var str3 = 'note:company:title:title:todo:todo:a:b:h:table:h:tr:h:td:h:td:' + expect(str1).assertEqual(str3) + }) +}) \ No newline at end of file diff --git a/compileruntime/xml_lib_standard/src/main/js/test/xml.test.js.bak b/compileruntime/xml_lib_standard/src/main/js/test/xml.test.js.bak new file mode 100644 index 0000000000000000000000000000000000000000..788bddb09c0f153ccc6542ec6054dfec957a34b9 --- /dev/null +++ b/compileruntime/xml_lib_standard/src/main/js/test/xml.test.js.bak @@ -0,0 +1,1384 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/lite' +import xml from '@ohos.xml' +describe('XmlSerializerXmlPullParserTest', function () { + /** + * @tc.name: testSetDeclaration001 + * @tc.desc: Writes xml declaration with encoding. For example: . + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDeclaration001', 0, function () { + var arrayBuffer = new ArrayBuffer(2048); + var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8"); + thatSer.setDeclaration(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDeclaration002 + * @tc.desc: Writes xml declaration with encoding. For example: . + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDeclaration002', 0, function () { + var arrayBuffer = new ArrayBuffer(2048); + var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8"); + thatSer.setDeclaration(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDeclaration003 + * @tc.desc: Writes xml declaration with encoding. For example: . + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDeclaration003', 0, function () { + var arrayBuffer = new ArrayBuffer(2048); + var thatSer = new xml.XmlSerializer(arrayBuffer,"utf-8"); + thatSer.setDeclaration(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDeclaration004 + * @tc.desc: Writes xml declaration with encoding. For example: . + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDeclaration004', 0, function () { + var arrayBuffer = new ArrayBuffer(2048); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDeclaration(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDeclaration005 + * @tc.desc: Writes xml declaration with encoding. For example: . + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDeclaration005', 0, function () { + var arrayBuffer = new ArrayBuffer(2048); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDeclaration(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testStartElement001 + * @tc.desc: Writes a elemnet start tag with the given name. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testStartElement001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note1"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testStartElement002 + * @tc.desc: Writes a elemnet start tag with the given name. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testStartElement002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note1"); + thatSer.endElement(); + thatSer.startElement("note2"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testStartElement003 + * @tc.desc: Writes a elemnet start tag with the given name. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testStartElement003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note1"); + thatSer.startElement("note2"); + thatSer.endElement(); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testStartElement004 + * @tc.desc: Writes a elemnet start tag with the given name. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testStartElement004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note1"); + thatSer.startElement("note2"); + thatSer.startElement("note3"); + thatSer.endElement(); + thatSer.endElement(); + thatSer.endElement(); + var result = '\r\n \r\n \r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testStartElement005 + * @tc.desc: Writes a elemnet start tag with the given name. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testStartElement005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note1"); + thatSer.startElement("note2"); + thatSer.endElement(); + thatSer.startElement("note3"); + thatSer.endElement(); + thatSer.endElement(); + var result = '\r\n \r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetAttributes001 + * @tc.desc: Write an attribute. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetAttributes001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance1", "high1"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetAttributes002 + * @tc.desc: Write an attribute. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetAttributes002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance1", "high1"); + thatSer.setAttributes("importance2", "high2"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetAttributes003 + * @tc.desc: Write an attribute. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetAttributes003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance1", "high1"); + thatSer.setAttributes("importance2", "high2"); + thatSer.setAttributes("importance3", "high3"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetAttributes004 + * @tc.desc: Write an attribute. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetAttributes004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance1", "high1"); + thatSer.setAttributes("importance2", "high2"); + thatSer.setAttributes("importance3", "high3"); + thatSer.setAttributes("importance4", "high4"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetAttributes005 + * @tc.desc: Write an attribute. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetAttributes005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance1", "high1"); + thatSer.setAttributes("importance2", "high2"); + thatSer.setAttributes("importance3", "high3"); + thatSer.setAttributes("importance5", "high5"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testEndElement001 + * @tc.desc: Writes end tag of the element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testEndElement001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testEndElement002 + * @tc.desc: Writes end tag of the element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testEndElement002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance", "high"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testEndElement003 + * @tc.desc: Writes end tag of the element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testEndElement003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("impo", "hi"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testEndElement004 + * @tc.desc: Writes end tag of the element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testEndElement004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note1"); + thatSer.startElement("note2"); + thatSer.endElement(); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testEndElement005 + * @tc.desc: Writes end tag of the element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testEndElement005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note2"); + thatSer.setAttributes("importance", "high"); + thatSer.endElement(); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetText001 + * @tc.desc: Writes the text. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetText001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance", "high"); + thatSer.setText("Happy1"); + thatSer.endElement(); + var result = 'Happy1'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetText002 + * @tc.desc: Writes the text. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetText002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance", "high"); + thatSer.setText("Happy2"); + thatSer.endElement(); + var result = 'Happy2'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetText003 + * @tc.desc: Writes the text. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetText003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance", "high"); + thatSer.setText("Happy3"); + thatSer.endElement(); + var result = 'Happy3'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetText004 + * @tc.desc: Writes the text. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetText004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance", "high"); + thatSer.setText("Happy4"); + thatSer.endElement(); + var result = 'Happy4'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetText005 + * @tc.desc: Writes the text. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetText005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setAttributes("importance", "high"); + thatSer.setText("Happy5"); + thatSer.endElement(); + var result = 'Happy5'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testAddEmptyElement001 + * @tc.desc: Add an empty element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testAddEmptyElement001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.addEmptyElement("a"); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testAddEmptyElement002 + * @tc.desc: Add an empty element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testAddEmptyElement002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.endElement(); + thatSer.addEmptyElement("b"); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testAddEmptyElement003 + * @tc.desc: Add an empty element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testAddEmptyElement003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.addEmptyElement("c"); + thatSer.startElement("note"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testAddEmptyElement004 + * @tc.desc: Add an empty element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testAddEmptyElement004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.addEmptyElement("d"); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testAddEmptyElement005 + * @tc.desc: Add an empty element. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testAddEmptyElement005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.addEmptyElement("c"); + thatSer.addEmptyElement("d"); + thatSer.endElement(); + var result = '\r\n \r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetNamespace001 + * @tc.desc: Writes the namespace of the current element tag. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetNamespace001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDeclaration(); + thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); + thatSer.startElement("note"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetNamespace002 + * @tc.desc: Writes the namespace of the current element tag. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetNamespace002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDeclaration(); + thatSer.setNamespace("b", "http://www.w3.org/TR/html4/"); + thatSer.startElement("note"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetNamespace003 + * @tc.desc: Writes the namespace of the current element tag. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetNamespace003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDeclaration(); + thatSer.setNamespace("h", "http://www.111/"); + thatSer.startElement("note"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetNamespace004 + * @tc.desc: Writes the namespace of the current element tag. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetNamespace004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); + thatSer.startElement("note1"); + thatSer.startElement("note2"); + thatSer.endElement(); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetNamespace005 + * @tc.desc: Writes the namespace of the current element tag. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetNamespace005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); + thatSer.startElement("note1"); + thatSer.startElement("note2"); + thatSer.endElement(); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCommnet001 + * @tc.desc: Writes the commnet. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCommnet001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setCommnet("Hi!"); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCommnet002 + * @tc.desc: Writes the commnet. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCommnet002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setCommnet("Hello, World!"); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCommnet003 + * @tc.desc: Writes the commnet. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCommnet003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setCommnet("Hello, World!"); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCommnet004 + * @tc.desc: Writes the commnet. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCommnet004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setCommnet("Hello, World!"); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCommnet005 + * @tc.desc: Writes the commnet. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCommnet005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setCommnet("Hello, World!"); + thatSer.startElement("note"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDocType001 + * @tc.desc: Writes the DOCTYPE. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDocType001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDocType('root SYSTEM'); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDocType002 + * @tc.desc: Writes the DOCTYPE. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDocType002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"'); + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDocType003 + * @tc.desc: Writes the DOCTYPE. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDocType003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.endElement(); + thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"'); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDocType004 + * @tc.desc: Writes the DOCTYPE. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDocType004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"'); + thatSer.startElement("note"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetDocType005 + * @tc.desc: Writes the DOCTYPE. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetDocType005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setDocType('root SYSTEM "http://www.test.org/test.dtd"'); + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCData001 + * @tc.desc: Writes the CDATA. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCData001', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setCData('root SYSTEM') + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCData002 + * @tc.desc: Writes the CDATA. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCData002', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setCData('root SYSTEM "http://www.test.org/test.dtd"') + var result = ''; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCData003 + * @tc.desc: Writes the CDATA. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCData003', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.endElement(); + thatSer.setCData('root SYSTEM "http://www.test.org/test.dtd"') + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCData004 + * @tc.desc: Writes the CDATA. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCData004', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.setCData('root SYSTEM "http://www.test.org/test.dtd"') + thatSer.startElement("note"); + thatSer.endElement(); + var result = '\r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testSetCData005 + * @tc.desc: Writes the CDATA. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testSetCData005', 0, function () { + const myMAX = 2048; + var arrayBuffer = new ArrayBuffer(m_MAX); + var thatSer = new xml.XmlSerializer(arrayBuffer); + thatSer.startElement("note"); + thatSer.setCData('root SYSTEM "http://www.test.org/test.dtd"') + thatSer.endElement(); + var result = '\r\n \r\n'; + var view = new Uint8Array(arrayBuffer); + var view1 = ""; + for (var i = 0; i < result.length; ++i) { + view1 = view1 + String.fromCodePoint(view[i]); + } + expect(view1).assertEqual(result); + }) + + /** + * @tc.name: testParse001 + * @tc.desc: Starts parsing the XML file. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testParse001', 0, function () { + var strXml = + '' + + ']>' + + '' + + ' ' + + ' ' + + ' John & Hans' + + ' Happy' + + ' Happy' + + ' Work' + + ' Play' + + ' ' + + ' ' + + ' ' + + ' ' + + ' Apples' + + ' Bananas' + + ' ' + + ' ' + + ''; + var arrayBuffer = new ArrayBuffer(strXml.length*2); + var bufView = new Uint8Array(arrayBuffer); + var strLen = strXml.length; + for (var i = 0; i < strLen; ++i) { + bufView[i] = strXml.charCodeAt(i); + } + var that = new xml.XmlPullParser(arrayBuffer, 'UTF-8'); + var arr = {}; + var i = 0; + function func3(key, info){ + arr[i] = 'key:' + JSON.stringify(key) + info.getDepth() + info.getColumnNumber() + info.getLineNumber() + + info.getAttributeCount() + info.getName() + info.getNamespace() + info.getPrefix() + info.getText() + + info.isEmptyElementTag()+ info.isWhitespace(); + i++; + return true; + } + var options = {supportDoctype:true, ignoreNameSpace:false, tokenValueCallbackFunction:func3} + that.parse(options); + var str = ''; + for(var j = 0; j < i; ++j) { + str = str + arr[j]; + } + var str1 = 'key:00110falsetruekey:702220 note [\n]falsefalsekey:216022notefalsefalsekey: + 1016420 falsetruekey:51470\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\nfalsetruekey:101870 + falsetruekey:612870Hello, World!falsetruekey:1013270 falsetruekey:224170companyfalsetruekey:424670 John + falsefalsekey:925170amp;amp;falsetruekey:425670 Hansfalsefalsekey:326670companyfalsetruekey:1017070 + falsetruekey:227770titlefalsetruekey:428270 Happyfalsefalsekey:329070titlefalsetruekey:1019470 + falsetruekey:2210170titlefalsetruekey:4210670 Happyfalsefalsekey:3211470titlefalsetruekey:10111870 + falsetruekey:2212470todofalsetruekey:4212870 Workfalsefalsekey:3213570todofalsetruekey:10113970 + falsetruekey:2214570todofalsetruekey:4214970 Playfalsefalsekey:3215670todofalsetruekey:10116070 + falsetruekey:8117270go therefalsetruekey:10117670 falsetruekey:2217970afalsetruekey:2318370btruetruekey: + 3318370bfalsetruekey:3218770afalsetruekey:10119170 falsetruekey:2223870table + http://www.w3.org/TR/html4/hfalsefalsekey:10224670 + falsetruekey:2325270tr http://www.w3.org/TR/html4/hfalsetruekey:10326470 + falsetruekey:2427070td http://www.w3.org/TR/html4/hfalsetruekey:4427670 Applesfalsefalsekey:3428370td + http://www.w3.org/TR/html4/hfalsetruekey:10329570 + falsetruekey:2430170td http://www.w3.org/TR/html4/hfalsetruekey:4430870 Bananasfalsefalsekey:3431570td + http://www.w3.org/TR/html4/hfalsetruekey:10332370 falsetruekey:3333070tr + http://www.w3.org/TR/html4/hfalsetruekey:10233470 falsetruekey:3234470table + http://www.w3.org/TR/html4/hfalsetruekey:3135170notefalsetruekey:10351130falsetrue'; + expect(str).assertEqual(str1); + }) + + /** + * @tc.name: testParse002 + * @tc.desc: Starts parsing the XML file. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testParse002', 0, function () { + var strXml = + '' + + ']>' + + '' + + ' ' + + ' ' + + ' John & Hans' + + ' Happy' + + ' Happy' + + ' Work' + + ' Play' + + ' ' + + ' ' + + ' ' + + ' ' + + ' Apples' + + ' Bananas' + + ' ' + + ' ' + + ''; + var arrayBuffer = new ArrayBuffer(strXml.length*2); + var bufView = new Uint8Array(arrayBuffer); + var strLen = strXml.length; + for (var i = 0; i < strLen; ++i) { + bufView[i] = strXml.charCodeAt(i); + } + var that = new xml.XmlPullParser(arrayBuffer); + var arr = {}; + var i = 0; + function func3(key, info){ + arr[i] = 'key:' + JSON.stringify(key) + info.getDepth() + info.getColumnNumber() + info.getLineNumber() + + info.getAttributeCount() + info.getName() + info.getNamespace() + info.getPrefix() + info.getText() + + info.isEmptyElementTag()+ info.isWhitespace(); + i++; + return true; + } + var options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func3} + that.parse(options); + var str = ''; + for(var j = 0; j < i; ++j) { + str = str + arr[j]; + } + var str1 = 'key:00110falsetruekey:702220 note [\n]falsefalsekey:216022notefalsefalsekey:1016420 falsetruekey:51470\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\nfalsetruekey:101870 falsetruekey:612870Hello, World!falsetruekey:1013270 falsetruekey:224170companyfalsetruekey:424670 John falsefalsekey:925170amp;amp;falsetruekey:425670 Hansfalsefalsekey:326670companyfalsetruekey:1017070 falsetruekey:227770titlefalsetruekey:428270 Happyfalsefalsekey:329070titlefalsetruekey:1019470 falsetruekey:2210170titlefalsetruekey:4210670 Happyfalsefalsekey:3211470titlefalsetruekey:10111870 falsetruekey:2212470todofalsetruekey:4212870 Workfalsefalsekey:3213570todofalsetruekey:10113970 falsetruekey:2214570todofalsetruekey:4214970 Playfalsefalsekey:3215670todofalsetruekey:10116070 falsetruekey:8117270go therefalsetruekey:10117670 falsetruekey:2217970afalsetruekey:2318370btruetruekey:3318370bfalsetruekey:3218770afalsetruekey:10119170 falsetruekey:2223871h:tablefalsefalsekey:10224670 falsetruekey:2325270h:trfalsetruekey:10326470 falsetruekey:2427070h:tdfalsetruekey:4427670 Applesfalsefalsekey:3428370h:tdfalsetruekey:10329570 falsetruekey:2430170h:tdfalsetruekey:4430870 Bananasfalsefalsekey:3431570h:tdfalsetruekey:10332370 falsetruekey:3333070h:trfalsetruekey:10233470 falsetruekey:3234470h:tablefalsetruekey:3135170notefalsetruekey:10351130falsetrue' + expect(str).assertEqual(str1) + }) + + /** + * @tc.name: testParse003 + * @tc.desc: Starts parsing the XML file. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testParse003', 0, function () { + var strXml = + '' + + ']>' + + '' + + ' ' + + ' ' + + ' John & Hans' + + ' Happy' + + ' Happy' + + ' Work' + + ' Play' + + ' ' + + ' ' + + ' ' + + ' ' + + ' Apples' + + ' Bananas' + + ' ' + + ' ' + + ''; + var arrayBuffer = new ArrayBuffer(strXml.length*2); + var bufView = new Uint8Array(arrayBuffer); + var strLen = strXml.length; + for (var i = 0; i < strLen; ++i) { + bufView[i] = strXml.charCodeAt(i); + } + var that = new xml.XmlPullParser(arrayBuffer, 'UTF-8'); + var arr = {}; + var i = 0; + function func3(key, info){ + arr[i] = 'key:' + JSON.stringify(key) + info.getDepth() + info.getColumnNumber() + info.getLineNumber() + + info.getAttributeCount() + info.getName() + info.getNamespace() + info.getPrefix() + info.getText() + + info.isEmptyElementTag()+ info.isWhitespace(); + i++; + return true; + } + var options = {supportDoctype:false, ignoreNameSpace:true, tokenValueCallbackFunction:func3} + that.parse(options); + var str = ''; + for(var j = 0; j < i; ++j) { + str = str + arr[j]; + } + var str1 = 'key:00110falsetruekey:216022notefalsefalsekey:1016420 falsetruekey:51470\r\nfuncrion matchwo(a,6)\r\n{\r\nreturn 1;\r\n}\r\nfalsetruekey:101870 falsetruekey:612870Hello, World!falsetruekey:1013270 falsetruekey:224170companyfalsetruekey:424670 John falsefalsekey:925170amp;amp;falsetruekey:425670 Hansfalsefalsekey:326670companyfalsetruekey:1017070 falsetruekey:227770titlefalsetruekey:428270 Happyfalsefalsekey:329070titlefalsetruekey:1019470 falsetruekey:2210170titlefalsetruekey:4210670 Happyfalsefalsekey:3211470titlefalsetruekey:10111870 falsetruekey:2212470todofalsetruekey:4212870 Workfalsefalsekey:3213570todofalsetruekey:10113970 falsetruekey:2214570todofalsetruekey:4214970 Playfalsefalsekey:3215670todofalsetruekey:10116070 falsetruekey:8117270go therefalsetruekey:10117670 falsetruekey:2217970afalsetruekey:2318370btruetruekey:3318370bfalsetruekey:3218770afalsetruekey:10119170 falsetruekey:2223871h:tablefalsefalsekey:10224670 falsetruekey:2325270h:trfalsetruekey:10326470 falsetruekey:2427070h:tdfalsetruekey:4427670 Applesfalsefalsekey:3428370h:tdfalsetruekey:10329570 falsetruekey:2430170h:tdfalsetruekey:4430870 Bananasfalsefalsekey:3431570h:tdfalsetruekey:10332370 falsetruekey:3333070h:trfalsetruekey:10233470 falsetruekey:3234470h:tablefalsetruekey:3135170notefalsetruekey:10351130falsetrue' + expect(str).assertEqual(str1); + + }) + + /** + * @tc.name: testParse004 + * @tc.desc: Starts parsing the XML file. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testParse004', 0, function () { + var strXml = + '' + + ']>' + + '' + + ' ' + + ' ' + + ' John & Hans' + + ' Happy' + + ' Happy' + + ' Work' + + ' Play' + + ' ' + + ' ' + + ' ' + + ' ' + + ' Apples' + + ' Bananas' + + ' ' + + ' ' + + ''; + var arrayBuffer = new ArrayBuffer(strXml.length*2); + var bufView = new Uint8Array(arrayBuffer); + var strLen = strXml.length; + for (var i = 0; i < strLen; ++i) { + bufView[i] = strXml.charCodeAt(i); + } + var that = new xml.XmlPullParser(arrayBuffer, 'UTF-8'); + var str = ''; + function func2(name, value){ + str += name+':'+value; + return true; + } + var options = {supportDoctype:true, ignoreNameSpace:true, attributeValueCallbackFunction:func2} + that.parse(options); + var str1= 'importance: highxmlns:h: http://www.w3.org/TR/html4/' + expect(str).assertEqual(str1); + }) + + /** + * @tc.name: testParse005 + * @tc.desc: Starts parsing the XML file. + * @tc.require: AR000GGRB8 + * @tc.author: lihucheng + */ + it('testParse005', 0, function () { + var strXml = + '' + + ']>' + + '' + + ' ' + + ' ' + + ' John & Hans' + + ' Happy' + + ' Happy' + + ' Work' + + ' Play' + + ' ' + + ' ' + + ' ' + + ' ' + + ' Apples' + + ' Bananas' + + ' ' + + ' ' + + ''; + var arrayBuffer = new ArrayBuffer(strXml.length*2); + var bufView = new Uint8Array(arrayBuffer); + var strLen = strXml.length; + for (var i = 0; i < strLen; ++i) { + bufView[i] = strXml.charCodeAt(i); + } + var that = new xml.XmlPullParser(arrayBuffer, 'UTF-8'); + var str1 = ''; + function func1(name, value){ + str1 += name+':'+value; + return true; + } + var options = {supportDoctype:true, ignoreNameSpace:true, tagValueCallbackFunction:func1} + that.parse(options); + var str3 = 'note:company:title:title:todo:todo:a:b:h:table:h:tr:h:td:h:td:' + expect(str1).assertEqual(str3) + }) +}) \ No newline at end of file diff --git a/compileruntime/xml_lib_standard/src/main/resources/base/element/string.json b/compileruntime/xml_lib_standard/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0bae6bd40f7360d5d818998221b199d3ec0f69c0 --- /dev/null +++ b/compileruntime/xml_lib_standard/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "mainability_description", + "value": "JS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/compileruntime/xml_lib_standard/src/main/resources/base/media/icon.png b/compileruntime/xml_lib_standard/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/compileruntime/xml_lib_standard/src/main/resources/base/media/icon.png differ