public function testRemoveObjectsWithPHPArrayOfKeys() { $dict = $this->dictionary; $keys = $dict->allKeys(); $keysToRemove = RTArray::arrayWithObjects($keys->firstObject(), $keys->lastObject()); $dict->removeObjectsForKeys($keysToRemove->phpArray()); $this->assertNull($dict->objectForKey($keysToRemove->firstObject())); $this->assertNull($dict->objectForKey($keysToRemove->lastObject())); }
public function testRemoveObjectsInArrayWithRTArray() { $mArray = RTMutableArray::anArray(); $mArray->addObjectsFromArray(array("42", 42, TRUE, FALSE)); $mArray->removeObjectsInArray(RTArray::arrayWithObjects("42", TRUE)); $this->assertEquals(2, $mArray->count()); $this->assertSame(42, $mArray->objectAtIndex(0)); $this->assertEquals(FALSE, $mArray->objectAtIndex(1)); }
public function testComponentsSeparatedByString() { $raw = RTArray::arrayWithObjects("this", "is", "a", "csv", "string"); $str = RTString::stringWithString($raw->componentsJoinedByString(",")); $components = $str->componentsSeparatedByString(","); $this->assertEquals(5, $components->count()); for ($i = 0; $i < $components->count(); $i++) { $this->assertEquals($raw->objectAtIndex($i), $components->objectAtIndex($i)); } }
public function testInitWithPHPArray() { $array = array("one" => "42", "two" => 42, "three" => YES, "four" => RTArray::arrayWithObjects("42", 42, YES, NO)); $dict = RTDictionary::alloc()->initWithPHPArray($array); $this->assertEquals(4, $dict->count()); $rtArray = RTArray::arrayWithObject($array); $dict = RTDictionary::alloc()->initWithPHPArray($rtArray); $this->assertEquals(1, $dict->count()); }
public function testDescription() { $array = RTArray::arrayWithObjects(RTArray::arrayWithObjects("one"), "two"); $this->assertEquals('[["one"],"two"]', $array->description()); }