Changeset View
Changeset View
Standalone View
Standalone View
src/utils/__tests__/PhutilUtilsTestCase.php
| Show First 20 Lines • Show All 960 Lines • ▼ Show 20 Lines | public function testNaturalList() { | ||||
| ); | ); | ||||
| foreach ($cases as $case) { | foreach ($cases as $case) { | ||||
| list($expect, $value) = $case; | list($expect, $value) = $case; | ||||
| $this->assertEqual($expect, phutil_is_natural_list($value)); | $this->assertEqual($expect, phutil_is_natural_list($value)); | ||||
| } | } | ||||
| } | } | ||||
| public function testArrayPartition() { | |||||
| $map = array( | |||||
| 'empty' => array( | |||||
| array(), | |||||
| array(), | |||||
| ), | |||||
| 'unique' => array( | |||||
| array('a' => 'a', 'b' => 'b', 'c' => 'c'), | |||||
| array(array('a' => 'a'), array('b' => 'b'), array('c' => 'c')), | |||||
| ), | |||||
| 'xy' => array( | |||||
| array('a' => 'x', 'b' => 'x', 'c' => 'y', 'd' => 'y'), | |||||
| array( | |||||
| array('a' => 'x', 'b' => 'x'), | |||||
| array('c' => 'y', 'd' => 'y'), | |||||
| ), | |||||
| ), | |||||
| 'multi' => array( | |||||
| array('a' => true, 'b' => true, 'c' => false, 'd' => true), | |||||
| array( | |||||
| array('a' => true, 'b' => true), | |||||
| array('c' => false), | |||||
| array('d' => true), | |||||
| ), | |||||
| ), | |||||
| ); | |||||
| foreach ($map as $name => $item) { | |||||
| list($input, $expect) = $item; | |||||
| $actual = phutil_partition($input); | |||||
| $this->assertEqual($expect, $actual, pht('Partition of "%s"', $name)); | |||||
| } | |||||
| } | |||||
| } | } | ||||