torch_state_test.dart
1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import 'package:flutter_test/flutter_test.dart';
import 'package:mobile_scanner/src/enums/torch_state.dart';
void main() {
group('$TorchState tests', () {
test('can be created from raw value', () {
const values = <int, TorchState>{
0: TorchState.off,
1: TorchState.on,
};
for (final MapEntry<int, TorchState> entry in values.entries) {
final TorchState result = TorchState.fromRawValue(entry.key);
expect(result, entry.value);
}
});
test('invalid raw value throws argument error', () {
const int negative = -1;
const int outOfRange = 2;
expect(() => TorchState.fromRawValue(negative), throwsArgumentError);
expect(() => TorchState.fromRawValue(outOfRange), throwsArgumentError);
});
test('can be converted to raw value', () {
const values = <TorchState, int>{
TorchState.off: 0,
TorchState.on: 1,
};
for (final MapEntry<TorchState, int> entry in values.entries) {
final int result = entry.key.rawValue;
expect(result, entry.value);
}
});
});
}