uri.test.js 32.7 KB
Newer Older
X
xdmal 已提交
1
/*
X
xdmal 已提交
2
 * Copyright (C) 2022 Huawei Device Co., Ltd.
X
xdmal 已提交
3 4 5 6 7 8 9 10 11 12 13 14
 * 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.
 */
15
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
16
import  uri from '@ohos.uri'
X
xdmal 已提交
17
describe('UriTest', function () {
X
xdmal 已提交
18

X
xdmal 已提交
19
    /**
X
xllify 已提交
20
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_012
X
xdmal 已提交
21 22 23 24
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
25
    it('SUB_Runtime_JSAPI_SR000GGR34_012', 0, function () {
X
xdmal 已提交
26
        try {
27
            let that = new uri.URI('#http://username:password@host:8080/directory/file?foo=1&bar=2');
X
xdmal 已提交
28
        } catch (err) {
29
            expect(err.toString()).assertEqual("Error: #It can't be the first");
X
xdmal 已提交
30 31 32 33
        }
    })

    /**
X
xllify 已提交
34
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_010
X
xdmal 已提交
35 36 37 38
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
39
    it('SUB_Runtime_JSAPI_SR000GGR34_010', 0, function () {
X
xdmal 已提交
40
        try {
41
            let that = new uri.URI({name: 'gaogao'});
X
xdmal 已提交
42
        } catch (err) {
43
            expect(err.toString()).assertEqual("Error: input type err");
X
xdmal 已提交
44 45 46 47
        }
    })

    /**
X
xllify 已提交
48
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_032
X
xdmal 已提交
49 50 51 52
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
53
    it('SUB_Runtime_JSAPI_SR000GGR34_032', 0, function () {
X
xdmal 已提交
54
        try {
55
            let that = new uri.URI('ht/tp://username:pas sword@host:8080/directory/file?foo=1&bar=2');
X
xdmal 已提交
56
        } catch (err) {
57
            expect(err.toString()).assertEqual("Error: SpecialPath does not conform to the rule");
X
xdmal 已提交
58 59 60 61
        }
    })

    /**
X
xllify 已提交
62
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_030
X
xdmal 已提交
63 64 65 66
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
67
    it('SUB_Runtime_JSAPI_SR000GGR34_030', 0, function () {
X
xdmal 已提交
68
        try {
69
            let that = new uri.URI('http://username:password@[::]:8080/directory/file?Query#gaogao faofao');
X
xdmal 已提交
70
        } catch (err) {
71
            expect(err.toString()).assertEqual("Error: Fragment does not conform to the rule");
X
xdmal 已提交
72 73 74 75
        }
    })

    /**
X
xllify 已提交
76
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_028
X
xdmal 已提交
77 78 79 80
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
81
    it('SUB_Runtime_JSAPI_SR000GGR34_028', 0, function () {
X
xdmal 已提交
82
        try {
83
            let that = new uri.URI('http://username:password@host:8080/directory/file?foo^=1&bar=2#gaogaofaofao');
X
xdmal 已提交
84
        } catch (err) {
85
            expect(err.toString()).assertEqual("Error: Query does not conform to the rule");
X
xdmal 已提交
86 87 88 89
        }
    })

    /**
X
xllify 已提交
90
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_013
X
xdmal 已提交
91 92 93 94
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
95
    it('SUB_Runtime_JSAPI_SR000GGR34_013', 0, function () {
X
xdmal 已提交
96
        try {
97
            let that = new uri.URI('1http://username:password@host:8080/directory/file?foo=1&bar=2#gaogaofaofao');
X
xdmal 已提交
98
        } catch (err) {
99
            expect(err.toString()).assertEqual("Error: Scheme the first character must be a letter");
X
xdmal 已提交
100 101 102 103
        }
    })

    /**
X
xllify 已提交
104
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_014
X
xdmal 已提交
105 106 107 108
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
109
    it('SUB_Runtime_JSAPI_SR000GGR34_014', 0, function () {
X
xdmal 已提交
110
        try {
111
            let that = new uri.URI('ht@tp://username:password@host:8080/directory/file?foo=1&bar=2#gaogaofaofao');
X
xdmal 已提交
112
        } catch (err) {
113
            expect(err.toString()).assertEqual("Error: scheme does not conform to the rule");
X
xdmal 已提交
114 115 116 117
        }
    })

    /**
X
xllify 已提交
118
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_026
X
xdmal 已提交
119 120 121 122
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
123
    it('SUB_Runtime_JSAPI_SR000GGR34_026', 0, function () {
X
xdmal 已提交
124
        try {
125
            let that = new uri.URI('http://username:password@[::]:80r80/directory/file?foo=1&bar=2#gaogaofaofao');
X
xdmal 已提交
126
        } catch (err) {
127
            expect(err.toString()).assertEqual("Error: Prot does not conform to the rule");
X
xdmal 已提交
128 129 130 131
        }
    })

    /**
X
xllify 已提交
132
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_021
X
xdmal 已提交
133 134 135 136
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
137
    it('SUB_Runtime_JSAPI_SR000GGR34_021', 0, function () {
X
xdmal 已提交
138
        try {
139
            let that = new uri.URI('http://username:password@[::12:55:8080/directory/file?foo=1&bar=2#gaogaofaofao');
X
xdmal 已提交
140
        } catch (err) {
141
            expect(err.toString()).assertEqual("Error: IPv6 is missing a closing bracket");
X
xdmal 已提交
142 143 144 145
        }
    })

    /**
X
xllify 已提交
146
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_018
X
xdmal 已提交
147 148 149 150
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
151
    it('SUB_Runtime_JSAPI_SR000GGR34_018', 0, function () {
X
xdmal 已提交
152
        try {
153
            let that = new uri.URI('http://username:pa^ssword@[::12:55]:8080/directory/file?foo=1&bar=2#gaogaofaofao');
X
xdmal 已提交
154
        } catch (err) {
155
            expect(err.toString()).assertEqual("Error: userInfo does not conform to the rule");
X
xdmal 已提交
156 157 158 159
        }
    })

    /**
X
xllify 已提交
160
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_020
X
xdmal 已提交
161 162 163 164
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
165
    it('SUB_Runtime_JSAPI_SR000GGR34_020', 0, function () {
X
xdmal 已提交
166
        try {
167
            let that = new uri.URI('http://username:password@[::1你2:55]:8080/directory/file?foo=1&bar=2#gaogaofaofao');
X
xdmal 已提交
168
        } catch (err) {
169
            expect(err.toString()).assertEqual("Error: ipv6 does not conform to the rule");
X
xdmal 已提交
170 171 172 173
        }
    })

    /**
X
xllify 已提交
174
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_001
X
xdmal 已提交
175 176 177 178
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
179
    it('SUB_Runtime_JSAPI_SR000GGR34_001', 0, function () {
180
        let gaogao = new uri.URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
X
xdmal 已提交
181 182 183
        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");
184
        expect(gaogao.userInfo).assertEqual("gg:gaogao");
X
xdmal 已提交
185 186 187 188 189 190 191 192 193 194 195 196 197 198
        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 () {
199
        let gaogao = new uri.URI('http://gg:gaogao@[1080::8:800:200C:417A]:99/path/66path1?query#fagment');
X
xdmal 已提交
200 201 202
        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");
203
        expect(gaogao.userInfo).assertEqual("gg:gaogao");
X
xdmal 已提交
204 205 206 207 208 209 210 211
        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");
    })

    /**
X
xllify 已提交
212
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_002
X
xdmal 已提交
213 214 215 216
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
217
    it('SUB_Runtime_JSAPI_SR000GGR34_002', 0, function () {
218
        let gaogao = new uri.URI('http://gg:gaogao@[::]:88/path/path66?foooo#gaogao');
X
xdmal 已提交
219 220 221
        expect(gaogao.scheme).assertEqual("http");
        expect(gaogao.authority).assertEqual("gg:gaogao@[::]:88");
        expect(gaogao.ssp).assertEqual("//gg:gaogao@[::]:88/path/path66?foooo");
222
        expect(gaogao.userInfo).assertEqual("gg:gaogao");
X
xdmal 已提交
223 224 225 226 227 228 229 230 231 232 233 234 235 236
        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 () {
237
        let gaogao = new uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66path1?query#fagment');
X
xdmal 已提交
238 239 240
        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");
241
        expect(gaogao.userInfo).assertEqual("gg:gaogao");
X
xdmal 已提交
242 243 244 245 246 247 248 249
        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");
    })

    /**
X
xllify 已提交
250
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_003
X
xdmal 已提交
251 252 253 254
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
255
    it('SUB_Runtime_JSAPI_SR000GGR34_003', 0, function () {
256
        let gaogao = new uri.URI('http://gg:gaogao@[::FFFF:129.144.52.38]:99/path/path?query#fagment');
X
xdmal 已提交
257 258 259
        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");
260
        expect(gaogao.userInfo).assertEqual("gg:gaogao");
X
xdmal 已提交
261 262 263 264 265 266 267 268 269 270 271 272 273 274
        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 () {
275
        let gaogao = new uri.URI('http://gg:gaogao@[::192.9.5.5]:99/path/path?query#fagment');
X
xdmal 已提交
276 277 278
        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");
279
        expect(gaogao.userInfo).assertEqual("gg:gaogao");
X
xdmal 已提交
280 281 282 283 284 285 286 287 288 289 290 291 292 293
        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 () {
294
        let gaogao = new uri.URI('http://gg:gaogao@[22::22:2:2%ss]:99/path/path?query#fagment');
X
xdmal 已提交
295 296 297
        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");
298
        expect(gaogao.userInfo).assertEqual("gg:gaogao");
X
xdmal 已提交
299 300 301 302 303 304 305 306 307 308 309 310 311 312
        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 () {
X
xdmal 已提交
313
        let gaogao =
314
		new uri.URI('http://gg:gaogao@[fe80:0000:0001:0000:0440:44ff:1233:5678]:99/path/path?query#fagment');
X
xdmal 已提交
315 316 317
        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");
318
        expect(gaogao.userInfo).assertEqual("gg:gaogao");
X
xdmal 已提交
319 320 321 322 323 324 325 326 327 328 329 330 331 332
        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 () {
333
        let gaogao = new uri.URI('http://gg:gaogao@[fe80::0001:0000]:99/path/path?query#fagment');
X
xdmal 已提交
334 335 336
        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");
337
        expect(gaogao.userInfo).assertEqual("gg:gaogao");
X
xdmal 已提交
338 339 340 341 342 343 344 345
        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");
    })

    /**
X
xllify 已提交
346
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_004
X
xdmal 已提交
347 348 349 350
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
351
    it('SUB_Runtime_JSAPI_SR000GGR34_004', 0, function () {
352
        let gaogao = new uri.URI('http://gg:gaogao@199.98.55.44:99/path/path?query#fagment');
X
xdmal 已提交
353 354 355
        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");
356
        expect(gaogao.userInfo).assertEqual("gg:gaogao");
X
xdmal 已提交
357 358 359 360 361 362 363 364
        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");
    })

    /**
X
xllify 已提交
365
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_005
X
xdmal 已提交
366 367 368 369
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
370
    it('SUB_Runtime_JSAPI_SR000GGR34_005', 0, function () {
371
        let gaogao = new uri.URI('http://16.9.5.4:99/path/path?query#fagment');
X
xdmal 已提交
372 373 374
        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");
375
        expect(gaogao.userInfo).assertEqual("null");
X
xdmal 已提交
376 377 378 379 380 381 382 383 384 385 386 387 388 389
        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 () {
390
        let gaogao = new uri.URI('http://49.99.54.12:50/path/path23?query#fagment');
X
xdmal 已提交
391 392 393
        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");
394
        expect(gaogao.userInfo).assertEqual("null");
X
xdmal 已提交
395 396 397 398 399 400 401 402
        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");
    })

    /**
X
xllify 已提交
403
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_006
X
xdmal 已提交
404 405 406 407
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
408
    it('SUB_Runtime_JSAPI_SR000GGR34_006', 0, function () {
409
        let gaogao = new uri.URI('http://user@49.10pe8.54.12:80/path/path23?query#qwer');
X
xdmal 已提交
410 411 412
        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");
413
        expect(gaogao.userInfo).assertEqual("null");
X
xdmal 已提交
414 415 416 417 418 419 420 421
        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");
    })

    /**
X
xllify 已提交
422
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_007
X
xdmal 已提交
423 424 425 426
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
427
    it('SUB_Runtime_JSAPI_SR000GGR34_007', 0, function () {
428
        let gaogao = new uri.URI('http://user@www.baidu.com/path/path23?query#qwer');
X
xdmal 已提交
429 430 431
        expect(gaogao.scheme).assertEqual("http");
        expect(gaogao.authority).assertEqual("user@www.baidu.com");
        expect(gaogao.ssp).assertEqual("//user@www.baidu.com/path/path23?query");
432
        expect(gaogao.userInfo).assertEqual("user");
X
xdmal 已提交
433 434 435 436 437 438 439 440
        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");
    })

    /**
X
xllify 已提交
441
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_008
X
xdmal 已提交
442 443 444 445
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
446
    it('SUB_Runtime_JSAPI_SR000GGR34_008', 0, function () {
447
        let gaogao = new uri.URI('http://user@www.hw.com:77/path/path23?query#qwer');
X
xdmal 已提交
448 449 450
        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");
451
        expect(gaogao.userInfo).assertEqual("user");
X
xdmal 已提交
452 453 454 455 456 457 458 459
        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");
    })

    /**
X
xllify 已提交
460
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_009
X
xdmal 已提交
461 462 463 464
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
465
    it('SUB_Runtime_JSAPI_SR000GGR34_009', 0, function () {
466
        let gaogao = new uri.URI('ht2tp://user@www.h12343w.com:77/path/path23?query#qwer');
X
xdmal 已提交
467 468 469
        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");
470
        expect(gaogao.userInfo).assertEqual("user");
X
xdmal 已提交
471 472 473 474 475 476 477 478 479 480 481 482 483 484
        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 () {
485
        let gaogao = new uri.URI('ht2tp://user@www.1hw.1com:77/path/path23?query#qwer');
X
xdmal 已提交
486 487 488
        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");
489
        expect(gaogao.userInfo).assertEqual("null");
X
xdmal 已提交
490 491 492 493 494 495 496 497 498 499 500 501 502 503
        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 () {
504
        let gaogao = new uri.URI('http://user@hosthost/path/path23?query#qwer');
X
xdmal 已提交
505 506 507
        expect(gaogao.scheme).assertEqual("http");
        expect(gaogao.authority).assertEqual("user@hosthost");
        expect(gaogao.ssp).assertEqual("//user@hosthost/path/path23?query");
508
        expect(gaogao.userInfo).assertEqual("user");
X
xdmal 已提交
509 510 511 512 513 514 515 516 517 518 519 520 521 522
        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 () {
523
        let gaogao = new uri.URI('http://user@[::]/path/path23?query#qwer');
X
xdmal 已提交
524 525 526
        expect(gaogao.scheme).assertEqual("http");
        expect(gaogao.authority).assertEqual("user@[::]");
        expect(gaogao.ssp).assertEqual("//user@[::]/path/path23?query");
527
        expect(gaogao.userInfo).assertEqual("user");
X
xdmal 已提交
528 529 530 531 532 533 534 535 536 537 538 539 540 541
        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 () {
542
        let gaogao = new uri.URI('http://[::192:0:5]/path/path23?query#qwer');
X
xdmal 已提交
543 544 545
        expect(gaogao.scheme).assertEqual("http");
        expect(gaogao.authority).assertEqual("[::192:0:5]");
        expect(gaogao.ssp).assertEqual("//[::192:0:5]/path/path23?query");
546
        expect(gaogao.userInfo).assertEqual("null");
X
xdmal 已提交
547 548 549 550 551 552 553 554 555 556 557 558 559 560
        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 () {
561
        let gaogao = new uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
X
xdmal 已提交
562 563 564 565 566 567
        let gaogao1 = gaogao;
        let res = gaogao.equals(gaogao1);
        expect(res).assertEqual(true);
    })

    /**
X
xllify 已提交
568
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_034
X
xdmal 已提交
569 570 571 572
     * @tc.desc: Tests this URI for equality with another object.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
573
    it('SUB_Runtime_JSAPI_SR000GGR34_034', 0, function () {
574 575
        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');
X
xdmal 已提交
576 577 578 579 580
        let res = gaogao.equals(gaogao1);
        expect(res).assertEqual(true);
    })

    /**
X
xllify 已提交
581
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_035
X
xdmal 已提交
582 583 584 585
     * @tc.desc: Tests this URI for equality with another object.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
586
    it('SUB_Runtime_JSAPI_SR000GGR34_035', 0, function () {
587 588
        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');
X
xdmal 已提交
589 590 591 592 593 594 595 596 597 598 599
        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 () {
600 601
        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');
X
xdmal 已提交
602 603 604 605 606 607 608 609 610 611 612
        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 () {
613 614
        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');
X
xdmal 已提交
615 616 617 618 619
        let res = gaogao.equals(gaogao1);
        expect(res).assertEqual(false);
    })

    /**
X
xllify 已提交
620
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_036
X
xdmal 已提交
621 622 623 624
     * @tc.desc: Normalizes this URI's path.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
625
    it('SUB_Runtime_JSAPI_SR000GGR34_036', 0, function () {
626
        let gaogao = new uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66./../././mm/.././path1?query#fagment');
X
xdmal 已提交
627 628 629 630 631 632
        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");
    })

    /**
X
xllify 已提交
633
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_037
X
xdmal 已提交
634 635 636 637
     * @tc.desc: Normalizes this URI's path.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
638
    it('SUB_Runtime_JSAPI_SR000GGR34_037', 0, function () {
639
        let gaogao = new uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path?query#fagment');
X
xdmal 已提交
640 641 642 643 644 645 646 647 648 649 650 651
        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 () {
652
        let gaogao = new uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment');
X
xdmal 已提交
653 654 655 656 657 658
        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");
    })

    /**
X
xllify 已提交
659
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_038
X
xdmal 已提交
660 661 662 663
     * @tc.desc: Normalizes this URI's path.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
664
    it('SUB_Runtime_JSAPI_SR000GGR34_038', 0, function () {
665
        let gaogao = new uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../path/.././../aa/bb/cc?query');
X
xdmal 已提交
666 667 668 669 670 671
        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");
    })

    /**
X
xllify 已提交
672
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_039
X
xdmal 已提交
673 674 675 676
     * @tc.desc: Normalizes this URI's path.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
677
    it('SUB_Runtime_JSAPI_SR000GGR34_039', 0, function () {
678
        let gaogao = new uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/./path/./aa/bb/cc?query#fagment');
X
xdmal 已提交
679 680 681 682 683 684
        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");
    })

    /**
X
xllify 已提交
685
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_042
X
xdmal 已提交
686 687 688 689
     * @tc.desc: Returns the content of this URI as a US-ASCII string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
690
    it('SUB_Runtime_JSAPI_SR000GGR34_042', 0, function () {
691
        let gaogao = new uri.URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/../../path/.././../aa/bb/cc?query#fagment');
X
xdmal 已提交
692 693 694 695 696 697 698 699 700 701 702
        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 () {
703
        let gaogao = new uri.URI('htt1p://gg:gaogao@[::192.9.5.5]:99/path/66path1?query#fagment');
X
xdmal 已提交
704 705 706 707 708 709 710 711 712 713 714
        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 () {
715
        let gaogao = new uri.URI('ftp://username:password@www.baidu.com:88/path?query#fagment');
X
xdmal 已提交
716 717 718 719 720
        let res = gaogao.toString();
        expect(res).assertEqual('ftp://username:password@www.baidu.com:88/path?query#fagment');
    })

    /**
X
xllify 已提交
721
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_043
X
xdmal 已提交
722 723 724 725
     * @tc.desc: Returns the content of this URI as a US-ASCII string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
726
    it('SUB_Runtime_JSAPI_SR000GGR34_043', 0, function () {
727
        let gaogao = new uri.URI('http://gg:gao你好gao@199.98.55.44:99/path/p你好ath?qu你好ery#fag你好ment');
X
xdmal 已提交
728 729 730 731 732 733 734 735 736 737 738 739
        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 () {
740
        let gaogao = new uri.URI('http://gg:gaogao@199.98.55.44:99/path/path?query#fagment');
X
xdmal 已提交
741 742 743 744 745
        let res = gaogao.toString();
        expect(res).assertEqual('http://gg:gaogao@199.98.55.44:99/path/path?query#fagment');
    })

    /**
X
xllify 已提交
746
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_041
X
xdmal 已提交
747 748 749 750
     * @tc.desc: Tells whether or not this URI is absolute.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
751
    it('SUB_Runtime_JSAPI_SR000GGR34_041', 0, function () {
752
        let gaogao = new uri.URI('f/tp://username:password@www.baidu.com:88/path?query#fagment');
X
xdmal 已提交
753 754 755 756 757
        let res = gaogao.checkIsAbsolute();
        expect(res).assertEqual(false);
    })

    /**
X
xllify 已提交
758
     * @tc.name: SUB_Runtime_JSAPI_SR000GGR34_040
X
xdmal 已提交
759 760 761 762
     * @tc.desc: Tells whether or not this URI is absolute.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
X
xllify 已提交
763
    it('SUB_Runtime_JSAPI_SR000GGR34_040', 0, function () {
764
        let gaogao = new uri.URI('ftp://username:password@www.baidu.com:88/path?query#fagment');
X
xdmal 已提交
765 766 767 768 769 770 771 772 773 774 775
        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 () {
776
        let gaogao = new uri.URI('htt/p://username:password@www.baidu.com:88/path?query#fagment');
X
xdmal 已提交
777 778 779 780 781 782 783 784 785 786 787
        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 () {
788
        let gaogao = new uri.URI('https://username:password@www.baidu.com:88/path?query#fagment');
X
xdmal 已提交
789 790 791 792 793 794 795 796 797 798 799
        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 () {
800
        let gaogao = new uri.URI('http1://username:password@www.baidu.com:88/path?query#fagment');
X
xdmal 已提交
801 802 803 804
        let res = gaogao.checkIsAbsolute();
        expect(res).assertEqual(true);
    })
})