uri.test.js 31.7 KB
Newer Older
X
xdmal 已提交
1
/*
X
xllify 已提交
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 20 21 22 23 24 25 26
    /**
     * @tc.name: testConstructor001
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
    it('testConstructor001', 0, function () {
        try {
27
            let that = new 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 34 35 36 37 38 39 40
        }
    })

    /**
     * @tc.name: testConstructor002
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
    it('testConstructor002', 0, function () {
        try {
41
            let that = new URI({name: 'gaogao'});
X
xdmal 已提交
42
        } catch (err) {
43
            expect(err.toString()).assertEqual("Error: input type err");
X
xdmal 已提交
44 45 46 47 48 49 50 51 52 53 54
        }
    })

    /**
     * @tc.name: testConstructor003
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
    it('testConstructor003', 0, function () {
        try {
55
            let that = new 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 62 63 64 65 66 67 68
        }
    })

    /**
     * @tc.name: testConstructor004
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
    it('testConstructor004', 0, function () {
        try {
69
            let that = new 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 76 77 78 79 80 81 82
        }
    })

    /**
     * @tc.name: testConstructor005
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
    it('testConstructor005', 0, function () {
        try {
83
            let that = new 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 90 91 92 93 94 95 96
        }
    })

    /**
     * @tc.name: testConstructor006
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
    it('testConstructor006', 0, function () {
        try {
97
            let that = new 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 104 105 106 107 108 109 110
        }
    })

    /**
     * @tc.name: testConstructor007
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
    it('testConstructor007', 0, function () {
        try {
111
            let that = new 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 118 119 120 121 122 123 124
        }
    })

    /**
     * @tc.name: testConstructor008
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
    it('testConstructor008', 0, function () {
        try {
125
            let that = new 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 132 133 134 135 136 137 138
        }
    })

    /**
     * @tc.name: testConstructor009
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
    it('testConstructor009', 0, function () {
        try {
139
            let that = new 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 146 147 148 149 150 151 152
        }
    })

    /**
     * @tc.name: testConstructor010
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
    it('testConstructor010', 0, function () {
        try {
153
            let that = new 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 160 161 162 163 164 165 166
        }
    })

    /**
     * @tc.name: testConstructor011
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
    it('testConstructor011', 0, function () {
        try {
167
            let that = new 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 174 175 176 177 178 179
        }
    })

    /**
     * @tc.name: testConstructor012
     * @tc.desc: Constructs a URI by parsing the given string.
     * @tc.require: AR000GFB2S
     * @tc.author: zhaoduwei
     */
    it('testConstructor012', 0, function () {
180
        let gaogao = new URI('http://gg:gaogao@www.baidu.com:99/path/path?query#fagment');
X
xdmal 已提交
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
        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 () {
199
        let gaogao = new URI('http://gg:gaogao@[1080::8:800:200C:417A]:99/path/66path1?query#fagment');
X
xdmal 已提交
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
        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 () {
218
        let gaogao = new URI('http://gg:gaogao@[::]:88/path/path66?foooo#gaogao');
X
xdmal 已提交
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
        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 () {
237
        let gaogao = new URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path/66path1?query#fagment');
X
xdmal 已提交
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
        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 () {
256
        let gaogao = new URI('http://gg:gaogao@[::FFFF:129.144.52.38]:99/path/path?query#fagment');
X
xdmal 已提交
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
        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 () {
275
        let gaogao = new URI('http://gg:gaogao@[::192.9.5.5]:99/path/path?query#fagment');
X
xdmal 已提交
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
        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 () {
294
        let gaogao = new URI('http://gg:gaogao@[22::22:2:2%ss]:99/path/path?query#fagment');
X
xdmal 已提交
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
        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 () {
X
xdmal 已提交
313
        let gaogao =
314
		new URI('http://gg:gaogao@[fe80:0000:0001:0000:0440:44ff:1233:5678]:99/path/path?query#fagment');
X
xdmal 已提交
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
        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 () {
333
        let gaogao = new URI('http://gg:gaogao@[fe80::0001:0000]:99/path/path?query#fagment');
X
xdmal 已提交
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
        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 () {
352
        let gaogao = new URI('http://gg:gaogao@199.98.55.44:99/path/path?query#fagment');
X
xdmal 已提交
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
        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 () {
371
        let gaogao = new URI('http://16.9.5.4:99/path/path?query#fagment');
X
xdmal 已提交
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
        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 () {
390
        let gaogao = new URI('http://49.99.54.12:50/path/path23?query#fagment');
X
xdmal 已提交
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
        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 () {
409
        let gaogao = new URI('http://user@49.10pe8.54.12:80/path/path23?query#qwer');
X
xdmal 已提交
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
        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 () {
428
        let gaogao = new URI('http://user@www.baidu.com/path/path23?query#qwer');
X
xdmal 已提交
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
        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 () {
447
        let gaogao = new URI('http://user@www.hw.com:77/path/path23?query#qwer');
X
xdmal 已提交
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
        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 () {
466
        let gaogao = new URI('ht2tp://user@www.h12343w.com:77/path/path23?query#qwer');
X
xdmal 已提交
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
        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 () {
485
        let gaogao = new URI('ht2tp://user@www.1hw.1com:77/path/path23?query#qwer');
X
xdmal 已提交
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
        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 () {
504
        let gaogao = new URI('http://user@hosthost/path/path23?query#qwer');
X
xdmal 已提交
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522
        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 () {
523
        let gaogao = new URI('http://user@[::]/path/path23?query#qwer');
X
xdmal 已提交
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
        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 () {
542
        let gaogao = new URI('http://[::192:0:5]/path/path23?query#qwer');
X
xdmal 已提交
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560
        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 () {
561
        let gaogao = new URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
X
xdmal 已提交
562 563 564 565 566 567 568 569 570 571 572 573
        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 () {
574 575
        let gaogao = new URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
        let gaogao1 = new URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
X
xdmal 已提交
576 577 578 579 580 581 582 583 584 585 586
        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 () {
587 588
        let gaogao = new URI('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
        let gaogao1 = new 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('http://gg:gaogao@wwwaaa:99/path1?query#fagment');
        let gaogao1 = new 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('http://gg:gaogao@[1:0:0:1:2:1:2:1]:99/path1?query#fagment');
        let gaogao1 = new URI('http://[1:0:0:1:2:1:2:1]/path1?query#fagment123');
X
xdmal 已提交
615 616 617 618 619 620 621 622 623 624 625
        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 () {
626
        let gaogao = new 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 633 634 635 636 637 638
        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 () {
639
        let gaogao = new 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('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 659 660 661 662 663 664
        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 () {
665
        let gaogao = new 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 672 673 674 675 676 677
        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 () {
678
        let gaogao = new 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 685 686 687 688 689 690
        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 () {
691
        let gaogao = new 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('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('ftp://username:password@www.baidu.com:88/path?query#fagment');
X
xdmal 已提交
716 717 718 719 720 721 722 723 724 725 726
        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 () {
727
        let gaogao = new 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('http://gg:gaogao@199.98.55.44:99/path/path?query#fagment');
X
xdmal 已提交
741 742 743 744 745 746 747 748 749 750 751
        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 () {
752
        let gaogao = new URI('f/tp://username:password@www.baidu.com:88/path?query#fagment');
X
xdmal 已提交
753 754 755 756 757 758 759 760 761 762 763
        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 () {
764
        let gaogao = new 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('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('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('http1://username:password@www.baidu.com:88/path?query#fagment');
X
xdmal 已提交
801 802 803 804
        let res = gaogao.checkIsAbsolute();
        expect(res).assertEqual(true);
    })
})