From 75ed26509d6a8948be15c8f49b4493628b75b4fe Mon Sep 17 00:00:00 2001 From: Christian Guinard <28689358+christiangnrd@users.noreply.github.com> Date: Wed, 5 Mar 2025 15:18:22 -0400 Subject: [PATCH] More --- test/runtests.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index c4509fe..0f7b5bd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,6 +6,7 @@ using Test, BFloat16s, Printf, Random @test Base.exponent_bits(BFloat16) == 8 @test Base.significand_bits(BFloat16) == 7 @test precision(BFloat16) == 8 + @test Base.uinttype(BFloat16) == UInt16 @test typemin(BFloat16) == -BFloat16s.InfB16 @test typemax(BFloat16) == BFloat16s.InfB16 @@ -33,7 +34,7 @@ end end @testset "trunc" begin - bf_val = 5.5 + bf_val = BFloat16(5.5) @testset "$Ti" for Ti in (Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128) @test trunc(Ti, bf_val) == Ti(5) end @@ -48,12 +49,17 @@ end @test Float32(BFloat16(10)) == 1f1 @test Float64(BFloat16(10)) == 10.0 @test Int32(BFloat16(10)) == Int32(10) + @test UInt32(BFloat16(10)) == Int32(10) @test Int64(BFloat16(10)) == Int64(10) + @test UInt64(BFloat16(10)) == Int64(10) @test BFloat16(BigFloat(1)) == BFloat16(1) @test BigFloat(BFloat16(1)) == BigFloat(1) @test Float16(BFloat16(3.140625)) == Float16(π) @test BFloat16(Float16(π)) == BFloat16(3.140625) + @test promote(BFloat16(4.5), Float64(5.0)) == (Float64(4.5), Float64(5.0)) + @test promote(BFloat16(4.5), Float32(5.0)) == (Float32(4.5), Float32(5.0)) + @test_throws InexactError Int8(BFloat16(500)) @test_throws InexactError UInt8(BFloat16(500)) end