Test HINCRBYFLOAT rounding only in x86_64 and when valgrind is not in use.

64 bit double math is not enough to make the test passing, and rounding
to 1.2999999 instead of 1.23 is not an error in the implementation.
Valgrind and sometimes other archs are not able to work with 80 bit
doubles.
This commit is contained in:
antirez 2015-11-28 09:28:35 +01:00
parent 96628cc40d
commit fceaa46dda

View File

@ -516,10 +516,21 @@ start_server {tags {"hash"}} {
}
}
test {Test HINCRBYFLOAT for correct float representation (issue #2846)} {
r del myhash
assert {[r hincrbyfloat myhash float 1.23] eq {1.23}}
assert {[r hincrbyfloat myhash float 0.77] eq {2}}
assert {[r hincrbyfloat myhash float -0.1] eq {1.9}}
# The following test can only be executed if we don't use Valgrind, and if
# we are using x86_64 architecture, because:
#
# 1) Valgrind has floating point limitations, no support for 80 bits math.
# 2) Other archs may have the same limits.
#
# 1.23 cannot be represented correctly with 64 bit doubles, so we skip
# the test, since we are only testing pretty printing here and is not
# a bug if the program outputs things like 1.299999...
if {!$::valgrind || ![string match *x86_64* [exec uname -a]]} {
test {Test HINCRBYFLOAT for correct float representation (issue #2846)} {
r del myhash
assert {[r hincrbyfloat myhash float 1.23] eq {1.23}}
assert {[r hincrbyfloat myhash float 0.77] eq {2}}
assert {[r hincrbyfloat myhash float -0.1] eq {1.9}}
}
}
}