8000 Merge pull request #1078 from remicollet/issue-1056 · jrtkcoder/phpredis@5fcd6dc · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fcd6dc

Browse files
Merge pull request phpredis#1078 from remicollet/issue-1056
Fix phpredis#1056 failed test on 32bits
2 parents 61a7e48 + 28be4a8 commit 5fcd6dc

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

tests/RedisTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ public function testBitsets() {
167167
// Verify valid offset ranges
168168
$this->assertFalse($this->redis->getBit('key', -1));
169169

170-
$this->redis->setBit('key', 4294967295, 1);
171-
$this->assertEquals(1, $this->redis->getBit('key', 4294967295));
170+
$this->redis->setBit('key', 0x7fffffff, 1);
171+
$this->assertEquals(1, $this->redis->getBit('key', 0x7fffffff));
172172
}
173173

174174
public function testBitPos() {
@@ -476,6 +476,9 @@ public function testSetNX() {
476476
}
477477

478478
public function testExpireAtWithLong() {
479+
if (PHP_INT_SIZE != 8) {
480+
$this->markTestSkipped('64 bits only');
481+
}
479482
$longExpiryTimeExceedingInt = 3153600000;
480483
$this->redis->del('key');
481484
$this->assertTrue($this->redis->setex('key', $longExpiryTimeExceedingInt, 'val') === TRUE);
@@ -515,7 +518,7 @@ public function testIncr()
515518
$this->assertTrue("abc" === $this->redis->get('key'));
516519

517520
$this->redis->set('key', 0);
518-
$this->assertEquals(2147483648, $this->redis->incrby('key', 2147483648));
521+
$this->assertEquals(PHP_INT_MAX, $this->redis->incrby('key', PHP_INT_MAX));
519522
}
520523

521524
public function testIncrByFloat()
@@ -550,7 +553,7 @@ public function testIncrByFloat()
550553
$this->redis->setOption(Redis::OPT_PREFIX, 'someprefix:');
551554
$this->redis->del('key');
552555
$this->redis->incrbyfloat('key',1.8);
553-
$this->assertEquals('1.8', $this->redis->get('key'));
556+
$this->assertEquals(1.8, floatval($this->redis->get('key'))); // convert to float to avoid rounding issue on arm
554557
$this->redis->setOption(Redis::OPT_PREFIX, '');
555558
$this->assertTrue($this->redis->exists('someprefix:key'));
556559
$this->redis->del('someprefix:key');
@@ -2296,8 +2299,8 @@ public function testHashes() {
22962299
$this->assertTrue(3 === $this->redis->hIncrBy('h', 'x', 1));
22972300
$this->assertTrue(2 === $this->redis->hIncrBy('h', 'x', -1));
22982301
$this->assertTrue("2" === $this->redis->hGet('h', 'x'));
2299-
$this->assertTrue(1000000000002 === $this->redis->hIncrBy('h', 'x', 1000000000000));
2300-
$this->assertTrue("1000000000002" === $this->redis->hGet('h', 'x'));
2302+
$this->assertTrue(PHP_INT_MAX === $this->redis->hIncrBy('h', 'x', PHP_INT_MAX-2));
2303+
$this->assertTrue("".PHP_INT_MAX === $this->redis->hGet('h', 'x'));
23012304

23022305
$this->redis->hSet('h', 'y', 'not-a-number');
23032306
$this->assertTrue(FALSE === $this->redis->hIncrBy('h', 'y', 1));

tests/TestRedis.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
/* Let the user know this can take a bit of time */
3636
echo "Note: these tests might take up to a minute. Don't worry :-)\n";
37-
echo "Using PHP version " . PHP_VERSION . "\n";
37+
echo "Using PHP version " . PHP_VERSION . " (" . (PHP_INT_SIZE*8) . " bits)\n";
3838

3939
/* Depending on the classes being tested, run our tests on it */
4040
echo "Testing class ";

0 commit comments

Comments
 (0)
0