20250516
* [Dictionary] Добавлен метод Keys (): array, который возвращает все ключи словаря. * [Dictionary] Добавлен метод Sort (bool $descending = false): void, который сортирует внутренние данные по ключам (в обратном порядке, если выбран $descending = true).
This commit is contained in:
		| @@ -99,4 +99,34 @@ class DictionaryTest extends TestCase | ||||
|         $this->assertTrue($dict->Has('3')); | ||||
|         $this->assertFalse($dict->Has('4')); | ||||
|     } | ||||
|  | ||||
|     public function testKeys () | ||||
|     { | ||||
|         $this->PrepareForTest(); | ||||
|  | ||||
|         $dict = new Dictionary(); | ||||
|         $dict->Add('1', 1); | ||||
|         $dict->Add('3', true); | ||||
|         $dict->Add('2', '2'); | ||||
|  | ||||
|         $array = ['1', '3', '2']; | ||||
|  | ||||
|         $this->assertArrayIsEqualToArrayIgnoringListOfKeys($array, $dict->Keys(), []); | ||||
|     } | ||||
|  | ||||
|     public function testSort () | ||||
|     { | ||||
|         $this->PrepareForTest(); | ||||
|  | ||||
|         $dict = new Dictionary(); | ||||
|         $dict->Add('1', 1); | ||||
|         $dict->Add('3', true); | ||||
|         $dict->Add('2', '2'); | ||||
|  | ||||
|         $array = ['1', '2', '3']; | ||||
|  | ||||
|         $dict->Sort(); | ||||
|  | ||||
|         $this->assertArrayIsEqualToArrayIgnoringListOfKeys($array, $dict->Keys(), []); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user