Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve coverage for float/float.mbt #1564

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions float/float_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,33 @@ test "@float.Float::is_nan" {
inspect!(@float.min_value.is_nan(), content="false")
inspect!(@float.min_positive.is_nan(), content="false")
}

test "Float::default()" {
inspect!(Float::default(), content="0")
}

test "Float::to_be_bytes with various values" {
let f1 : Float = 0.0
inspect!(f1.to_be_bytes(), content="b\"\\x00\\x00\\x00\\x00\"")
let f2 : Float = -1.0
inspect!(f2.to_be_bytes(), content="b\"\\xbf\\x80\\x00\\x00\"")
let f3 : Float = @float.infinity
inspect!(f3.to_be_bytes(), content="b\"\\x7f\\x80\\x00\\x00\"")
let f4 : Float = @float.not_a_number
inspect!(f4.to_be_bytes(), content="b\"\\x7f\\xc0\\x00\\x00\"")
}

test "to_le_bytes for zero" {
inspect!(
(0.0 : Float).to_le_bytes(),
content=
#|b"\x00\x00\x00\x00"
,
)
inspect!(
(-0.0 : Float).to_le_bytes(),
content=
#|b"\x00\x00\x00\x80"
,
)
}
Loading