Add a matcher for Matrix4 that includes epsilon (#107326)

This commit is contained in:
Jonah Williams
2022-07-11 12:23:05 -07:00
committed by GitHub
parent acb0a47616
commit f980d6654e
2 changed files with 53 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
// flutter_ignore_for_file: golden_tag (see analyze.dart)
import 'dart:math' as math;
import 'dart:typed_data';
import 'package:flutter/rendering.dart';
@@ -197,6 +198,38 @@ void main() {
expect(-11.0, moreOrLessEquals(11.0, epsilon: 100.0));
});
test('matrixMoreOrLessEquals', () {
expect(
Matrix4.rotationZ(math.pi),
matrixMoreOrLessEquals(Matrix4.fromList(<double>[
-1, 0, 0, 0,
0, -1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
]))
);
expect(
Matrix4.rotationZ(math.pi),
matrixMoreOrLessEquals(Matrix4.fromList(<double>[
-2, 0, 0, 0,
0, -2, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
]), epsilon: 2)
);
expect(
Matrix4.rotationZ(math.pi),
isNot(matrixMoreOrLessEquals(Matrix4.fromList(<double>[
-2, 0, 0, 0,
0, -2, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
])))
);
});
test('rectMoreOrLessEquals', () {
expect(
const Rect.fromLTRB(0.0, 0.0, 10.0, 10.0),