Path splitting test.
所有检测均成功
The build was successful.

这个提交包含在:
Rafal Kupiec 2019-04-17 08:32:19 +02:00
父节点 395f6c446c
当前提交 ec580ddf8c
签署人:: belliash
GPG 密钥 ID: 4E829243E0CFE6B4
共有 2 个文件被更改,包括 64 次插入0 次删除

32
tests/path_split.aer 普通文件
查看文件

@ -0,0 +1,32 @@
class Program {
string[] parsePathComponents(string $path, bool $endSlash=true, bool $base=false) {
string[] $retArray;
$path = trim($path);
string $str, $temp;
char $char;
for(int $x = 0; $char = $path[$x]; $x++) {
if(!strstr('/', $char)) $temp += $char;
else if($temp) {
$str += $temp;
$retArray[$temp] = $str + ($endSlash ? '/' : '');
$str += '/';
$temp = '';
}
}
($base && $temp) ? $retArray[$temp] = $str + $temp : NULL;
return $retArray;
}
void main() {
string $path = '/my//stupid//path/to///some/file.php';
print_r($this->parsePathComponents($path));
$path = 'my/other//path/';
print_r($this->parsePathComponents($path, false));
$path = '/my//other/path/to///file.php';
print_r($this->parsePathComponents($path, true, true));
}
}

32
tests/path_split.exp 普通文件
查看文件

@ -0,0 +1,32 @@
Array(5) {
[my] =>
my/
[stupid] =>
my/stupid/
[path] =>
my/stupid/path/
[to] =>
my/stupid/path/to/
[some] =>
my/stupid/path/to/some/
}
Array(3) {
[my] =>
my
[other] =>
my/other
[path] =>
my/other/path
}
Array(5) {
[my] =>
my/
[other] =>
my/other/
[path] =>
my/other/path/
[to] =>
my/other/path/to/
[file.php] =>
my/other/path/to/file.php
}