提交 25b3cbb2 编写于 作者: R Ryuta Kamizono

Add edge test cases for integer and string types

上级 78d23d82
......@@ -50,6 +50,13 @@ class IntegerTest < ActiveModel::TestCase
assert_equal 7200, type.cast(2.hours)
end
test "casting empty string" do
type = Type::Integer.new
assert_nil type.cast("")
assert_nil type.serialize("")
assert_equal 0, type.deserialize("")
end
test "changed?" do
type = Type::Integer.new
......
......@@ -12,6 +12,14 @@ class StringTest < ActiveModel::TestCase
assert_equal "123", type.cast(123)
end
test "type casting for database" do
type = Type::String.new
object, array, hash = Object.new, [true], { a: :b }
assert_equal object, type.serialize(object)
assert_equal array, type.serialize(array)
assert_equal hash, type.serialize(hash)
end
test "cast strings are mutable" do
type = Type::String.new
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册