| OLD | NEW |
| 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 14 matching lines...) Expand all Loading... |
| 25 Expect.equals(uri.hashCode, uri2.hashCode); | 25 Expect.equals(uri.hashCode, uri2.hashCode); |
| 26 | 26 |
| 27 // Test that removeFragment doesn't change anything else. | 27 // Test that removeFragment doesn't change anything else. |
| 28 if (uri.hasFragment) { | 28 if (uri.hasFragment) { |
| 29 Expect.equals(Uri.parse(uriText.substring(0, uriText.indexOf('#'))), | 29 Expect.equals(Uri.parse(uriText.substring(0, uriText.indexOf('#'))), |
| 30 uri.removeFragment()); | 30 uri.removeFragment()); |
| 31 } else { | 31 } else { |
| 32 Expect.equals(uri, | 32 Expect.equals(uri, |
| 33 Uri.parse(uriText + "#fragment").removeFragment()); | 33 Uri.parse(uriText + "#fragment").removeFragment()); |
| 34 } | 34 } |
| 35 |
| 36 // Test uri.replace on uri with fragment |
| 37 uri = Uri.parse('http://hello.com/fake#fragment'); |
| 38 uri = uri.replace(path: "D/E/E"); |
| 39 Expect.stringEquals('http://hello.com/D/E/E#fragment', uri.toString()); |
| 35 } | 40 } |
| 36 | 41 |
| 37 testEncodeDecode(String orig, String encoded) { | 42 testEncodeDecode(String orig, String encoded) { |
| 38 var e = Uri.encodeFull(orig); | 43 var e = Uri.encodeFull(orig); |
| 39 Expect.stringEquals(encoded, e); | 44 Expect.stringEquals(encoded, e); |
| 40 var d = Uri.decodeFull(encoded); | 45 var d = Uri.decodeFull(encoded); |
| 41 Expect.stringEquals(orig, d); | 46 Expect.stringEquals(orig, d); |
| 42 } | 47 } |
| 43 | 48 |
| 44 testEncodeDecodeComponent(String orig, String encoded) { | 49 testEncodeDecodeComponent(String orig, String encoded) { |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 String dump(Uri uri) { | 863 String dump(Uri uri) { |
| 859 return "URI: $uri\n" | 864 return "URI: $uri\n" |
| 860 " Scheme: ${uri.scheme} #${uri.scheme.length}\n" | 865 " Scheme: ${uri.scheme} #${uri.scheme.length}\n" |
| 861 " User-info: ${uri.userInfo} #${uri.userInfo.length}\n" | 866 " User-info: ${uri.userInfo} #${uri.userInfo.length}\n" |
| 862 " Host: ${uri.host} #${uri.host.length}\n" | 867 " Host: ${uri.host} #${uri.host.length}\n" |
| 863 " Port: ${uri.port}\n" | 868 " Port: ${uri.port}\n" |
| 864 " Path: ${uri.path} #${uri.path.length}\n" | 869 " Path: ${uri.path} #${uri.path.length}\n" |
| 865 " Query: ${uri.query} #${uri.query.length}\n" | 870 " Query: ${uri.query} #${uri.query.length}\n" |
| 866 " Fragment: ${uri.fragment} #${uri.fragment.length}\n"; | 871 " Fragment: ${uri.fragment} #${uri.fragment.length}\n"; |
| 867 } | 872 } |
| OLD | NEW |