mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-12 19:01:09 +08:00
31 lines
857 B
Dart
31 lines
857 B
Dart
import 'package:flame/src/anchor.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
void main() {
|
|
group('Anchor', () {
|
|
test('can parse to and from string', () async {
|
|
expect(Anchor.center.toString(), 'center');
|
|
expect(Anchor.valueOf('topRight'), Anchor.topRight);
|
|
|
|
expect(Anchor.values.length, 9);
|
|
|
|
for (final value in Anchor.values) {
|
|
final thereAndBack = Anchor.valueOf(value.toString());
|
|
expect(thereAndBack, value);
|
|
}
|
|
});
|
|
|
|
test('can parse custom anchor', () async {
|
|
expect(const Anchor(0.2, 0.2).toString(), 'Anchor(0.2, 0.2)');
|
|
expect(Anchor.valueOf('Anchor(0.2, 0.2)'), const Anchor(0.2, 0.2));
|
|
});
|
|
|
|
test('fail to parse invalid anchor', () async {
|
|
expect(
|
|
() => Anchor.valueOf('foobar'),
|
|
throwsA(const TypeMatcher<AssertionError>()),
|
|
);
|
|
});
|
|
});
|
|
}
|