Add more examples for Integer.parse
- show behavior of parsing with unparsable suffix bits - show behavior of parsing float as integer
This commit is contained in:
@@ -39,6 +39,14 @@ defmodule Numbers do
|
||||
assert Integer.parse("2A", 16) == {___, ""}
|
||||
end
|
||||
|
||||
koan "The remaining unparsable part is also returned" do
|
||||
assert Integer.parse("5 years") == {5, ___}
|
||||
end
|
||||
|
||||
koan "What if you parse a floating point value as an integer?" do
|
||||
assert Integer.parse("1.2") == {___, ___}
|
||||
end
|
||||
|
||||
koan "Just want to parse to a float" do
|
||||
assert Float.parse("34.5") == {___, ""}
|
||||
end
|
||||
|
||||
@@ -11,6 +11,8 @@ defmodule NumbersTests do
|
||||
'7',
|
||||
"1234",
|
||||
42,
|
||||
" years",
|
||||
{:multiple, [1, ".2"]},
|
||||
34.5,
|
||||
1.5,
|
||||
35.0,
|
||||
|
||||
Reference in New Issue
Block a user