platform/packages/route/test/strip_test.dart
Tobe O 5eef4314ec Add 'packages/route/' from commit '8b2b0524609ab737eb5569fdf82a7ac491fdc67b'
git-subtree-dir: packages/route
git-subtree-mainline: 6db839928b
git-subtree-split: 8b2b052460
2020-02-15 18:22:17 -05:00

46 lines
956 B
Dart

import 'package:angel_route/string_util.dart';
import 'package:test/test.dart';
main() {
test('strip leading', () {
var a = '///a';
var b = stripStraySlashes(a);
print('$a => $b');
expect(b, 'a');
});
test('strip trailing', () {
var a = 'a///';
var b = stripStraySlashes(a);
print('$a => $b');
expect(b, 'a');
});
test('strip both', () {
var a = '///a///';
var b = stripStraySlashes(a);
print('$a => $b');
expect(b, 'a');
});
test('intermediate slashes preserved', () {
var a = '///a///b//';
var b = stripStraySlashes(a);
print('$a => $b');
expect(b, 'a///b');
});
test('only if starts with', () {
var a = 'd///a///b//';
var b = stripStraySlashes(a);
print('$a => $b');
expect(b, 'd///a///b');
});
test('only if ends with', () {
var a = '///a///b//c';
var b = stripStraySlashes(a);
print('$a => $b');
expect(b, 'a///b//c');
});
}