Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F114988
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/test/cast/number_test.exs b/test/cast/number_test.exs
index a2c6a4c..398008d 100644
--- a/test/cast/number_test.exs
+++ b/test/cast/number_test.exs
@@ -1,66 +1,66 @@
defmodule OpenApiSpex.CastNumberTest do
use ExUnit.Case
alias OpenApiSpex.{Cast, Schema}
alias OpenApiSpex.Cast.{Error, Number}
defp cast(ctx), do: Number.cast(struct(Cast, ctx))
describe "cast/1" do
test "basics" do
schema = %Schema{type: :number}
- assert cast(value: 1, schema: schema) == {:ok, 1}
- assert cast(value: 1.5, schema: schema) == {:ok, 1.5}
- assert cast(value: "1", schema: schema) == {:ok, 1}
- assert cast(value: "1.5", schema: schema) == {:ok, 1.5}
+ assert cast(value: 1, schema: schema) === {:ok, 1}
+ assert cast(value: 1.5, schema: schema) === {:ok, 1.5}
+ assert cast(value: "1", schema: schema) === {:ok, 1.0}
+ assert cast(value: "1.5", schema: schema) === {:ok, 1.5}
assert {:error, [error]} = cast(value: "other", schema: schema)
assert %Error{reason: :invalid_type} = error
assert error.value == "other"
end
test "with minimum" do
schema = %Schema{type: :number, minimum: 2}
- assert cast(value: 3, schema: schema) == {:ok, 3}
- assert cast(value: 2, schema: schema) == {:ok, 2}
+ assert cast(value: 3, schema: schema) === {:ok, 3}
+ assert cast(value: 2, schema: schema) === {:ok, 2}
assert {:error, [error]} = cast(value: 1, schema: schema)
assert error.reason == :minimum
- assert error.value == 1
+ assert error.value === 1
# error.length is the minimum
- assert error.length == 2
+ assert error.length === 2
assert Error.message(error) =~ "smaller than inclusive minimum"
end
test "with maximum" do
schema = %Schema{type: :number, maximum: 2}
- assert cast(value: 1, schema: schema) == {:ok, 1}
- assert cast(value: 2, schema: schema) == {:ok, 2}
+ assert cast(value: 1, schema: schema) === {:ok, 1}
+ assert cast(value: 2, schema: schema) === {:ok, 2}
assert {:error, [error]} = cast(value: 3, schema: schema)
- assert error.reason == :maximum
- assert error.value == 3
+ assert error.reason === :maximum
+ assert error.value === 3
# error.length is the maximum
- assert error.length == 2
+ assert error.length === 2
assert Error.message(error) =~ "larger than inclusive maximum"
end
test "with minimum w/ exclusiveMinimum" do
schema = %Schema{type: :number, minimum: 2, exclusiveMinimum: true}
assert cast(value: 3, schema: schema) == {:ok, 3}
assert {:error, [error]} = cast(value: 2, schema: schema)
assert error.reason == :exclusive_min
assert error.value == 2
# error.length is the minimum
assert error.length == 2
assert Error.message(error) =~ "smaller than exclusive minimum"
end
test "with maximum w/ exclusiveMaximum" do
schema = %Schema{type: :number, maximum: 2, exclusiveMaximum: true}
assert cast(value: 1, schema: schema) == {:ok, 1}
assert {:error, [error]} = cast(value: 2, schema: schema)
assert error.reason == :exclusive_max
assert error.value == 2
# error.length is the maximum
assert error.length == 2
assert Error.message(error) =~ "larger than exclusive maximum"
end
end
end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Nov 26, 10:31 PM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40500
Default Alt Text
(3 KB)
Attached To
Mode
R22 open_api_spex
Attached
Detach File
Event Timeline
Log In to Comment