summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-11-28 09:28:35 +0100
committerantirez <antirez@gmail.com>2015-11-28 09:28:37 +0100
commitfceaa46dda37a2d4db4e0a48cc1dab3fe208cb2c (patch)
treef4e43fc6f37abb97bdf6fde6dffd0fc1395a935b /tests
parent96628cc40df778716b70f4b661ceb1bd329591dd (diff)
downloadredis-fceaa46dda37a2d4db4e0a48cc1dab3fe208cb2c.tar.gz
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/type/hash.tcl21
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/unit/type/hash.tcl b/tests/unit/type/hash.tcl
index 1c0600879..02560ede2 100644
--- a/tests/unit/type/hash.tcl
+++ b/tests/unit/type/hash.tcl
@@ -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}}
+ }
}
}