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 14:11:56 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a0f1b37952c52be3bee3d92e93b8787e026bbb3f
a0f1b379
1 parent
dc89269f
add EncryptionType test
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
2 deletions
lib/src/enums/encryption_type.dart
test/enums/encryption_type_test.dart
lib/src/enums/encryption_type.dart
View file @
a0f1b37
...
...
@@ -16,15 +16,16 @@ enum EncryptionType {
factory
EncryptionType
.
fromRawValue
(
int
value
)
{
switch
(
value
)
{
case
0
:
return
EncryptionType
.
none
;
case
1
:
return
EncryptionType
.
open
;
case
2
:
return
EncryptionType
.
wpa
;
case
3
:
return
EncryptionType
.
wep
;
case
0
:
default
:
return
EncryptionType
.
none
;
throw
ArgumentError
.
value
(
value
,
'value'
,
'Invalid raw value.'
)
;
}
}
...
...
test/enums/encryption_type_test.dart
0 → 100644
View file @
a0f1b37
import
'package:flutter_test/flutter_test.dart'
;
import
'package:mobile_scanner/src/enums/encryption_type.dart'
;
void
main
(
)
{
group
(
'
$EncryptionType
tests'
,
()
{
test
(
'can be created from raw value'
,
()
{
const
values
=
<
int
,
EncryptionType
>{
0
:
EncryptionType
.
none
,
1
:
EncryptionType
.
open
,
2
:
EncryptionType
.
wpa
,
3
:
EncryptionType
.
wep
,
};
for
(
final
MapEntry
<
int
,
EncryptionType
>
entry
in
values
.
entries
)
{
final
EncryptionType
result
=
EncryptionType
.
fromRawValue
(
entry
.
key
);
expect
(
result
,
entry
.
value
);
}
});
test
(
'invalid raw value throws argument error'
,
()
{
const
int
negative
=
-
1
;
const
int
outOfRange
=
4
;
expect
(()
=>
EncryptionType
.
fromRawValue
(
negative
),
throwsArgumentError
);
expect
(()
=>
EncryptionType
.
fromRawValue
(
outOfRange
),
throwsArgumentError
);
});
test
(
'can be converted to raw value'
,
()
{
const
values
=
<
EncryptionType
,
int
>{
EncryptionType
.
none
:
0
,
EncryptionType
.
open
:
1
,
EncryptionType
.
wpa
:
2
,
EncryptionType
.
wep
:
3
,
};
for
(
final
MapEntry
<
EncryptionType
,
int
>
entry
in
values
.
entries
)
{
final
int
result
=
entry
.
key
.
rawValue
;
expect
(
result
,
entry
.
value
);
}
});
});
}
...
...
Please
register
or
login
to post a comment