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/')), '/path/to/foo/' ); |
Bob Nystrom
2014/03/18 20:31:09
Long line.
nweiz
2014/03/18 22:02:19
Done.
| |
481 expect(context.fromUri(Uri.parse('foo/bar')), 'foo/bar'); | 481 expect(context.fromUri(Uri.parse('file:///')), '/'); |
482 expect(context.fromUri(Uri.parse('/path/to/foo')), '/path/to/foo'); | 482 expect(context.fromUri(Uri.parse('foo/bar')), 'foo/bar'); |
483 expect(context.fromUri(Uri.parse('///path/to/foo')), '/path/to/foo'); | 483 expect(context.fromUri(Uri.parse('/path/to/foo')), '/path/to/foo'); |
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('file:///path/to/foo%23bar')), |
486 expect(context.fromUri(Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')), | 486 '/path/to/foo#bar'); |
487 r'_{_}_`_^_ _"_%_'); | 487 expect(context.fromUri(Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')), |
488 expect(() => context.fromUri(Uri.parse('http://dartlang.org')), | 488 r'_{_}_`_^_ _"_%_'); |
489 throwsArgumentError); | 489 expect(() => context.fromUri(Uri.parse('http://dartlang.org')), |
490 throwsArgumentError); | |
491 }); | |
492 | |
493 test('with a string', () { | |
494 expect(context.fromUri('file:///path/to/foo'), '/path/to/foo'); | |
495 }); | |
490 }); | 496 }); |
491 | 497 |
492 test('toUri', () { | 498 test('toUri', () { |
493 expect(context.toUri('/path/to/foo'), Uri.parse('file:///path/to/foo')); | 499 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/')); | 500 expect(context.toUri('/path/to/foo/'), Uri.parse('file:///path/to/foo/')); |
495 expect(context.toUri('/'), Uri.parse('file:///')); | 501 expect(context.toUri('/'), Uri.parse('file:///')); |
496 expect(context.toUri('foo/bar'), Uri.parse('foo/bar')); | 502 expect(context.toUri('foo/bar'), Uri.parse('foo/bar')); |
497 expect(context.toUri('/path/to/foo#bar'), | 503 expect(context.toUri('/path/to/foo#bar'), |
498 Uri.parse('file:///path/to/foo%23bar')); | 504 Uri.parse('file:///path/to/foo%23bar')); |
499 expect(context.toUri(r'/_{_}_`_^_ _"_%_'), | 505 expect(context.toUri(r'/_{_}_`_^_ _"_%_'), |
500 Uri.parse('file:///_%7B_%7D_%60_%5E_%20_%22_%25_')); | 506 Uri.parse('file:///_%7B_%7D_%60_%5E_%20_%22_%25_')); |
501 expect(context.toUri(r'_{_}_`_^_ _"_%_'), | 507 expect(context.toUri(r'_{_}_`_^_ _"_%_'), |
502 Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')); | 508 Uri.parse('_%7B_%7D_%60_%5E_%20_%22_%25_')); |
503 }); | 509 }); |
504 } | 510 } |
OLD | NEW |