nc-photos/np_math/test/num_extension_test.dart

62 lines
2.3 KiB
Dart
Raw Normal View History

2023-08-25 17:29:27 +02:00
import 'package:np_math/src/num_extension.dart';
2021-06-21 11:04:09 +02:00
import 'package:test/test.dart';
void main() {
group("NumExtension", () {
group("inRange", () {
test("[x, y)", () {
expect(10.inRange(0, 20, isBegInclusive: true, isEndInclusive: false),
true);
expect(0.inRange(0, 20, isBegInclusive: true, isEndInclusive: false),
true);
expect((-1).inRange(0, 20, isBegInclusive: true, isEndInclusive: false),
false);
expect(20.inRange(0, 20, isBegInclusive: true, isEndInclusive: false),
false);
expect(21.inRange(0, 20, isBegInclusive: true, isEndInclusive: false),
false);
});
test("[x, y]", () {
expect(10.inRange(0, 20, isBegInclusive: true, isEndInclusive: true),
true);
expect(
0.inRange(0, 20, isBegInclusive: true, isEndInclusive: true), true);
expect((-1).inRange(0, 20, isBegInclusive: true, isEndInclusive: true),
false);
expect(20.inRange(0, 20, isBegInclusive: true, isEndInclusive: true),
true);
expect(21.inRange(0, 20, isBegInclusive: true, isEndInclusive: true),
false);
});
test("(x, y)", () {
expect(10.inRange(0, 20, isBegInclusive: false, isEndInclusive: false),
true);
expect(0.inRange(0, 20, isBegInclusive: false, isEndInclusive: false),
false);
expect(
(-1).inRange(0, 20, isBegInclusive: false, isEndInclusive: false),
false);
expect(20.inRange(0, 20, isBegInclusive: false, isEndInclusive: false),
false);
expect(21.inRange(0, 20, isBegInclusive: false, isEndInclusive: false),
false);
});
test("(x, y]", () {
expect(10.inRange(0, 20, isBegInclusive: false, isEndInclusive: true),
true);
expect(0.inRange(0, 20, isBegInclusive: false, isEndInclusive: true),
false);
expect((-1).inRange(0, 20, isBegInclusive: false, isEndInclusive: true),
false);
expect(20.inRange(0, 20, isBegInclusive: false, isEndInclusive: true),
true);
expect(21.inRange(0, 20, isBegInclusive: false, isEndInclusive: true),
false);
});
});
});
}