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 path.test.posix_test; | 5 library path.test.posix_test; |
6 | 6 |
7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
8 import 'package:path/path.dart' as path; | 8 import 'package:path/path.dart' as path; |
9 | 9 |
10 import 'utils.dart'; | 10 import 'utils.dart'; |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 expect(context.withoutExtension('a/.'), 'a/.'); | 467 expect(context.withoutExtension('a/.'), 'a/.'); |
468 expect(context.withoutExtension('a/.b'), 'a/.b'); | 468 expect(context.withoutExtension('a/.b'), 'a/.b'); |
469 expect(context.withoutExtension('a.b/c'), 'a.b/c'); | 469 expect(context.withoutExtension('a.b/c'), 'a.b/c'); |
470 expect(context.withoutExtension(r'a.b\c'), r'a'); | 470 expect(context.withoutExtension(r'a.b\c'), r'a'); |
471 expect(context.withoutExtension(r'a/b\c'), r'a/b\c'); | 471 expect(context.withoutExtension(r'a/b\c'), r'a/b\c'); |
472 expect(context.withoutExtension(r'a/b\c.d'), r'a/b\c'); | 472 expect(context.withoutExtension(r'a/b\c.d'), r'a/b\c'); |
473 expect(context.withoutExtension('a/b.c/'), 'a/b/'); | 473 expect(context.withoutExtension('a/b.c/'), 'a/b/'); |
474 expect(context.withoutExtension('a/b.c//'), 'a/b//'); | 474 expect(context.withoutExtension('a/b.c//'), 'a/b//'); |
475 }); | 475 }); |
476 | 476 |
477 test('fromUri', () { | 477 group('fromUri', () { |
478 expect(context.fromUri(Uri.parse('file:///path/to/foo')), '/path/to/foo'); | 478 test('with a URI', () { |
479 expect(context.fromUri(Uri.parse('file:///path/to/foo/')), '/path/to/foo/'); | 479 expect(context.fromUri(Uri.parse('file:///path/to/foo')), '/path/to/foo'); |
480 expect(context.fromUri(Uri.parse('file:///')), '/'); | 480 expect(context.fromUri(Uri.parse('file:///path/to/foo/')), |
481 expect(context.fromUri(Uri.parse('foo/bar')), 'foo/bar'); | 481 '/path/to/foo/'); |
482 expect(context.fromUri(Uri.parse('/path/to/foo')), '/path/to/foo'); | 482 expect(context.fromUri(Uri.parse('file:///')), '/'); |
483 expect(context.fromUri(Uri.parse('///path/to/foo')), '/path/to/foo'); | 483 expect(context.fromUri(Uri.parse('foo/bar')), 'foo/bar'); |
484 expect(context.fromUri(Uri.parse('file:///path/to/foo%23bar')), | 484 expect(context.fromUri(Uri.parse('/path/to/foo')), '/path/to/foo'); |
485 '/path/to/foo#bar'); | 485 expect(context.fromUri(Uri.parse('///path/to/foo')), '/path/to/foo'); |
486 expect(context.fromUri(Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')), | 486 expect(context.fromUri(Uri.parse('file:///path/to/foo%23bar')), |
487 r'_{_}_`_^_ _"_%_'); | 487 '/path/to/foo#bar'); |
488 expect(() => context.fromUri(Uri.parse('http://dartlang.org')), | 488 expect(context.fromUri(Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')), |
489 throwsArgumentError); | 489 r'_{_}_`_^_ _"_%_'); |
| 490 expect(() => context.fromUri(Uri.parse('http://dartlang.org')), |
| 491 throwsArgumentError); |
| 492 }); |
| 493 |
| 494 test('with a string', () { |
| 495 expect(context.fromUri('file:///path/to/foo'), '/path/to/foo'); |
| 496 }); |
490 }); | 497 }); |
491 | 498 |
492 test('toUri', () { | 499 test('toUri', () { |
493 expect(context.toUri('/path/to/foo'), Uri.parse('file:///path/to/foo')); | 500 expect(context.toUri('/path/to/foo'), Uri.parse('file:///path/to/foo')); |
494 expect(context.toUri('/path/to/foo/'), Uri.parse('file:///path/to/foo/')); | 501 expect(context.toUri('/path/to/foo/'), Uri.parse('file:///path/to/foo/')); |
495 expect(context.toUri('/'), Uri.parse('file:///')); | 502 expect(context.toUri('/'), Uri.parse('file:///')); |
496 expect(context.toUri('foo/bar'), Uri.parse('foo/bar')); | 503 expect(context.toUri('foo/bar'), Uri.parse('foo/bar')); |
497 expect(context.toUri('/path/to/foo#bar'), | 504 expect(context.toUri('/path/to/foo#bar'), |
498 Uri.parse('file:///path/to/foo%23bar')); | 505 Uri.parse('file:///path/to/foo%23bar')); |
499 expect(context.toUri(r'/_{_}_`_^_ _"_%_'), | 506 expect(context.toUri(r'/_{_}_`_^_ _"_%_'), |
500 Uri.parse('file:///_%7B_%7D_%60_%5E_%20_%22_%25_')); | 507 Uri.parse('file:///_%7B_%7D_%60_%5E_%20_%22_%25_')); |
501 expect(context.toUri(r'_{_}_`_^_ _"_%_'), | 508 expect(context.toUri(r'_{_}_`_^_ _"_%_'), |
502 Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')); | 509 Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')); |
503 }); | 510 }); |
504 } | 511 } |
OLD | NEW |