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

Side by Side Diff: pkg/path/test/url_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/test/posix_test.dart ('k') | pkg/path/test/windows_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 import 'package:unittest/unittest.dart'; 5 import 'package:unittest/unittest.dart';
6 import 'package:path/path.dart' as path; 6 import 'package:path/path.dart' as path;
7 7
8 main() { 8 main() {
9 var builder = new path.Builder(style: path.Style.url, 9 var builder = new path.Builder(style: path.Style.url,
10 root: 'http://dartlang.org/root/path'); 10 root: 'http://dartlang.org/root/path');
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 'http://dartlang.org/b/c'); 216 'http://dartlang.org/b/c');
217 expect(builder.join('file://', 'a', '/b', 'c'), 'file:///b/c'); 217 expect(builder.join('file://', 'a', '/b', 'c'), 'file:///b/c');
218 expect(builder.join('file://', 'a', '/b', 'c', '/d'), 'file:///d'); 218 expect(builder.join('file://', 'a', '/b', 'c', '/d'), 'file:///d');
219 }); 219 });
220 220
221 test('ignores trailing nulls', () { 221 test('ignores trailing nulls', () {
222 expect(builder.join('a', null), equals('a')); 222 expect(builder.join('a', null), equals('a'));
223 expect(builder.join('a', 'b', 'c', null, null), equals('a/b/c')); 223 expect(builder.join('a', 'b', 'c', null, null), equals('a/b/c'));
224 }); 224 });
225 225
226 test('ignores empty strings', () {
227 expect(builder.join(''), '');
228 expect(builder.join('', ''), '');
229 expect(builder.join('', 'a'), 'a');
230 expect(builder.join('a', '', 'b', '', '', '', 'c'), 'a/b/c');
231 expect(builder.join('a', 'b', ''), 'a/b');
232 });
233
226 test('disallows intermediate nulls', () { 234 test('disallows intermediate nulls', () {
227 expect(() => builder.join('a', null, 'b'), throwsArgumentError); 235 expect(() => builder.join('a', null, 'b'), throwsArgumentError);
228 expect(() => builder.join(null, 'a'), throwsArgumentError); 236 expect(() => builder.join(null, 'a'), throwsArgumentError);
229 }); 237 });
230 }); 238 });
231 239
232 group('joinAll', () { 240 group('joinAll', () {
233 test('allows more than eight parts', () { 241 test('allows more than eight parts', () {
234 expect(builder.joinAll(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']), 242 expect(builder.joinAll(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']),
235 'a/b/c/d/e/f/g/h/i'); 243 'a/b/c/d/e/f/g/h/i');
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 Uri.parse('http://dartlang.org/path/to/foo')); 652 Uri.parse('http://dartlang.org/path/to/foo'));
645 expect(builder.toUri('http://dartlang.org/path/to/foo/'), 653 expect(builder.toUri('http://dartlang.org/path/to/foo/'),
646 Uri.parse('http://dartlang.org/path/to/foo/')); 654 Uri.parse('http://dartlang.org/path/to/foo/'));
647 expect(builder.toUri('file:///path/to/foo'), 655 expect(builder.toUri('file:///path/to/foo'),
648 Uri.parse('file:///path/to/foo')); 656 Uri.parse('file:///path/to/foo'));
649 expect(builder.toUri('foo/bar'), Uri.parse('foo/bar')); 657 expect(builder.toUri('foo/bar'), Uri.parse('foo/bar'));
650 expect(builder.toUri('http://dartlang.org/path/to/foo%23bar'), 658 expect(builder.toUri('http://dartlang.org/path/to/foo%23bar'),
651 Uri.parse('http://dartlang.org/path/to/foo%23bar')); 659 Uri.parse('http://dartlang.org/path/to/foo%23bar'));
652 }); 660 });
653 } 661 }
OLDNEW
« no previous file with comments | « pkg/path/test/posix_test.dart ('k') | pkg/path/test/windows_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698