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

Side by Side Diff: pkg/path/test/posix_test.dart

Issue 19219002: Test empty strings arguments to path.join(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Handle trailing empty string args in path.join(). Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « pkg/path/lib/path.dart ('k') | pkg/path/test/url_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 main() { 10 main() {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 expect(builder.join('a', '/b', '/c', 'd'), '/c/d'); 146 expect(builder.join('a', '/b', '/c', 'd'), '/c/d');
147 expect(builder.join('a', r'c:\b', 'c', 'd'), r'a/c:\b/c/d'); 147 expect(builder.join('a', r'c:\b', 'c', 'd'), r'a/c:\b/c/d');
148 expect(builder.join('a', r'\\b', 'c', 'd'), r'a/\\b/c/d'); 148 expect(builder.join('a', r'\\b', 'c', 'd'), r'a/\\b/c/d');
149 }); 149 });
150 150
151 test('ignores trailing nulls', () { 151 test('ignores trailing nulls', () {
152 expect(builder.join('a', null), equals('a')); 152 expect(builder.join('a', null), equals('a'));
153 expect(builder.join('a', 'b', 'c', null, null), equals('a/b/c')); 153 expect(builder.join('a', 'b', 'c', null, null), equals('a/b/c'));
154 }); 154 });
155 155
156 test('ignores empty strings', () {
157 expect(builder.join(''), '');
158 expect(builder.join('', ''), '');
159 expect(builder.join('', 'a'), 'a');
160 expect(builder.join('a', '', 'b', '', '', '', 'c'), 'a/b/c');
161 expect(builder.join('a', 'b', ''), 'a/b');
162 });
163
156 test('disallows intermediate nulls', () { 164 test('disallows intermediate nulls', () {
157 expect(() => builder.join('a', null, 'b'), throwsArgumentError); 165 expect(() => builder.join('a', null, 'b'), throwsArgumentError);
158 expect(() => builder.join(null, 'a'), throwsArgumentError); 166 expect(() => builder.join(null, 'a'), throwsArgumentError);
159 }); 167 });
160 }); 168 });
161 169
162 group('joinAll', () { 170 group('joinAll', () {
163 test('allows more than eight parts', () { 171 test('allows more than eight parts', () {
164 expect(builder.joinAll(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']), 172 expect(builder.joinAll(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']),
165 'a/b/c/d/e/f/g/h/i'); 173 'a/b/c/d/e/f/g/h/i');
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 423
416 test('toUri', () { 424 test('toUri', () {
417 expect(builder.toUri('/path/to/foo'), Uri.parse('file:///path/to/foo')); 425 expect(builder.toUri('/path/to/foo'), Uri.parse('file:///path/to/foo'));
418 expect(builder.toUri('/path/to/foo/'), Uri.parse('file:///path/to/foo/')); 426 expect(builder.toUri('/path/to/foo/'), Uri.parse('file:///path/to/foo/'));
419 expect(builder.toUri('/'), Uri.parse('file:///')); 427 expect(builder.toUri('/'), Uri.parse('file:///'));
420 expect(builder.toUri('foo/bar'), Uri.parse('foo/bar')); 428 expect(builder.toUri('foo/bar'), Uri.parse('foo/bar'));
421 expect(builder.toUri('/path/to/foo#bar'), 429 expect(builder.toUri('/path/to/foo#bar'),
422 Uri.parse('file:///path/to/foo%23bar')); 430 Uri.parse('file:///path/to/foo%23bar'));
423 }); 431 });
424 } 432 }
OLDNEW
« no previous file with comments | « pkg/path/lib/path.dart ('k') | pkg/path/test/url_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698