Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
mobile_scanner
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Navaron Bracke
2023-10-23 10:38:17 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c0a8dc365bf835987bc9a6d54d93c5b92240bf56
c0a8dc36
1 parent
ac68a214
add BarcodeFormat test
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
test/enums/barcode_format_test.dart
test/enums/barcode_format_test.dart
0 → 100644
View file @
c0a8dc3
import
'package:flutter_test/flutter_test.dart'
;
import
'package:mobile_scanner/src/enums/barcode_format.dart'
;
void
main
(
)
{
group
(
'
$BarcodeFormat
tests'
,
()
{
test
(
'can be created from raw value'
,
()
{
const
values
=
<
int
,
BarcodeFormat
>{
-
1
:
BarcodeFormat
.
unknown
,
0
:
BarcodeFormat
.
all
,
1
:
BarcodeFormat
.
code128
,
2
:
BarcodeFormat
.
code39
,
4
:
BarcodeFormat
.
code93
,
8
:
BarcodeFormat
.
codebar
,
16
:
BarcodeFormat
.
dataMatrix
,
32
:
BarcodeFormat
.
ean13
,
64
:
BarcodeFormat
.
ean8
,
128
:
BarcodeFormat
.
itf
,
256
:
BarcodeFormat
.
qrCode
,
512
:
BarcodeFormat
.
upcA
,
1024
:
BarcodeFormat
.
upcE
,
2048
:
BarcodeFormat
.
pdf417
,
4096
:
BarcodeFormat
.
aztec
,
};
for
(
final
MapEntry
<
int
,
BarcodeFormat
>
entry
in
values
.
entries
)
{
final
BarcodeFormat
result
=
BarcodeFormat
.
fromRawValue
(
entry
.
key
);
expect
(
result
,
entry
.
value
);
}
});
test
(
'invalid raw value creates unknown barcode format'
,
()
{
final
BarcodeFormat
negative
=
BarcodeFormat
.
fromRawValue
(-
2
);
final
BarcodeFormat
outOfRange
=
BarcodeFormat
.
fromRawValue
(
4097
);
expect
(
negative
,
BarcodeFormat
.
unknown
);
expect
(
outOfRange
,
BarcodeFormat
.
unknown
);
});
test
(
'can be converted to raw value'
,
()
{
const
values
=
<
BarcodeFormat
,
int
>{
BarcodeFormat
.
unknown
:
-
1
,
BarcodeFormat
.
all
:
0
,
BarcodeFormat
.
code128
:
1
,
BarcodeFormat
.
code39
:
2
,
BarcodeFormat
.
code93
:
4
,
BarcodeFormat
.
codebar
:
8
,
BarcodeFormat
.
dataMatrix
:
16
,
BarcodeFormat
.
ean13
:
32
,
BarcodeFormat
.
ean8
:
64
,
BarcodeFormat
.
itf
:
128
,
BarcodeFormat
.
qrCode
:
256
,
BarcodeFormat
.
upcA
:
512
,
BarcodeFormat
.
upcE
:
1024
,
BarcodeFormat
.
pdf417
:
2048
,
BarcodeFormat
.
aztec
:
4096
,
};
for
(
final
MapEntry
<
BarcodeFormat
,
int
>
entry
in
values
.
entries
)
{
final
int
result
=
entry
.
key
.
rawValue
;
expect
(
result
,
entry
.
value
);
}
});
});
}
...
...
Please
register
or
login
to post a comment