Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechi1219 committed Jun 21, 2020
1 parent 1ae6cd3 commit c3e94ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/core/util/input_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class InputConverter {
throw FormatException();
}
return Right(integer);
} on ArgumentError {
return Left(InvalidInputFailure());
} on FormatException {
return Left(InvalidInputFailure());
}
Expand Down
12 changes: 12 additions & 0 deletions test/core/util/input_converter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ void main() {
},
);

test(
'should return a Failure when the string is null',
() async {
// arrange
final str = null;
// act
final result = inputConverter.stringToUnsignedInteger(str);
// assert
expect(result, Left(InvalidInputFailure()));
},
);

test(
'should return a Failure when the string is not an integer',
() async {
Expand Down

0 comments on commit c3e94ea

Please sign in to comment.