test: fixed tests for assertions

pull/27/head
RuiAlonso 4 years ago
parent 9d0ed24ce8
commit 1692532a43

@ -1,7 +1,7 @@
// ignore_for_file: prefer_const_constructors, cascade_invocations // ignore_for_file: prefer_const_constructors, cascade_invocations
import 'package:flame/extensions.dart'; import 'package:flame/extensions.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:geometry/geometry.dart'; import 'package:geometry/geometry.dart';
import 'package:test/test.dart';
class Binomial { class Binomial {
Binomial({required this.n, required this.k}); Binomial({required this.n, required this.k});
@ -42,18 +42,18 @@ void main() {
], ],
step: 2, step: 2,
), ),
throwsAssertionError, throwsA(const TypeMatcher<AssertionError>()),
); );
}); });
test('fails if not enough control points', () { test('fails if not enough control points', () {
expect( expect(
() => calculateBezierCurve(controlPoints: [Vector2.zero()]), () => calculateBezierCurve(controlPoints: [Vector2.zero()]),
throwsAssertionError, throwsA(const TypeMatcher<AssertionError>()),
); );
expect( expect(
() => calculateBezierCurve(controlPoints: []), () => calculateBezierCurve(controlPoints: []),
throwsAssertionError, throwsA(const TypeMatcher<AssertionError>()),
); );
}); });
@ -81,15 +81,18 @@ void main() {
group('binomial', () { group('binomial', () {
test('fails if k is negative', () { test('fails if k is negative', () {
expect(() => binomial(1, -1), throwsAssertionError); expect(
() => binomial(1, -1), throwsA(const TypeMatcher<AssertionError>()));
}); });
test('fails if n is negative', () { test('fails if n is negative', () {
expect(() => binomial(-1, 1), throwsAssertionError); expect(
() => binomial(-1, 1), throwsA(const TypeMatcher<AssertionError>()));
}); });
test('fails if n < k', () { test('fails if n < k', () {
expect(() => binomial(1, 2), throwsAssertionError); expect(
() => binomial(1, 2), throwsA(const TypeMatcher<AssertionError>()));
}); });
test('for a specific input gives a correct value', () { test('for a specific input gives a correct value', () {
@ -131,7 +134,7 @@ void main() {
group('factorial', () { group('factorial', () {
test('fails if negative number', () { test('fails if negative number', () {
expect(() => factorial(-1), throwsAssertionError); expect(() => factorial(-1), throwsA(const TypeMatcher<AssertionError>()));
}); });
test('for a specific input gives a correct value', () { test('for a specific input gives a correct value', () {

Loading…
Cancel
Save