2018-08-20 14:24:11 +00:00
|
|
|
import 'package:angel_route/angel_route.dart';
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
|
|
|
void main() {
|
2019-11-28 17:40:32 +00:00
|
|
|
var router = Router()
|
2018-08-20 14:24:11 +00:00
|
|
|
..get('/int/int:id', '')
|
|
|
|
..get('/double/double:id', '')
|
|
|
|
..get('/num/num:id', '');
|
|
|
|
|
|
|
|
num getId(String path) {
|
|
|
|
var result = router.resolveAbsolute(path).first;
|
2018-08-20 18:59:51 +00:00
|
|
|
return result.allParams['id'] as num;
|
2018-08-20 14:24:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
test('parse', () {
|
|
|
|
expect(getId('/int/2'), 2);
|
|
|
|
expect(getId('/double/2.0'), 2.0);
|
|
|
|
expect(getId('/num/-2.4'), -2.4);
|
|
|
|
});
|
|
|
|
}
|