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:56:19 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bbc9042bea22a6d16fd6594f276bf1f786b7184c
bbc9042b
1 parent
c0a8dc36
add BarcodeType test
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
test/enums/barcode_type_test.dart
test/enums/barcode_type_test.dart
0 → 100644
View file @
bbc9042
import
'package:flutter_test/flutter_test.dart'
;
import
'package:mobile_scanner/src/enums/barcode_type.dart'
;
void
main
(
)
{
group
(
'
$BarcodeType
tests'
,
()
{
test
(
'can be created from raw value'
,
()
{
const
values
=
<
int
,
BarcodeType
>{
0
:
BarcodeType
.
unknown
,
1
:
BarcodeType
.
contactInfo
,
2
:
BarcodeType
.
email
,
3
:
BarcodeType
.
isbn
,
4
:
BarcodeType
.
phone
,
5
:
BarcodeType
.
product
,
6
:
BarcodeType
.
sms
,
7
:
BarcodeType
.
text
,
8
:
BarcodeType
.
url
,
9
:
BarcodeType
.
wifi
,
10
:
BarcodeType
.
geo
,
11
:
BarcodeType
.
calendarEvent
,
12
:
BarcodeType
.
driverLicense
,
};
for
(
final
MapEntry
<
int
,
BarcodeType
>
entry
in
values
.
entries
)
{
final
BarcodeType
result
=
BarcodeType
.
fromRawValue
(
entry
.
key
);
expect
(
result
,
entry
.
value
);
}
});
test
(
'invalid raw value creates unknown barcode type'
,
()
{
final
BarcodeType
negative
=
BarcodeType
.
fromRawValue
(-
1
);
final
BarcodeType
outOfRange
=
BarcodeType
.
fromRawValue
(
13
);
expect
(
negative
,
BarcodeType
.
unknown
);
expect
(
outOfRange
,
BarcodeType
.
unknown
);
});
test
(
'can be converted to raw value'
,
()
{
const
values
=
<
BarcodeType
,
int
>{
BarcodeType
.
unknown
:
0
,
BarcodeType
.
contactInfo
:
1
,
BarcodeType
.
email
:
2
,
BarcodeType
.
isbn
:
3
,
BarcodeType
.
phone
:
4
,
BarcodeType
.
product
:
5
,
BarcodeType
.
sms
:
6
,
BarcodeType
.
text
:
7
,
BarcodeType
.
url
:
8
,
BarcodeType
.
wifi
:
9
,
BarcodeType
.
geo
:
10
,
BarcodeType
.
calendarEvent
:
11
,
BarcodeType
.
driverLicense
:
12
,
};
for
(
final
MapEntry
<
BarcodeType
,
int
>
entry
in
values
.
entries
)
{
final
int
result
=
entry
.
key
.
rawValue
;
expect
(
result
,
entry
.
value
);
}
});
});
}
...
...
Please
register
or
login
to post a comment