2017-10-09 13:39:14 +00:00
|
|
|
import 'package:angel_route/string_util.dart';
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
2021-02-21 02:47:23 +00:00
|
|
|
void main() {
|
2017-10-09 13:39:14 +00:00
|
|
|
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');
|
|
|
|
});
|
2018-08-20 19:34:00 +00:00
|
|
|
}
|