Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: tests/corelib/uri_test.dart

Issue 2763823002: Move spaces from before comments to within comments (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library uriTest; 5 library uriTest;
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 testUri(String uriText, bool isAbsolute) { 10 testUri(String uriText, bool isAbsolute) {
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 491
492 void testInvalidUrls() { 492 void testInvalidUrls() {
493 void checkInvalid(uri) { 493 void checkInvalid(uri) {
494 try { 494 try {
495 var result = Uri.parse(uri); 495 var result = Uri.parse(uri);
496 Expect.fail("Invalid URI `$uri` parsed to $result\n" + dump(result)); 496 Expect.fail("Invalid URI `$uri` parsed to $result\n" + dump(result));
497 } on FormatException { 497 } on FormatException {
498 // Success. 498 // Success.
499 } 499 }
500 } 500 }
501 checkInvalid("s%41://x.x/"); // No escapes in scheme, 501 checkInvalid("s%41://x.x/"); // No escapes in scheme,
502 // and no colon before slash in path. 502 // and no colon before slash in path.
sra1 2017/03/21 01:43:47 ??
Jacob 2017/03/21 02:25:35 Done.
503 checkInvalid("1a://x.x/"); // Scheme must start with letter, 503 checkInvalid("1a://x.x/"); // Scheme must start with letter,
504 // and no colon before slash in path. 504 // and no colon before slash in path.
505 checkInvalid(".a://x.x/"); // Scheme must start with letter, 505 checkInvalid(".a://x.x/"); // Scheme must start with letter,
506 // and no colon before slash in path. 506 // and no colon before slash in path.
507 checkInvalid("_:"); // Character not valid in scheme, 507 checkInvalid("_:"); // Character not valid in scheme,
508 // and no colon before slash in path. 508 // and no colon before slash in path.
509 checkInvalid(":"); // Scheme must start with letter, 509 checkInvalid(":"); // Scheme must start with letter,
510 // and no colon before slash in path. 510 // and no colon before slash in path.
511 511
512 void checkInvalidReplaced(uri, invalid, replacement) { 512 void checkInvalidReplaced(uri, invalid, replacement) {
513 var source = uri.replaceAll('{}', invalid); 513 var source = uri.replaceAll('{}', invalid);
514 var expected = uri.replaceAll('{}', replacement); 514 var expected = uri.replaceAll('{}', replacement);
515 var result = Uri.parse(source); 515 var result = Uri.parse(source);
516 Expect.equals(expected, "$result", "Source: $source\n${dump(result)}"); 516 Expect.equals(expected, "$result", "Source: $source\n${dump(result)}");
517 } 517 }
518 518
519 // Regression test for http://dartbug.com/16081 519 // Regression test for http://dartbug.com/16081
520 checkInvalidReplaced("http://www.example.org/red%09ros{}#red)", 520 checkInvalidReplaced("http://www.example.org/red%09ros{}#red)",
521 "\u00e9", "%C3%A9"); 521 "\u00e9", "%C3%A9");
522 checkInvalidReplaced("http://r{}sum\{}.example.org", "\u00E9", "%C3%A9"); 522 checkInvalidReplaced("http://r{}sum\{}.example.org", "\u00E9", "%C3%A9");
523 523
524 // Invalid characters. The characters must be rejected, even if normalizing 524 // Invalid characters. The characters must be rejected, even if normalizing
525 // the input would cause them to be valid (normalization happens after 525 // the input would cause them to be valid (normalization happens after
526 // validation). 526 // validation).
527 var invalidCharsAndReplacements = [ 527 var invalidCharsAndReplacements = [
528 "\xe7", "%C3%A7", // Arbitrary non-ASCII letter 528 "\xe7", "%C3%A7", // Arbitrary non-ASCII letter
529 " ", "%20", // Space, not allowed anywhere. 529 " ", "%20", // Space, not allowed anywhere.
530 '"', "%22", // Quote, not allowed anywhere 530 '"', "%22", // Quote, not allowed anywhere
531 "<>", "%3C%3E", // Less/greater-than, not allowed anywhere. 531 "<>", "%3C%3E", // Less/greater-than, not allowed anywhere.
532 "\x7f", "%7F", // DEL, not allowed anywhere 532 "\x7f", "%7F", // DEL, not allowed anywhere
533 "\xdf", "%C3%9F", // German lower-case scharf-S. 533 "\xdf", "%C3%9F", // German lower-case scharf-S.
534 // Becomes ASCII when upper-cased. 534 // Becomes ASCII when upper-cased.
535 "\u0130", "%C4%B0", // Latin capital dotted I, 535 "\u0130", "%C4%B0", // Latin capital dotted I,
536 // becomes ASCII lower-case in Turkish. 536 // becomes ASCII lower-case in Turkish.
537 "%\uFB03", "%25%EF%AC%83", // % + Ligature ffi, 537 "%\uFB03", "%25%EF%AC%83", // % + Ligature ffi,
538 // becomes ASCII when upper-cased, 538 // becomes ASCII when upper-cased,
539 // should not be read as "%FFI". 539 // should not be read as "%FFI".
540 "\u212a", "%E2%84%AA", // Kelvin sign. Becomes ASCII when lower-cased. 540 "\u212a", "%E2%84%AA", // Kelvin sign. Becomes ASCII when lower-cased.
541 "%1g", "%251g", // Invalid escape. 541 "%1g", "%251g", // Invalid escape.
542 "\u{10000}", "%F0%90%80%80", // Non-BMP character as surrogate pair. 542 "\u{10000}", "%F0%90%80%80", // Non-BMP character as surrogate pair.
543 ]; 543 ];
544 for (int i = 0; i < invalidCharsAndReplacements.length; i += 2) { 544 for (int i = 0; i < invalidCharsAndReplacements.length; i += 2) {
545 var invalid = invalidCharsAndReplacements[i]; 545 var invalid = invalidCharsAndReplacements[i];
546 var valid = invalidCharsAndReplacements[i + 1]; 546 var valid = invalidCharsAndReplacements[i + 1];
547 checkInvalid("A{}b:///".replaceAll('{}', invalid)); 547 checkInvalid("A{}b:///".replaceAll('{}', invalid));
548 checkInvalid("{}b:///".replaceAll('{}', invalid)); 548 checkInvalid("{}b:///".replaceAll('{}', invalid));
549 checkInvalidReplaced("s://user{}info@x.x/", invalid, valid); 549 checkInvalidReplaced("s://user{}info@x.x/", invalid, valid);
550 checkInvalidReplaced("s://reg{}name/", invalid, valid); 550 checkInvalidReplaced("s://reg{}name/", invalid, valid);
551 checkInvalid("s://regname:12{}45/".replaceAll("{}", invalid)); 551 checkInvalid("s://regname:12{}45/".replaceAll("{}", invalid));
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 String dump(Uri uri) { 962 String dump(Uri uri) {
963 return "URI: $uri\n" 963 return "URI: $uri\n"
964 " Scheme: ${uri.scheme} #${uri.scheme.length}\n" 964 " Scheme: ${uri.scheme} #${uri.scheme.length}\n"
965 " User-info: ${uri.userInfo} #${uri.userInfo.length}\n" 965 " User-info: ${uri.userInfo} #${uri.userInfo.length}\n"
966 " Host: ${uri.host} #${uri.host.length}\n" 966 " Host: ${uri.host} #${uri.host.length}\n"
967 " Port: ${uri.port}\n" 967 " Port: ${uri.port}\n"
968 " Path: ${uri.path} #${uri.path.length}\n" 968 " Path: ${uri.path} #${uri.path.length}\n"
969 " Query: ${uri.query} #${uri.query.length}\n" 969 " Query: ${uri.query} #${uri.query.length}\n"
970 " Fragment: ${uri.fragment} #${uri.fragment.length}\n"; 970 " Fragment: ${uri.fragment} #${uri.fragment.length}\n";
971 } 971 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698