Skip to content

Commit

Permalink
test: deduce type for adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
miRoox committed Jun 18, 2024
1 parent ac905be commit 1400e05
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ end
@test_throws ValidationError deserialize(Validator(Int8, (v; kw...) -> v >= get(kw, :min_value, 0)), b"\x00"; min_value=1)
end
@testset "type Adapter" begin
@testset "deduce type" begin
@test Constructs.deducetype(() -> Adapter(Int, Integer)) <: Construct{Integer}
@test Constructs.deducetype((b) -> b ? Adapter(Int, Integer) : Adapter(UInt, Integer), Bool) <: Construct{Integer}
@test Constructs.deducetype((b) -> Adapter(b ? Int : UInt, Integer), Bool) <: Construct{Integer}
end
@test estimatesize(Adapter(UInt8, Int)) == sizeof(UInt8)
@test serialize(Adapter(UInt8, Int), 10) == b"\x0a"
@test_throws InexactError serialize(Adapter(UInt8, Int), 256)
Expand Down

0 comments on commit 1400e05

Please sign in to comment.