mirror of
https://github.com/predis/predis.git
synced 2026-08-31 12:43:31 +00:00
[tests] Use round() to avoid issues with floats on certain plaforms.
See issue #220 on GitHub for reference.
This commit is contained in:
@@ -63,8 +63,10 @@ class HashIncrementByFloatTest extends PredisCommandTestCase
|
||||
$redis = $this->getClient();
|
||||
|
||||
$this->assertSame('10.5', $redis->hincrbyfloat('metavars', 'foo', 10.5));
|
||||
$this->assertSame('10.001', $redis->hincrbyfloat('metavars', 'hoge', 10.001));
|
||||
|
||||
$redis->hincrbyfloat('metavars', 'hoge', 10.001);
|
||||
$this->assertSame('11', $redis->hincrbyfloat('metavars', 'hoge', 0.999));
|
||||
|
||||
$this->assertSame(array('foo' => '10.5', 'hoge' => '11'), $redis->hgetall('metavars'));
|
||||
}
|
||||
|
||||
@@ -76,8 +78,10 @@ class HashIncrementByFloatTest extends PredisCommandTestCase
|
||||
$redis = $this->getClient();
|
||||
|
||||
$this->assertSame('-10.5', $redis->hincrbyfloat('metavars', 'foo', -10.5));
|
||||
$this->assertSame('-10.001', $redis->hincrbyfloat('metavars', 'hoge', -10.001));
|
||||
|
||||
$redis->hincrbyfloat('metavars', 'hoge', -10.001);
|
||||
$this->assertSame('-11', $redis->hincrbyfloat('metavars', 'hoge', -0.999));
|
||||
|
||||
$this->assertSame(array('foo' => '-10.5', 'hoge' => '-11'), $redis->hgetall('metavars'));
|
||||
}
|
||||
|
||||
|
||||
@@ -75,9 +75,11 @@ class StringIncrementByFloatTest extends PredisCommandTestCase
|
||||
|
||||
$redis->set('foo', 2);
|
||||
|
||||
// We use round() to avoid errors on some platforms, see the following
|
||||
// issue https://github.com/nrk/predis/issues/220 for reference.
|
||||
$this->assertEquals(22.123, $redis->incrbyfloat('foo', 20.123));
|
||||
$this->assertEquals(10, $redis->incrbyfloat('foo', -12.123));
|
||||
$this->assertEquals(-100.01, $redis->incrbyfloat('foo', -110.01));
|
||||
$this->assertEquals(10, round($redis->incrbyfloat('foo', -12.123), 5));
|
||||
$this->assertEquals(-100.01, round($redis->incrbyfloat('foo', -110.01), 5));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user