OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 /// Unit tests for dartdoc. | |
6 #library('dartdoc_tests'); | |
7 | |
8 #import('../dartdoc.dart'); | |
9 | |
10 // TODO(rnystrom): Better path to unittest. | |
pquitslund
2011/12/01 23:29:54
Hear, hear!
| |
11 #import('../../../client/testing/unittest/unittest_node.dart'); | |
12 | |
13 main() { | |
14 group('countOccurrences', () { | |
15 test('empty haystack returns 0', () { | |
16 expect(countOccurrences('', 'needle')).equals(0); | |
17 }); | |
18 | |
19 test('one occurrence', () { | |
20 expect(countOccurrences('bananarama', 'nara')).equals(1); | |
21 }); | |
22 | |
23 test('multiple occurrences', () { | |
24 expect(countOccurrences('bananarama', 'a')).equals(5); | |
25 }); | |
26 | |
27 test('overlapping ones needles do not count', () { | |
28 expect(countOccurrences('bananarama', 'ana')).equals(1); | |
29 }); | |
30 }); | |
31 | |
32 group('repeat', () { | |
33 test('zero times returns an empty string', () { | |
34 expect(repeat('ba', 0)).equals(''); | |
35 }); | |
36 | |
37 test('one time returns the string', () { | |
38 expect(repeat('ba', 1)).equals('ba'); | |
39 }); | |
40 | |
41 test('multiple times', () { | |
42 expect(repeat('ba', 3)).equals('bababa'); | |
43 }); | |
44 | |
45 test('multiple times with a separator', () { | |
46 expect(repeat('ba', 3, separator: ' ')).equals('ba ba ba'); | |
47 }); | |
48 }); | |
49 | |
50 group('relativePath', () { | |
51 test('from root to root', () { | |
52 startFile('root.html'); | |
53 expect(relativePath('other.html')).equals('other.html'); | |
54 }); | |
55 | |
56 test('from root to directory', () { | |
57 startFile('root.html'); | |
58 expect(relativePath('dir/file.html')).equals('dir/file.html'); | |
59 }); | |
60 | |
61 test('from root to nested', () { | |
62 startFile('root.html'); | |
63 expect(relativePath('dir/sub/file.html')).equals('dir/sub/file.html'); | |
64 }); | |
65 | |
66 test('from directory to root', () { | |
67 startFile('dir/file.html'); | |
68 expect(relativePath('root.html')).equals('../root.html'); | |
69 }); | |
70 | |
71 test('from nested to root', () { | |
72 startFile('dir/sub/file.html'); | |
73 expect(relativePath('root.html')).equals('../../root.html'); | |
74 }); | |
75 | |
76 test('from dir to dir with different path', () { | |
77 startFile('dir/file.html'); | |
78 expect(relativePath('other/file.html')).equals('../other/file.html'); | |
79 }); | |
80 | |
81 test('from nested to nested with different path', () { | |
82 startFile('dir/sub/file.html'); | |
83 expect(relativePath('other/sub/file.html')).equals( | |
84 '../../other/sub/file.html'); | |
85 }); | |
86 | |
87 test('from nested to directory with different path', () { | |
88 startFile('dir/sub/file.html'); | |
89 expect(relativePath('other/file.html')).equals( | |
90 '../../other/file.html'); | |
91 }); | |
92 }); | |
93 } | |
OLD | NEW |