From 748543a787a4f51bf814405f669e36fbb3c2fc02 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 14 Mar 2010 10:09:59 +0100 Subject: [PATCH] Use assertSame instead of assertEquals because we need to be sure the type has not been altered. Signed-off-by: Florent Bruneau --- ut/arrayiteratortest.php | 104 +++++++++++++++++++++---------------------- ut/filtermapiteratortest.php | 22 ++++----- ut/heaptest.php | 88 ++++++++++++++++++------------------ ut/xdbtest.php | 18 ++++---- 4 files changed, 116 insertions(+), 116 deletions(-) diff --git a/ut/arrayiteratortest.php b/ut/arrayiteratortest.php index 06e0455..9622a9a 100644 --- a/ut/arrayiteratortest.php +++ b/ut/arrayiteratortest.php @@ -26,21 +26,21 @@ class ArrayIteratorTest extends PlTestCase public function testSimple() { $it = PlIteratorUtils::fromArray(array(1, 2, 3, 4)); - $this->assertEquals(4, $it->total()); + $this->assertSame(4, $it->total()); - $this->assertEquals(array('keys' => array(0), 'value' => 1), $it->next()); + $this->assertSame(array('keys' => array(0), 'value' => 1), $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('keys' => array(1), 'value' => 2), $it->next()); + $this->assertSame(array('keys' => array(1), 'value' => 2), $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('keys' => array(2), 'value' => 3), $it->next()); + $this->assertSame(array('keys' => array(2), 'value' => 3), $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('keys' => array(3), 'value' => 4), $it->next()); + $this->assertSame(array('keys' => array(3), 'value' => 4), $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); @@ -50,21 +50,21 @@ class ArrayIteratorTest extends PlTestCase public function testSimpleFlat() { $it = PlIteratorUtils::fromArray(array(1, 2, 3, 4), 1, true); - $this->assertEquals(4, $it->total()); + $this->assertSame(4, $it->total()); - $this->assertEquals(1, $it->next()); + $this->assertSame(1, $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(2, $it->next()); + $this->assertSame(2, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(3, $it->next()); + $this->assertSame(3, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(4, $it->next()); + $this->assertSame(4, $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); @@ -74,21 +74,21 @@ class ArrayIteratorTest extends PlTestCase public function testAssoc() { $it = PlIteratorUtils::fromArray(array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4)); - $this->assertEquals(4, $it->total()); + $this->assertSame(4, $it->total()); - $this->assertEquals(array('keys' => array('a'), 'value' => 1), $it->next()); + $this->assertSame(array('keys' => array('a'), 'value' => 1), $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('keys' => array('b'), 'value' => 2), $it->next()); + $this->assertSame(array('keys' => array('b'), 'value' => 2), $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('keys' => array('c'), 'value' => 3), $it->next()); + $this->assertSame(array('keys' => array('c'), 'value' => 3), $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('keys' => array('d'), 'value' => 4), $it->next()); + $this->assertSame(array('keys' => array('d'), 'value' => 4), $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); @@ -98,21 +98,21 @@ class ArrayIteratorTest extends PlTestCase public function testAssocFlat() { $it = PlIteratorUtils::fromArray(array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4), 1, true); - $this->assertEquals(4, $it->total()); + $this->assertSame(4, $it->total()); - $this->assertEquals(1, $it->next()); + $this->assertSame(1, $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(2, $it->next()); + $this->assertSame(2, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(3, $it->next()); + $this->assertSame(3, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(4, $it->next()); + $this->assertSame(4, $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); @@ -122,13 +122,13 @@ class ArrayIteratorTest extends PlTestCase public function testDepth() { $it = PlIteratorUtils::fromArray(array(array(1, 2), array(3, 4)), 1); - $this->assertEquals(2, $it->total()); + $this->assertSame(2, $it->total()); - $this->assertEquals(array('keys' => array(0), 'value' => array(1, 2)), $it->next()); + $this->assertSame(array('keys' => array(0), 'value' => array(1, 2)), $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('keys' => array(1), 'value' => array(3, 4)), $it->next()); + $this->assertSame(array('keys' => array(1), 'value' => array(3, 4)), $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); @@ -136,21 +136,21 @@ class ArrayIteratorTest extends PlTestCase $it = PlIteratorUtils::fromArray(array(array(1, 2), array(3, 4)), 2); - $this->assertEquals(4, $it->total()); + $this->assertSame(4, $it->total()); - $this->assertEquals(array('keys' => array(0, 0), 'value' => 1), $it->next()); + $this->assertSame(array('keys' => array(0, 0), 'value' => 1), $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('keys' => array(0, 1), 'value' => 2), $it->next()); + $this->assertSame(array('keys' => array(0, 1), 'value' => 2), $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('keys' => array(1, 0), 'value' => 3), $it->next()); + $this->assertSame(array('keys' => array(1, 0), 'value' => 3), $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('keys' => array(1, 1), 'value' => 4), $it->next()); + $this->assertSame(array('keys' => array(1, 1), 'value' => 4), $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); @@ -160,13 +160,13 @@ class ArrayIteratorTest extends PlTestCase public function testDepthFlat() { $it = PlIteratorUtils::fromArray(array(array(1, 2), array(3, 4)), 1, true); - $this->assertEquals(2, $it->total()); + $this->assertSame(2, $it->total()); - $this->assertEquals(array(1, 2), $it->next()); + $this->assertSame(array(1, 2), $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array(3, 4), $it->next()); + $this->assertSame(array(3, 4), $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); @@ -174,21 +174,21 @@ class ArrayIteratorTest extends PlTestCase $it = PlIteratorUtils::fromArray(array(array(1, 2), array(3, 4)), 2, true); - $this->assertEquals(4, $it->total()); + $this->assertSame(4, $it->total()); - $this->assertEquals(1, $it->next()); + $this->assertSame(1, $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(2, $it->next()); + $this->assertSame(2, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(3, $it->next()); + $this->assertSame(3, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(4, $it->next()); + $this->assertSame(4, $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); @@ -198,13 +198,13 @@ class ArrayIteratorTest extends PlTestCase public function testDepthAssoc() { $it = PlIteratorUtils::fromArray(array('a' => array('b' => 1, 'c' => 2), 'd' => array('e' => 3, 'f' => 4)), 1); - $this->assertEquals(2, $it->total()); + $this->assertSame(2, $it->total()); - $this->assertEquals(array('keys' => array('a'), 'value' => array('b' => 1, 'c' => 2)), $it->next()); + $this->assertSame(array('keys' => array('a'), 'value' => array('b' => 1, 'c' => 2)), $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('keys' => array('d'), 'value' => array('e' => 3, 'f' => 4)), $it->next()); + $this->assertSame(array('keys' => array('d'), 'value' => array('e' => 3, 'f' => 4)), $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); @@ -212,21 +212,21 @@ class ArrayIteratorTest extends PlTestCase $it = PlIteratorUtils::fromArray(array('a' => array('b' => 1, 'c' => 2), 'd' => array('e' => 3, 'f' => 4)), 2); - $this->assertEquals(4, $it->total()); + $this->assertSame(4, $it->total()); - $this->assertEquals(array('keys' => array('a', 'b'), 'value' => 1), $it->next()); + $this->assertSame(array('keys' => array('a', 'b'), 'value' => 1), $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('keys' => array('a', 'c'), 'value' => 2), $it->next()); + $this->assertSame(array('keys' => array('a', 'c'), 'value' => 2), $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('keys' => array('d', 'e'), 'value' => 3), $it->next()); + $this->assertSame(array('keys' => array('d', 'e'), 'value' => 3), $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('keys' => array('d', 'f'), 'value' => 4), $it->next()); + $this->assertSame(array('keys' => array('d', 'f'), 'value' => 4), $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); @@ -236,13 +236,13 @@ class ArrayIteratorTest extends PlTestCase public function testDepthAssocFlat() { $it = PlIteratorUtils::fromArray(array('a' => array('b' => 1, 'c' => 2), 'd' => array('e' => 3, 'f' => 4)), 1, true); - $this->assertEquals(2, $it->total()); + $this->assertSame(2, $it->total()); - $this->assertEquals(array('b' => 1, 'c' => 2), $it->next()); + $this->assertSame(array('b' => 1, 'c' => 2), $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(array('e' => 3, 'f' => 4), $it->next()); + $this->assertSame(array('e' => 3, 'f' => 4), $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); @@ -250,21 +250,21 @@ class ArrayIteratorTest extends PlTestCase $it = PlIteratorUtils::fromArray(array('a' => array('b' => 1, 'c' => 2), 'd' => array('e' => 3, 'f' => 4)), 2, true); - $this->assertEquals(4, $it->total()); + $this->assertSame(4, $it->total()); - $this->assertEquals(1, $it->next()); + $this->assertSame(1, $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(2, $it->next()); + $this->assertSame(2, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(3, $it->next()); + $this->assertSame(3, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(4, $it->next()); + $this->assertSame(4, $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); diff --git a/ut/filtermapiteratortest.php b/ut/filtermapiteratortest.php index 4d320df..c016527 100644 --- a/ut/filtermapiteratortest.php +++ b/ut/filtermapiteratortest.php @@ -35,19 +35,19 @@ class FilterMapIteratorTest extends PlTestCase $this->assertLessThanOrEqual(8, $it->total()); $this->assertGreaterThanOrEqual(4, $it->total()); - $this->assertEquals(10, $it->next()); + $this->assertSame(10, $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(9, $it->next()); + $this->assertSame(9, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(42, $it->next()); + $this->assertSame(42, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(9, $it->next()); + $this->assertSame(9, $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); @@ -63,29 +63,29 @@ class FilterMapIteratorTest extends PlTestCase { $it = PlIteratorUtils::fromArray(array(1, 2, 3, 4, 7, 512), 1, true); $it = PlIteratorUtils::map($it, array('FilterMapIteratorTest', 'map')); - $this->assertEquals(6, $it->total()); + $this->assertSame(6, $it->total()); - $this->assertEquals(2, $it->next()); + $this->assertSame(2, $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(4, $it->next()); + $this->assertSame(4, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(6, $it->next()); + $this->assertSame(6, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(8, $it->next()); + $this->assertSame(8, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(14, $it->next()); + $this->assertSame(14, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(1024, $it->next()); + $this->assertSame(1024, $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); diff --git a/ut/heaptest.php b/ut/heaptest.php index 5f37ce6..cae76dd 100644 --- a/ut/heaptest.php +++ b/ut/heaptest.php @@ -31,32 +31,32 @@ class HeapTest extends PlTestCase public function testHeap() { $heap = new PlHeap(array('HeapTest', 'compare')); - $this->assertEquals(0, $heap->count()); + $this->assertSame(0, $heap->count()); $this->assertNull($heap->pop()); $heap->push(1); - $this->assertEquals(1, $heap->count()); - $this->assertEquals(1, $heap->pop()); - $this->assertEquals(0, $heap->count()); + $this->assertSame(1, $heap->count()); + $this->assertSame(1, $heap->pop()); + $this->assertSame(0, $heap->count()); $this->assertNull($heap->pop()); $heap->push(2); $heap->push(1); $heap->push(4); $heap->push(3); - $this->assertEquals(4, $heap->count()); - $this->assertEquals(1, $heap->pop()); - $this->assertEquals(3, $heap->count()); - $this->assertEquals(2, $heap->pop()); - $this->assertEquals(2, $heap->count()); + $this->assertSame(4, $heap->count()); + $this->assertSame(1, $heap->pop()); + $this->assertSame(3, $heap->count()); + $this->assertSame(2, $heap->pop()); + $this->assertSame(2, $heap->count()); $heap->push(-1); - $this->assertEquals(3, $heap->count()); - $this->assertEquals(-1, $heap->pop()); - $this->assertEquals(2, $heap->count()); - $this->assertEquals(3, $heap->pop()); - $this->assertEquals(1, $heap->count()); - $this->assertEquals(4, $heap->pop()); - $this->assertEquals(0, $heap->count()); + $this->assertSame(3, $heap->count()); + $this->assertSame(-1, $heap->pop()); + $this->assertSame(2, $heap->count()); + $this->assertSame(3, $heap->pop()); + $this->assertSame(1, $heap->count()); + $this->assertSame(4, $heap->pop()); + $this->assertSame(0, $heap->count()); $this->assertNull($heap->pop()); } @@ -69,26 +69,26 @@ class HeapTest extends PlTestCase $heap->push(3); $it = $heap->iterator(); - $this->assertEquals(4, $it->total()); + $this->assertSame(4, $it->total()); - $this->assertEquals(1, $it->next()); + $this->assertSame(1, $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(2, $it->next()); + $this->assertSame(2, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(3, $it->next()); + $this->assertSame(3, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(4, $it->next()); + $this->assertSame(4, $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); $this->assertNull($it->next()); - $this->assertEquals(4, $heap->count()); + $this->assertSame(4, $heap->count()); } public function testMergeSortedIterator() @@ -98,45 +98,45 @@ class HeapTest extends PlTestCase $its[] = PlIteratorUtils::fromArray(array(3, 9, 27), 1, true); $its[] = PlIteratorUtils::fromArray(array(4, 16, 32), 1, true); $it = PlIteratorUtils::merge($its, array('HeapTest', 'compare')); - $this->assertEquals(10, $it->total()); + $this->assertSame(10, $it->total()); - $this->assertEquals(2, $it->next()); + $this->assertSame(2, $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(3, $it->next()); + $this->assertSame(3, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(4, $it->next()); + $this->assertSame(4, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(4, $it->next()); + $this->assertSame(4, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(8, $it->next()); + $this->assertSame(8, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(9, $it->next()); + $this->assertSame(9, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(16, $it->next()); + $this->assertSame(16, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(16, $it->next()); + $this->assertSame(16, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(27, $it->next()); + $this->assertSame(27, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(32, $it->next()); + $this->assertSame(32, $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); @@ -150,45 +150,45 @@ class HeapTest extends PlTestCase $its[] = PlIteratorUtils::fromArray(array(3, 27, 9), 1, true); $its[] = PlIteratorUtils::fromArray(array(32, 4, 16), 1, true); $it = PlIteratorUtils::merge($its, array('HeapTest', 'compare'), false); - $this->assertEquals(10, $it->total()); + $this->assertSame(10, $it->total()); - $this->assertEquals(2, $it->next()); + $this->assertSame(2, $it->next()); $this->assertTrue($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(3, $it->next()); + $this->assertSame(3, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(4, $it->next()); + $this->assertSame(4, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(4, $it->next()); + $this->assertSame(4, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(8, $it->next()); + $this->assertSame(8, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(9, $it->next()); + $this->assertSame(9, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(16, $it->next()); + $this->assertSame(16, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(16, $it->next()); + $this->assertSame(16, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(27, $it->next()); + $this->assertSame(27, $it->next()); $this->assertFalse($it->first()); $this->assertFalse($it->last()); - $this->assertEquals(32, $it->next()); + $this->assertSame(32, $it->next()); $this->assertFalse($it->first()); $this->assertTrue($it->last()); diff --git a/ut/xdbtest.php b/ut/xdbtest.php index 72b1686..585b8f8 100644 --- a/ut/xdbtest.php +++ b/ut/xdbtest.php @@ -25,31 +25,31 @@ class XDBTest extends PlTestCase { public function testEscapeString() { - $this->assertEquals("'blah'", XDB::format('{?}', 'blah')); - $this->assertEquals("'blah\\''", XDB::format('{?}', "blah'")); - $this->assertEquals("'bl\\'ah'", XDB::format('{?}', "bl'ah")); - $this->assertEquals("'\\'blah\\''", XDB::format('{?}', "'blah'")); + $this->assertSame("'blah'", XDB::format('{?}', 'blah')); + $this->assertSame("'blah\\''", XDB::format('{?}', "blah'")); + $this->assertSame("'bl\\'ah'", XDB::format('{?}', "bl'ah")); + $this->assertSame("'\\'blah\\''", XDB::format('{?}', "'blah'")); } public function testEscapeInt() { - $this->assertEquals("1", XDB::format('{?}', 1)); + $this->assertSame("1", XDB::format('{?}', 1)); } public function testEscapeFlagSet() { $flagset = new PlFlagSet(); $flagset->addFlag('toto'); - $this->assertEquals("'toto'", XDB::format('{?}', $flagset)); + $this->assertSame("'toto'", XDB::format('{?}', $flagset)); $flagset->addFlag('titi'); - $this->assertEquals("'toto,titi'", XDB::format('{?}', $flagset)); + $this->assertSame("'toto,titi'", XDB::format('{?}', $flagset)); $flagset->addFlag('titi'); - $this->assertEquals("'toto,titi'", XDB::format('{?}', $flagset)); + $this->assertSame("'toto,titi'", XDB::format('{?}', $flagset)); } public function testEscapeArray() { - $this->assertEquals("(1, 'toto')", XDB::format('{?}', array(1, 'toto'))); + $this->assertSame("(1, 'toto')", XDB::format('{?}', array(1, 'toto'))); } } -- 2.1.4