Skip to content

Commit

Permalink
fix round-trip for f32
Browse files Browse the repository at this point in the history
  • Loading branch information
saks committed May 20, 2021
1 parent e4b9f82 commit 44b4c44
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions examples/rondpoint/tests/bindings/test_rondpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def affirm_aller_retour(vals, fn_name)

# Ruby floats are always doubles, so won't round-trip through f32 correctly.
# This truncates them appropriately.
F32_ONE_THIRD = 1.0 / 3
F32_ONE_THIRD = [1.0 / 3].pack('f').unpack('f')[0]

# Booleans
affirm_aller_retour([true, false], :identique_boolean)
Expand All @@ -80,8 +80,7 @@ def affirm_aller_retour(vals, fn_name)
affirm_aller_retour([0x0000000000000000, 0x1234567890ABCDEF, 0xFFFFFFFFFFFFFFFF], :identique_u64)

# Floats
# TODO: make F32_ONE_THIRD work as well
affirm_aller_retour([0.0, 0.5, 0.25, 1.0], :identique_float)
affirm_aller_retour([0.0, 0.5, 0.25, 1.0, F32_ONE_THIRD], :identique_float)

# Doubles
affirm_aller_retour(
Expand Down

0 comments on commit 44b4c44

Please sign in to comment.