From f4cfc0ae19bf27d8fb84a9dba74a2e8f05e268e2 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 22 Dec 2016 11:00:59 +0100 Subject: [PATCH 1/3] Fix #1056 failed test on 32bits --- tests/RedisTest.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/RedisTest.php b/tests/RedisTest.php index 8c99b04677..c79ab88f57 100644 --- a/tests/RedisTest.php +++ b/tests/RedisTest.php @@ -167,8 +167,8 @@ public function testBitsets() { // Verify valid offset ranges $this->assertFalse($this->redis->getBit('key', -1)); - $this->redis->setBit('key', 4294967295, 1); - $this->assertEquals(1, $this->redis->getBit('key', 4294967295)); + $this->redis->setBit('key', 0x7fffffff, 1); + $this->assertEquals(1, $this->redis->getBit('key', 0x7fffffff)); } public function testBitPos() { @@ -476,6 +476,9 @@ public function testSetNX() { } public function testExpireAtWithLong() { + if (PHP_INT_SIZE != 8) { + $this->markTestSkipped('64 bits only'); + } $longExpiryTimeExceedingInt = 3153600000; $this->redis->del('key'); $this->assertTrue($this->redis->setex('key', $longExpiryTimeExceedingInt, 'val') === TRUE); @@ -515,7 +518,7 @@ public function testIncr() $this->assertTrue("abc" === $this->redis->get('key')); $this->redis->set('key', 0); - $this->assertEquals(2147483648, $this->redis->incrby('key', 2147483648)); + $this->assertEquals(PHP_INT_MAX, $this->redis->incrby('key', PHP_INT_MAX)); } public function testIncrByFloat() @@ -2296,8 +2299,8 @@ public function testHashes() { $this->assertTrue(3 === $this->redis->hIncrBy('h', 'x', 1)); $this->assertTrue(2 === $this->redis->hIncrBy('h', 'x', -1)); $this->assertTrue("2" === $this->redis->hGet('h', 'x')); - $this->assertTrue(1000000000002 === $this->redis->hIncrBy('h', 'x', 1000000000000)); - $this->assertTrue("1000000000002" === $this->redis->hGet('h', 'x')); + $this->assertTrue(PHP_INT_MAX === $this->redis->hIncrBy('h', 'x', PHP_INT_MAX-2)); + $this->assertTrue("".PHP_INT_MAX === $this->redis->hGet('h', 'x')); $this->redis->hSet('h', 'y', 'not-a-number'); $this->assertTrue(FALSE === $this->redis->hIncrBy('h', 'y', 1)); From 52dbe95c293806c63c375bdc4057e440e17ca4e2 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 22 Dec 2016 11:54:54 +0100 Subject: [PATCH 2/3] fix rounding issue on arm --- tests/RedisTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/RedisTest.php b/tests/RedisTest.php index c79ab88f57..e0867cfca9 100644 --- a/tests/RedisTest.php +++ b/tests/RedisTest.php @@ -553,7 +553,7 @@ public function testIncrByFloat() $this->redis->setOption(Redis::OPT_PREFIX, 'someprefix:'); $this->redis->del('key'); $this->redis->incrbyfloat('key',1.8); - $this->assertEquals('1.8', $this->redis->get('key')); + $this->assertEquals(1.8, floatval($this->redis->get('key'))); // convert to float to avoid rounding issue on arm $this->redis->setOption(Redis::OPT_PREFIX, ''); $this->assertTrue($this->redis->exists('someprefix:key')); $this->redis->del('someprefix:key'); From 28be4a8d28cec56b1d2347ca8a9630a056bdfdbd Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 22 Dec 2016 11:55:21 +0100 Subject: [PATCH 3/3] display integer size in test suite output --- tests/TestRedis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/TestRedis.php b/tests/TestRedis.php index 794ea8843c..7f73d258ec 100644 --- a/tests/TestRedis.php +++ b/tests/TestRedis.php @@ -34,7 +34,7 @@ /* Let the user know this can take a bit of time */ echo "Note: these tests might take up to a minute. Don't worry :-)\n"; -echo "Using PHP version " . PHP_VERSION . "\n"; +echo "Using PHP version " . PHP_VERSION . " (" . (PHP_INT_SIZE*8) . " bits)\n"; /* Depending on the classes being tested, run our tests on it */ echo "Testing class ";