OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'package:unittest/unittest.dart'; |
| 6 |
| 7 import '../lib/src/dartdoc/utils.dart'; |
| 8 |
| 9 void main() { |
| 10 group('countOccurrences', () { |
| 11 test('empty text returns 0', () { |
| 12 expect(countOccurrences('', 'needle'), equals(0)); |
| 13 }); |
| 14 |
| 15 test('one occurrence', () { |
| 16 expect(countOccurrences('bananarama', 'nara'), equals(1)); |
| 17 }); |
| 18 |
| 19 test('multiple occurrences', () { |
| 20 expect(countOccurrences('bananarama', 'a'), equals(5)); |
| 21 }); |
| 22 |
| 23 test('overlapping matches do not count', () { |
| 24 expect(countOccurrences('bananarama', 'ana'), equals(1)); |
| 25 }); |
| 26 }); |
| 27 |
| 28 group('repeat', () { |
| 29 test('zero times returns an empty string', () { |
| 30 expect(repeat('ba', 0), isEmpty); |
| 31 }); |
| 32 |
| 33 test('one time returns the string', () { |
| 34 expect(repeat('ba', 1), equals('ba')); |
| 35 }); |
| 36 |
| 37 test('multiple times', () { |
| 38 expect(repeat('ba', 3), equals('bababa')); |
| 39 }); |
| 40 |
| 41 test('multiple times with a separator', () { |
| 42 expect(repeat('ba', 3, separator: ' '), equals('ba ba ba')); |
| 43 }); |
| 44 }); |
| 45 } |
OLD | NEW |