1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
<?php
declare(strict_types=1);
use Nette\Utils\FileSystem;
use Tester\Assert;
require __DIR__ . '/../bootstrap.php';
test('', function () {
$S = DIRECTORY_SEPARATOR;
Assert::same('', FileSystem::normalizePath(''));
Assert::same($S, FileSystem::normalizePath('\\'));
Assert::same($S, FileSystem::normalizePath('/'));
Assert::same('file', FileSystem::normalizePath('file'));
Assert::same("file{$S}", FileSystem::normalizePath('file/'));
Assert::same("d:{$S}file", FileSystem::normalizePath('d:/file'));
Assert::same("d:{$S}file", FileSystem::normalizePath('d:\file'));
Assert::same("{$S}file", FileSystem::normalizePath('/file'));
Assert::same('', FileSystem::normalizePath('.'));
Assert::same($S, FileSystem::normalizePath('\.'));
Assert::same($S, FileSystem::normalizePath('/.'));
Assert::same($S, FileSystem::normalizePath('.\\'));
Assert::same($S, FileSystem::normalizePath('./'));
Assert::same($S, FileSystem::normalizePath('/file/..'));
Assert::same($S, FileSystem::normalizePath('/file/../'));
Assert::same('', FileSystem::normalizePath('file/..'));
Assert::same($S, FileSystem::normalizePath('file/../'));
Assert::same("{$S}..", FileSystem::normalizePath('/file/../..'));
Assert::same("{$S}..{$S}", FileSystem::normalizePath('/file/../../'));
Assert::same('..', FileSystem::normalizePath('file/../..'));
Assert::same("..{$S}", FileSystem::normalizePath('file/../../'));
Assert::same("{$S}..{$S}bar", FileSystem::normalizePath('/file/../../bar'));
Assert::same("..{$S}bar", FileSystem::normalizePath('file/../../bar'));
Assert::same("..{$S}file", FileSystem::normalizePath('../file'));
Assert::same("{$S}..{$S}file", FileSystem::normalizePath('/../file'));
Assert::same('file', FileSystem::normalizePath('./file'));
Assert::same("{$S}file", FileSystem::normalizePath('/./file'));
Assert::same("{$S}..{$S}bar", FileSystem::normalizePath('/file/./.././.././bar'));
Assert::same("..{$S}bar", FileSystem::normalizePath('file/../../bar/.'));
Assert::same("{$S}..{$S}bar{$S}", FileSystem::normalizePath('/file/./.././.././bar/'));
Assert::same("..{$S}bar{$S}", FileSystem::normalizePath('file/../../bar/./'));
Assert::same($S, FileSystem::normalizePath('//'));
Assert::same("{$S}foo{$S}", FileSystem::normalizePath('//foo//'));
Assert::same("{$S}", FileSystem::normalizePath('//foo//..//'));
});
|