OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 pathos_test; | |
6 | |
7 import 'dart:io' as io; | 5 import 'dart:io' as io; |
8 | 6 |
9 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
10 import 'package:pathos/path.dart' as path; | 8 import 'package:pathos/path.dart' as path; |
11 | 9 |
12 main() { | 10 main() { |
13 group('path.Style', () { | |
14 test('name', () { | |
15 expect(path.Style.posix.name, 'posix'); | |
16 expect(path.Style.windows.name, 'windows'); | |
17 }); | |
18 | |
19 test('separator', () { | |
20 expect(path.Style.posix.separator, '/'); | |
21 expect(path.Style.windows.separator, '\\'); | |
22 }); | |
23 | |
24 test('toString()', () { | |
25 expect(path.Style.posix.toString(), 'posix'); | |
26 expect(path.Style.windows.toString(), 'windows'); | |
27 }); | |
28 }); | |
29 | |
30 group('new Builder()', () { | 11 group('new Builder()', () { |
31 test('uses the given root directory', () { | |
32 var builder = new path.Builder(root: '/a/b/c'); | |
33 expect(builder.root, '/a/b/c'); | |
34 }); | |
35 | |
36 test('uses the given style', () { | |
37 var builder = new path.Builder(style: path.Style.windows); | |
38 expect(builder.style, path.Style.windows); | |
39 }); | |
40 | |
41 test('uses the current working directory if root is omitted', () { | 12 test('uses the current working directory if root is omitted', () { |
42 var builder = new path.Builder(); | 13 var builder = new path.Builder(); |
43 expect(builder.root, io.Directory.current.path); | 14 expect(builder.root, io.Directory.current.path); |
44 }); | 15 }); |
45 | 16 |
46 test('uses the host OS if style is omitted', () { | 17 test('uses the host OS if style is omitted', () { |
47 var builder = new path.Builder(); | 18 var builder = new path.Builder(); |
48 if (io.Platform.operatingSystem == 'windows') { | 19 if (io.Platform.operatingSystem == 'windows') { |
49 expect(builder.style, path.Style.windows); | 20 expect(builder.style, path.Style.windows); |
50 } else { | 21 } else { |
51 expect(builder.style, path.Style.posix); | 22 expect(builder.style, path.Style.posix); |
52 } | 23 } |
53 }); | 24 }); |
54 }); | 25 }); |
55 | 26 |
56 test('current', () { | 27 test('current', () { |
57 expect(path.current, io.Directory.current.path); | 28 expect(path.current, io.Directory.current.path); |
58 }); | 29 }); |
59 } | 30 } |
OLD | NEW |