test: add tests for the isBetween function

This commit is contained in:
ricardodalarme 2023-03-25 16:12:46 -03:00
parent 8330f0bc80
commit 9288df4d65
1 changed files with 46 additions and 0 deletions

46
test/extensions_test.dart Normal file
View File

@ -0,0 +1,46 @@
import 'package:flutter_card_swiper/src/extensions.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('isBetween', () {
test('should return true when value is within range', () {
const value = 5;
const from = 1;
const to = 10;
final result = value.isBetween(from, to);
expect(result, isTrue);
});
test('should return true when value is equal to the range limits', () {
const value = 1;
const from = 1;
const to = 1;
final result = value.isBetween(from, to);
expect(result, isTrue);
});
test('should return false when value is outside the range', () {
const value = 15;
const from = 1;
const to = 10;
final result = value.isBetween(from, to);
expect(result, isFalse);
});
test('should return false when the range limits are inverted', () {
const value = 5;
const from = 10;
const to = 1;
final result = value.isBetween(from, to);
expect(result, isFalse);
});
});
}