diff --git a/tests/support/util.tcl b/tests/support/util.tcl index a39a2134..675d57f7 100644 --- a/tests/support/util.tcl +++ b/tests/support/util.tcl @@ -294,3 +294,7 @@ proc csvdump r { proc csvstring s { return "\"$s\"" } + +proc roundFloat f { + format "%.10g" $f +} diff --git a/tests/unit/basic.tcl b/tests/unit/basic.tcl index fec782ef..4210f48b 100644 --- a/tests/unit/basic.tcl +++ b/tests/unit/basic.tcl @@ -152,13 +152,15 @@ start_server {tags {"basic"}} { test {INCRBYFLOAT against non existing key} { r del novar - list [r incrbyfloat novar 1] [r get novar] [r incrbyfloat novar 0.25] \ - [r get novar] + list [roundFloat [r incrbyfloat novar 1]] \ + [roundFloat [r get novar]] \ + [roundFloat [r incrbyfloat novar 0.25]] \ + [roundFloat [r get novar]] } {1 1 1.25 1.25} test {INCRBYFLOAT against key originally set with SET} { r set novar 1.5 - r incrbyfloat novar 1.5 + roundFloat [r incrbyfloat novar 1.5] } {3} test {INCRBYFLOAT over 32bit value} { @@ -213,7 +215,7 @@ start_server {tags {"basic"}} { test {INCRBYFLOAT decrement} { r set foo 1 - r incrbyfloat foo -1.1 + roundFloat [r incrbyfloat foo -1.1] } {-0.1} test "SETNX target key missing" { diff --git a/tests/unit/type/hash.tcl b/tests/unit/type/hash.tcl index 2b2a684e..04a5f4c7 100644 --- a/tests/unit/type/hash.tcl +++ b/tests/unit/type/hash.tcl @@ -327,30 +327,32 @@ start_server {tags {"hash"}} { set rv {} r hdel smallhash tmp r hdel bighash tmp - lappend rv [r hincrbyfloat smallhash tmp 2.5] - lappend rv [r hget smallhash tmp] - lappend rv [r hincrbyfloat bighash tmp 2.5] - lappend rv [r hget bighash tmp] + lappend rv [roundFloat [r hincrbyfloat smallhash tmp 2.5]] + lappend rv [roundFloat [r hget smallhash tmp]] + lappend rv [roundFloat [r hincrbyfloat bighash tmp 2.5]] + lappend rv [roundFloat [r hget bighash tmp]] } {2.5 2.5 2.5 2.5} test {HINCRBYFLOAT against hash key created by hincrby itself} { set rv {} - lappend rv [r hincrbyfloat smallhash tmp 3.5] - lappend rv [r hget smallhash tmp] - lappend rv [r hincrbyfloat bighash tmp 3.5] - lappend rv [r hget bighash tmp] + lappend rv [roundFloat [r hincrbyfloat smallhash tmp 3.5]] + lappend rv [roundFloat [r hget smallhash tmp]] + lappend rv [roundFloat [r hincrbyfloat bighash tmp 3.5]] + lappend rv [roundFloat [r hget bighash tmp]] } {6 6 6 6} test {HINCRBYFLOAT against hash key originally set with HSET} { r hset smallhash tmp 100 r hset bighash tmp 100 - list [r hincrbyfloat smallhash tmp 2.5] [r hincrbyfloat bighash tmp 2.5] + list [roundFloat [r hincrbyfloat smallhash tmp 2.5]] \ + [roundFloat [r hincrbyfloat bighash tmp 2.5]] } {102.5 102.5} test {HINCRBYFLOAT over 32bit value} { r hset smallhash tmp 17179869184 r hset bighash tmp 17179869184 - list [r hincrbyfloat smallhash tmp 1] [r hincrbyfloat bighash tmp 1] + list [r hincrbyfloat smallhash tmp 1] \ + [r hincrbyfloat bighash tmp 1] } {17179869185 17179869185} test {HINCRBYFLOAT over 32bit value with over 32bit increment} {