From 0c8fbd82baf9a506f852afc919c4f8cf6a21cb6d Mon Sep 17 00:00:00 2001 From: "(Holloway) Chew, Kean Ho" Date: Wed, 25 Dec 2024 15:14:06 +0800 Subject: [PATCH] Shell: upgraded test libraries into HestiaKERNEL Since the test framework is reusable, it's best to upgrade the existing ones into HestiaKERNEL library instead. Hence, let's do this. This patch upgrades test libraries into HestiaKERNEL in Shell/ directory. Co-authored-by: Shuralyov, Jean Co-authored-by: Galyna, Cory Co-authored-by: (Holloway) Chew, Kean Ho Signed-off-by: (Holloway) Chew, Kean Ho --- Shell/libraries/HestiaKERNEL/FS/Get_Files.ps1 | 61 +++++++++ Shell/libraries/HestiaKERNEL/FS/Get_Files.sh | 61 +++++++++ .../HestiaKERNEL/FS/Is_Directory.ps1 | 36 ++++++ .../libraries/HestiaKERNEL/FS/Is_Directory.sh | 38 ++++++ Shell/libraries/HestiaKERNEL/FS/Is_File.ps1 | 36 ++++++ Shell/libraries/HestiaKERNEL/FS/Is_File.sh | 38 ++++++ .../HestiaKERNEL/Number/Is_Number.sh | 2 +- Shell/libraries/HestiaKERNEL/Test/Codes.ps1 | 17 +++ Shell/libraries/HestiaKERNEL/Test/Codes.sh | 18 +++ .../HestiaKERNEL/Test/Exec_Test_Case.ps1 | 55 ++++++++ .../HestiaKERNEL/Test/Exec_Test_Case.sh | 49 +++++++ .../Unicode/To_Unicode_From_String.sh | 34 +++-- Shell/libraries/HestiaKERNEL/Vanilla.sh.ps1 | 10 ++ Shell/shell/init.ps1 | 45 ++----- Shell/shell/init.sh | 59 ++------- Shell/shell/test.ps1 | 47 +++---- Shell/shell/test.sh | 44 +++---- Shell/tests/FS/Get_Files/0.ps1 | 69 ++++++++++ Shell/tests/FS/Get_Files/0.sh | 72 +++++++++++ Shell/tests/FS/Get_Files/1.ps1 | 71 ++++++++++ Shell/tests/FS/Get_Files/1.sh | 74 +++++++++++ Shell/tests/FS/Get_Files/2.ps1 | 73 +++++++++++ Shell/tests/FS/Get_Files/2.sh | 76 +++++++++++ Shell/tests/FS/Get_Files/3.ps1 | 73 +++++++++++ Shell/tests/FS/Get_Files/3.sh | 76 +++++++++++ Shell/tests/FS/Get_Files/4.ps1 | 69 ++++++++++ Shell/tests/FS/Get_Files/4.sh | 72 +++++++++++ Shell/tests/FS/Get_Files/5.ps1 | 69 ++++++++++ Shell/tests/FS/Get_Files/5.sh | 72 +++++++++++ Shell/tests/FS/Get_Files/6.ps1 | 73 +++++++++++ Shell/tests/FS/Get_Files/6.sh | 76 +++++++++++ Shell/tests/FS/Get_Files/7.ps1 | 73 +++++++++++ Shell/tests/FS/Get_Files/7.sh | 76 +++++++++++ Shell/tests/FS/Get_Files/8.ps1 | 73 +++++++++++ Shell/tests/FS/Get_Files/8.sh | 76 +++++++++++ Shell/tests/FS/Is_Directory/0.ps1 | 69 ++++++++++ Shell/tests/FS/Is_Directory/0.sh | 70 ++++++++++ Shell/tests/FS/Is_Directory/1.ps1 | 69 ++++++++++ Shell/tests/FS/Is_Directory/1.sh | 72 +++++++++++ Shell/tests/FS/Is_Directory/2.ps1 | 69 ++++++++++ Shell/tests/FS/Is_Directory/2.sh | 72 +++++++++++ Shell/tests/FS/Is_Directory/3.ps1 | 69 ++++++++++ Shell/tests/FS/Is_Directory/3.sh | 72 +++++++++++ Shell/tests/FS/Is_File/0.ps1 | 69 ++++++++++ Shell/tests/FS/Is_File/0.sh | 72 +++++++++++ Shell/tests/FS/Is_File/1.ps1 | 69 ++++++++++ Shell/tests/FS/Is_File/1.sh | 70 ++++++++++ Shell/tests/FS/Is_File/2.ps1 | 69 ++++++++++ Shell/tests/FS/Is_File/2.sh | 70 ++++++++++ Shell/tests/FS/Is_File/3.ps1 | 69 ++++++++++ Shell/tests/FS/Is_File/3.sh | 70 ++++++++++ Shell/tests/String/Split_Left_String/0.ps1 | 15 +-- Shell/tests/String/Split_Left_String/0.sh | 42 +++--- Shell/tests/String/Split_Left_String/1.ps1 | 15 +-- Shell/tests/String/Split_Left_String/1.sh | 42 +++--- Shell/tests/String/Split_Left_String/2.ps1 | 15 +-- Shell/tests/String/Split_Left_String/2.sh | 42 +++--- Shell/tests/String/Split_Left_String/3.ps1 | 15 +-- Shell/tests/String/Split_Left_String/3.sh | 42 +++--- Shell/tests/String/Split_Left_String/4.ps1 | 121 ++++++++++++++++++ Shell/tests/String/Split_Left_String/4.sh | 83 ++++++++++++ 61 files changed, 3252 insertions(+), 263 deletions(-) create mode 100644 Shell/libraries/HestiaKERNEL/FS/Get_Files.ps1 create mode 100644 Shell/libraries/HestiaKERNEL/FS/Get_Files.sh create mode 100644 Shell/libraries/HestiaKERNEL/FS/Is_Directory.ps1 create mode 100644 Shell/libraries/HestiaKERNEL/FS/Is_Directory.sh create mode 100644 Shell/libraries/HestiaKERNEL/FS/Is_File.ps1 create mode 100644 Shell/libraries/HestiaKERNEL/FS/Is_File.sh create mode 100755 Shell/libraries/HestiaKERNEL/Test/Codes.ps1 create mode 100755 Shell/libraries/HestiaKERNEL/Test/Codes.sh create mode 100755 Shell/libraries/HestiaKERNEL/Test/Exec_Test_Case.ps1 create mode 100755 Shell/libraries/HestiaKERNEL/Test/Exec_Test_Case.sh create mode 100755 Shell/tests/FS/Get_Files/0.ps1 create mode 100755 Shell/tests/FS/Get_Files/0.sh create mode 100755 Shell/tests/FS/Get_Files/1.ps1 create mode 100755 Shell/tests/FS/Get_Files/1.sh create mode 100755 Shell/tests/FS/Get_Files/2.ps1 create mode 100755 Shell/tests/FS/Get_Files/2.sh create mode 100755 Shell/tests/FS/Get_Files/3.ps1 create mode 100755 Shell/tests/FS/Get_Files/3.sh create mode 100755 Shell/tests/FS/Get_Files/4.ps1 create mode 100755 Shell/tests/FS/Get_Files/4.sh create mode 100755 Shell/tests/FS/Get_Files/5.ps1 create mode 100755 Shell/tests/FS/Get_Files/5.sh create mode 100755 Shell/tests/FS/Get_Files/6.ps1 create mode 100755 Shell/tests/FS/Get_Files/6.sh create mode 100755 Shell/tests/FS/Get_Files/7.ps1 create mode 100755 Shell/tests/FS/Get_Files/7.sh create mode 100755 Shell/tests/FS/Get_Files/8.ps1 create mode 100755 Shell/tests/FS/Get_Files/8.sh create mode 100755 Shell/tests/FS/Is_Directory/0.ps1 create mode 100755 Shell/tests/FS/Is_Directory/0.sh create mode 100755 Shell/tests/FS/Is_Directory/1.ps1 create mode 100755 Shell/tests/FS/Is_Directory/1.sh create mode 100755 Shell/tests/FS/Is_Directory/2.ps1 create mode 100755 Shell/tests/FS/Is_Directory/2.sh create mode 100755 Shell/tests/FS/Is_Directory/3.ps1 create mode 100755 Shell/tests/FS/Is_Directory/3.sh create mode 100755 Shell/tests/FS/Is_File/0.ps1 create mode 100755 Shell/tests/FS/Is_File/0.sh create mode 100755 Shell/tests/FS/Is_File/1.ps1 create mode 100755 Shell/tests/FS/Is_File/1.sh create mode 100755 Shell/tests/FS/Is_File/2.ps1 create mode 100755 Shell/tests/FS/Is_File/2.sh create mode 100755 Shell/tests/FS/Is_File/3.ps1 create mode 100755 Shell/tests/FS/Is_File/3.sh create mode 100755 Shell/tests/String/Split_Left_String/4.ps1 create mode 100755 Shell/tests/String/Split_Left_String/4.sh diff --git a/Shell/libraries/HestiaKERNEL/FS/Get_Files.ps1 b/Shell/libraries/HestiaKERNEL/FS/Get_Files.ps1 new file mode 100644 index 0000000..72ce5fa --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/FS/Get_Files.ps1 @@ -0,0 +1,61 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${env:LIBS_HESTIA}\HestiaKERNEL\Errors\Error_Codes.ps1" +. "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_Directory.ps1" +. "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_File.ps1" + + + + +function HestiaKERNEL-Get-Files { + param ( + [string]$___directory, + [string]$___filter, + [int]$___recursive + ) + + + # validate input + if ($(HestiaKERNEL-Is-Directory-FS $___directory) -ne ${env:HestiaKERNEL_ERROR_OK}) { + return [string[]]@() + } + + + # execute + [System.Collections.Generic.List[string]]$___list = @() + foreach ($____item in (Get-ChildItem $___directory)) { + if ($(HestiaKERNEL-Is-Directory-FS $____item) -eq ${env:HestiaKERNEL_ERROR_OK}) { + if ($___recursive -eq 0) { + continue + } elseif ($___recursive -gt 0) { + $___results = HestiaKERNEL-Get-Files $____item.FullName ` + $___filter ` + ($___recursive - 1) + } else { + $___results = HestiaKERNEL-Get-Files $____item.FullName ` + $___filter ` + -1 + } + + foreach ($___result in $___results) { + $___list.Add($___result) + } + } elseif ($(HestiaKERNEL-Is-File-FS $____item) -eq ${env:HestiaKERNEL_ERROR_OK}) { + if ($____item.Name -like "*${___filter}*") { + $___list.Add($____item.FullName) + } + } + } + + + # report status + return [string[]]$___list +} diff --git a/Shell/libraries/HestiaKERNEL/FS/Get_Files.sh b/Shell/libraries/HestiaKERNEL/FS/Get_Files.sh new file mode 100644 index 0000000..06d053f --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/FS/Get_Files.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${LIBS_HESTIA}/HestiaKERNEL/Errors/Error_Codes.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/FS/Is_Directory.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/FS/Is_File.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/Number/Is_Number.sh" + + + + +HestiaKERNEL_Get_Files_FS() { + #___directory="$1" + #___filter="$2" + #___recursive="$3" + + + # validate input + if [ $(HestiaKERNEL_Is_Directory_FS "$1") -ne $HestiaKERNEL_ERROR_OK ]; then + printf -- "" + return $HestiaKERNEL_ERROR_ENTITY_INVALID + fi + + + # execute + for ____item in "$1"/*; do + if [ $(HestiaKERNEL_Is_Directory_FS "$____item") -eq $HestiaKERNEL_ERROR_OK ]; then + if [ $(HestiaKERNEL_Is_Number "$3") -ne $HestiaKERNEL_ERROR_OK ]; then + continue + fi + + if [ $3 -eq 0 ]; then + continue + elif [ $3 -gt 0 ]; then + HestiaKERNEL_Get_Files_FS "$____item" "$2" "$(($3 - 1))" + else + HestiaKERNEL_Get_Files_FS "$____item" "$2" "$3" + fi + elif [ $(HestiaKERNEL_Is_File_FS "$____item") -eq $HestiaKERNEL_ERROR_OK ]; then + ____filename="${____item##*/}" + + if [ "$2" = "" ]; then + printf -- "%s\n" "$____item" + elif [ ! "${____filename##*"$2"}" = "$____filename" ]; then + printf -- "%s\n" "$____item" + fi + fi + done + + + # report status + return $HestiaKERNEL_ERROR_OK +} diff --git a/Shell/libraries/HestiaKERNEL/FS/Is_Directory.ps1 b/Shell/libraries/HestiaKERNEL/FS/Is_Directory.ps1 new file mode 100644 index 0000000..77ae883 --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/FS/Is_Directory.ps1 @@ -0,0 +1,36 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${env:LIBS_HESTIA}\hestiaKERNEL\Errors\Error_Codes.sh" + + + + +function HestiaKERNEL-Is-Directory-FS { + param ( + [string]$___target + ) + + + # validate input + if ($___target -eq "") { + return ${env:hestiaKERNEL_ERROR_DATA_EMPTY} + } + + + # execute + if (Test-Path -PathType Container -Path $___target -ErrorAction SilentlyContinue) { + return ${env:hestiaKERNEL_ERROR_OK} + } + + + # report status + return ${env:hestiaKERNEL_ERROR_DATA_BAD} +} diff --git a/Shell/libraries/HestiaKERNEL/FS/Is_Directory.sh b/Shell/libraries/HestiaKERNEL/FS/Is_Directory.sh new file mode 100644 index 0000000..73893a6 --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/FS/Is_Directory.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${LIBS_HESTIA}/HestiaKERNEL/Errors/Error_Codes.sh" + + + + +HestiaKERNEL_Is_Directory_FS() { + #___target="$1" + + + # validate input + if [ "$1" = "" ]; then + printf -- "%d" "$HestiaKERNEL_ERROR_DATA_EMPTY" + return $HestiaKERNEL_ERROR_DATA_EMPTY + fi + + + # execute + if [ -d "$1" ]; then + printf -- "%d" "$HestiaKERNEL_ERROR_OK" + return $HestiaKERNEL_ERROR_OK + fi + + + # report status + printf -- "%d" "$HestiaKERNEL_ERROR_DATA_BAD" + return $HestiaKERNEL_ERROR_DATA_BAD +} diff --git a/Shell/libraries/HestiaKERNEL/FS/Is_File.ps1 b/Shell/libraries/HestiaKERNEL/FS/Is_File.ps1 new file mode 100644 index 0000000..dfcf714 --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/FS/Is_File.ps1 @@ -0,0 +1,36 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${env:LIBS_HESTIA}\hestiaKERNEL\Errors\Error_Codes.sh" + + + + +function HestiaKERNEL-Is-File-FS { + param ( + [string]$___target + ) + + + # validate input + if ($___target -eq "") { + return ${env:hestiaKERNEL_ERROR_DATA_EMPTY} + } + + + # execute + if (Test-Path -PathType leaf -Path $___target -ErrorAction SilentlyContinue) { + return ${env:hestiaKERNEL_ERROR_OK} + } + + + # report status + return ${env:hestiaKERNEL_ERROR_DATA_BAD} +} diff --git a/Shell/libraries/HestiaKERNEL/FS/Is_File.sh b/Shell/libraries/HestiaKERNEL/FS/Is_File.sh new file mode 100644 index 0000000..594ece2 --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/FS/Is_File.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${LIBS_HESTIA}/HestiaKERNEL/Errors/Error_Codes.sh" + + + + +HestiaKERNEL_Is_File_FS() { + #___target="$1" + + + # validate input + if [ "$1" = "" ]; then + printf -- "%d" "$HestiaKERNEL_ERROR_DATA_EMPTY" + return $HestiaKERNEL_ERROR_DATA_EMPTY + fi + + + # execute + if [ -f "$1" ]; then + printf -- "%d" "$HestiaKERNEL_ERROR_OK" + return $HestiaKERNEL_ERROR_OK + fi + + + # report status + printf -- "%d" "$HestiaKERNEL_ERROR_DATA_BAD" + return $HestiaKERNEL_ERROR_DATA_BAD +} diff --git a/Shell/libraries/HestiaKERNEL/Number/Is_Number.sh b/Shell/libraries/HestiaKERNEL/Number/Is_Number.sh index 511f30d..f56b195 100644 --- a/Shell/libraries/HestiaKERNEL/Number/Is_Number.sh +++ b/Shell/libraries/HestiaKERNEL/Number/Is_Number.sh @@ -27,7 +27,7 @@ HestiaKERNEL_Is_Number() { # execute case "$1" in - *[!0123456789_]*) + *[!+-0123456789_]*) printf -- "%d" $HestiaKERNEL_ERROR_DATA_INVALID return $HestiaKERNEL_ERROR_DATA_INVALID ;; diff --git a/Shell/libraries/HestiaKERNEL/Test/Codes.ps1 b/Shell/libraries/HestiaKERNEL/Test/Codes.ps1 new file mode 100755 index 0000000..b83b8bd --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/Test/Codes.ps1 @@ -0,0 +1,17 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. + + + + +# faciliate test framework +${env:HestiaKERNEL_TEST_PASSED} = 0 +${env:HestiaKERNEL_TEST_FAILED} = 1 diff --git a/Shell/libraries/HestiaKERNEL/Test/Codes.sh b/Shell/libraries/HestiaKERNEL/Test/Codes.sh new file mode 100755 index 0000000..f944b86 --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/Test/Codes.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. + + + + +# faciliate test framework +export HestiaKERNEL_TEST_PASSED=0 +export HestiaKERNEL_TEST_FAILED=1 diff --git a/Shell/libraries/HestiaKERNEL/Test/Exec_Test_Case.ps1 b/Shell/libraries/HestiaKERNEL/Test/Exec_Test_Case.ps1 new file mode 100755 index 0000000..1b9d6ac --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/Test/Exec_Test_Case.ps1 @@ -0,0 +1,55 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${env:LIBS_HESTIA}\HestiaKERNEL\Test\Codes.sh" + + + + +function HestiaKERNEL-Exec-Test-Case { + param ( + [string]$___filepath, + [string]$___report_only_failed + ) + + + # validate input + if ($___filepath -eq "") { + return ${env:HestiaKERNEL_TEST_FAILED} + } + + if (-not (Test-Path -Path $___filepath -PathType Leaf)) { + return ${env:HestiaKERNEL_TEST_FAILED} + } + + + # execute + $___process = & { + $___output = . $___script 2>&1 + if ($LASTEXITCODE -eq ${env:HestiaKERNEL_TEST_PASSED}) { + if ($___report_only_failed -eq "") { + $null = Write-Host "${___output}" + } + + return ${env:HestiaKERNEL_TEST_PASSED} + } + + $null = Write-Host "${___output}" + return ${env:HestiaKERNEL_TEST_FAILED} + } + + if ($___process -eq ${env:HestiaKERNEL_TEST_PASSED}) { + return ${env:HestiaKERNEL_TEST_PASSED} + } + + + # report status + return ${env:HestiaKERNEL_TEST_FAILED} +} diff --git a/Shell/libraries/HestiaKERNEL/Test/Exec_Test_Case.sh b/Shell/libraries/HestiaKERNEL/Test/Exec_Test_Case.sh new file mode 100755 index 0000000..c3c74f7 --- /dev/null +++ b/Shell/libraries/HestiaKERNEL/Test/Exec_Test_Case.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +. "${LIBS_HESTIA}/HestiaKERNEL/Test/Codes.sh" + + + + +HestiaKERNEL_Exec_Test_Case() { + #___filepath="$1" + #___report_only_failed="$2" + + + # validate input + if [ "$1" = "" ]; then + return $HestiaKERNEL_TEST_FAILED + fi + + if [ ! -f "$1" ]; then + return $HestiaKERNEL_TEST_FAILED + fi + + if [ ! -x "$1" ]; then + return $HestiaKERNEL_TEST_FAILED + fi + + + # execute + ___output="$(2>&1 /bin/sh "$1")" + if [ $? -eq 0 ]; then + if [ "$2" = "" ]; then + 1>&2 printf -- "%s\n" "$___output" + fi + return $HestiaKERNEL_TEST_PASSED + fi + 1>&2 printf -- "%s\n" "$___output" + + + # report status + return $HestiaKERNEL_TEST_FAILED +} diff --git a/Shell/libraries/HestiaKERNEL/Unicode/To_Unicode_From_String.sh b/Shell/libraries/HestiaKERNEL/Unicode/To_Unicode_From_String.sh index 6ad3b8b..368aef4 100644 --- a/Shell/libraries/HestiaKERNEL/Unicode/To_Unicode_From_String.sh +++ b/Shell/libraries/HestiaKERNEL/Unicode/To_Unicode_From_String.sh @@ -26,6 +26,12 @@ HestiaKERNEL_To_Unicode_From_String() { return $HestiaKERNEL_ERROR_DATA_EMPTY fi + if [ "${LANG%".UTF-8"}" = "$LANG" ] && [ "${LC_ALL%".UTF-8"}" = "$LC_ALL" ]; then + # unknown encoder + printf -- "%s" "" + return $HestiaKERNEL_ERROR_UNSUPPORTED + fi + # execute ## POSIX Shell does not handle any character beyond Latin-1 script. @@ -43,30 +49,22 @@ HestiaKERNEL_To_Unicode_From_String() { ___codepoint="" if [ "$LANG" = "" ] && [ "$LC_ALL" = "" ]; then - : # unknown language & encoder + # unknown language & encoder + ___codepoint=63 elif [ ! "$(type -t od)" = "" ]; then # using od byte processor ___data="$(printf -- "%s" "$___char" | od -A n -t uC)" - ___bytes="" + ___codepoint="" while [ ! "$___data" = "" ]; do ___byte="${___data##* }" ___data="${___data%" $___byte"}" if [ ! "$___byte" = "" ]; then - ___bytes="${___byte}, ${___bytes}" + ___codepoint="${___byte}, ${___codepoint}" continue fi done - ___bytes="${___bytes%, }" - - if [ ! "${LANG%".UTF-8"}" = "$LANG" ] || - [ ! "${LC_ALL%".UTF-8"}" = "$LC_ALL" ]; then - # encoder is UTF-8 - ___codepoint="$(HestiaKERNEL_To_Unicode_From_UTF8 "$___bytes")" - fi - fi - - if [ "$___codepoint" = "" ]; then + else # unknown encoder - replace with '?' ___codepoint=63 fi @@ -74,7 +72,15 @@ HestiaKERNEL_To_Unicode_From_String() { ___converted="${___converted}${___codepoint}, " done - printf -- "%s" "${___converted%, }" + + + # decode by known encoders + if [ ! "${LANG%".UTF-8"}" = "$LANG" ] || + [ ! "${LC_ALL%".UTF-8"}" = "$LC_ALL" ]; then + # encoder is UTF-8 + ___converted="$(HestiaKERNEL_To_Unicode_From_UTF8 "${___converted%, }")" + fi + printf -- "%s" "$___converted" # report status diff --git a/Shell/libraries/HestiaKERNEL/Vanilla.sh.ps1 b/Shell/libraries/HestiaKERNEL/Vanilla.sh.ps1 index 8a662b6..95a94e6 100644 --- a/Shell/libraries/HestiaKERNEL/Vanilla.sh.ps1 +++ b/Shell/libraries/HestiaKERNEL/Vanilla.sh.ps1 @@ -33,6 +33,9 @@ echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null # Windows POWERSHELL Codes # ################################################################################ . "${env:LIBS_HESTIA}\HestiaKERNEL\Errors\Error_Codes.ps1" +. "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Get_Files.ps1" +. "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_Directory.ps1" +. "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_File.ps1" . "${env:LIBS_HESTIA}\HestiaKERNEL\List\Is_Array_Byte.ps1" . "${env:LIBS_HESTIA}\HestiaKERNEL\List\Is_Array_Number.ps1" . "${env:LIBS_HESTIA}\HestiaKERNEL\Number\Is_Number.ps1" @@ -73,6 +76,8 @@ echo \" <<'RUN_AS_POWERSHELL' >/dev/null # " | Out-Null . "${env:LIBS_HESTIA}\HestiaKERNEL\String\Trim_Whitespace_Left_String.ps1" . "${env:LIBS_HESTIA}\HestiaKERNEL\String\Trim_Whitespace_Right_String.ps1" . "${env:LIBS_HESTIA}\HestiaKERNEL\String\Trim_Whitespace_String.ps1" +. "${env:LIBS_HESTIA}\HestiaKERNEL\Test\Codes.ps1" +. "${env:LIBS_HESTIA}\HestiaKERNEL\Test\Exec_Test_Case.ps1" . "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Get_First_Unicode.ps1" . "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Get_Last_Unicode.ps1" . "${env:LIBS_HESTIA}\HestiaKERNEL\Unicode\Index_Any_Left_Unicode.ps1" @@ -131,6 +136,9 @@ RUN_AS_POWERSHELL # Unix Main Codes # ################################################################################ . "${LIBS_HESTIA}/HestiaKERNEL/Errors/Error_Codes.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/FS/Get_Files.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/FS/Is_Directory.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/FS/Is_File.sh" . "${LIBS_HESTIA}/HestiaKERNEL/List/Is_Array_Byte.sh" . "${LIBS_HESTIA}/HestiaKERNEL/List/Is_Array_Number.sh" . "${LIBS_HESTIA}/HestiaKERNEL/Number/Is_Number.sh" @@ -171,6 +179,8 @@ RUN_AS_POWERSHELL . "${LIBS_HESTIA}/HestiaKERNEL/String/Trim_Whitespace_Left_String.sh" . "${LIBS_HESTIA}/HestiaKERNEL/String/Trim_Whitespace_Right_String.sh" . "${LIBS_HESTIA}/HestiaKERNEL/String/Trim_Whitespace_String.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/Test/Codes.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/Test/Exec_Test_Case.sh" . "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Get_First_Unicode.sh" . "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Get_Last_Unicode.sh" . "${LIBS_HESTIA}/HestiaKERNEL/Unicode/Index_Any_Left_Unicode.sh" diff --git a/Shell/shell/init.ps1 b/Shell/shell/init.ps1 index 9083e80..6ec787a 100644 --- a/Shell/shell/init.ps1 +++ b/Shell/shell/init.ps1 @@ -25,11 +25,17 @@ ${env:DIR_TEMP} = "${env:DIR_WORKSPACE}\temp" # setup locale -if (-not (Test-Path "${env:DIR_WORKSPACE}\libraries\HestiaKERNEL\Unicode\Init.ps1")) { - $null = Write-Host "[ ERROR ] Missing '.\libraries\HestiaKERNEL\Unicode\Init.ps1'" - return 1 +foreach ($___line in @( + "${env:DIR_WORKSPACE}\libraries\HestiaKERNEL\Unicode\Init.ps1" + "${env:DIR_WORKSPACE}\libraries\HestiaKERNEL\FS\Get_Files.ps1" +)) { + if (-not (Test-Path $___line)) { + $null = Write-Host "[ ERROR ] Missing '${___line}'" + return 1 + } + + $null = . $___line } -. "${env:DIR_WORKSPACE}\libraries\HestiaKERNEL\Unicode\Init.ps1" @@ -41,37 +47,6 @@ $null = New-Item -Path ${env:DIR_TEMP} -ItemType Directory -Force -# facilitate recursive find function -function Find-Files-Recursive { - param ( - [string]$___directory, - [string]$___filter - ) - - - # execute - [System.Collections.Generic.List[string]]$___list = @() - foreach ($___item in (Get-ChildItem $___directory)) { - if (Test-Path -Path $___item.FullName -PathType Container) { - $___results = Find-Files-Recursive $___item.FullName $___filter - foreach ($___result in $___results) { - $___list.Add($___result) - } - } elseif (Test-Path -Path $___item.FullName -PathType Leaf) { - if ($___item.Name -like "*${___filter}*") { - $___list.Add($___item.FullName) - } - } - } - - - # report status - return [string[]]$___list -} - - - - # source all init scripts if available if (Test-Path -Path "${env:DIR_WORKSPACE}\init" -PathType Container) { foreach ($___script in $(Find-Files-Recursive "${env:DIR_WORKSPACE}\init" ".ps1")) { diff --git a/Shell/shell/init.sh b/Shell/shell/init.sh index 8317170..23e3d70 100644 --- a/Shell/shell/init.sh +++ b/Shell/shell/init.sh @@ -26,11 +26,19 @@ export DIR_TEMP="${DIR_WORKSPACE}/temp" # setup locale -if [ ! -f "${DIR_WORKSPACE}/libraries/HestiaKERNEL/Unicode/Init.sh" ]; then - 1>&2 printf -- "[ ERROR ] Missing './libraries/HestiaKERNEL/Unicode/Init.sh'\n" - return 1 -fi -. "${DIR_WORKSPACE}/libraries/HestiaKERNEL/Unicode/Init.sh" +___old_IFS="$IFS" +while IFS="" read -r ___line || [ -n "$___line" ]; do + if [ ! -f "$___line" ]; then + 1>&2 printf -- "[ ERROR ] Missing '${___line}'\n" + return 1 + fi + + . "$___line" +done <&2 printf -- "$1" "${@:2}" - - - # report status - return 0 -} - - - - # source all init scripts if available if [ -d "${DIR_WORKSPACE}/init" ]; then - for ___script in $(Find_Files_Recursive "${DIR_WORKSPACE}/init" ".sh"); do + for ___script in $(HestiaKERNEL_Get_Files_FS "${DIR_WORKSPACE}/init" ".sh"); do if [ ! -f "$___script" ]; then continue fi diff --git a/Shell/shell/test.ps1 b/Shell/shell/test.ps1 index 1647e92..de040a3 100755 --- a/Shell/shell/test.ps1 +++ b/Shell/shell/test.ps1 @@ -8,11 +8,6 @@ # # You MUST ensure any interaction with the content STRICTLY COMPLIES with # the permissions and limitations set forth in the license. - - - - -# initialize workspace if (-not (Test-Path -Path "$(Get-Location)\shell\init.ps1")) { $null = Write-Error "[ ERROR ] Missing '.\shell\init.ps1'." exit 1 @@ -26,49 +21,57 @@ if ($___process -ne 0) { -# faciliate test framework -${env:TEST_PASSED} = 0 -${env:TEST_FAILED} = 1 +# import required libraries +. "${env:LIBS_HESTIA}\HestiaKERNEL\Test\Codes.ps1" +. "${env:LIBS_HESTIA}\HestiaKERNEL\Test\Exec_Test_Case.ps1" # execute all test scripts -$null = Write-Host "[ INFO ] BEGIN TESTS SUITE" $___scripts_total = 0 $___scripts_passed = 0 +$___only_failed = "" # value: 'true' (string) if (Test-Path -Path "${env:DIR_WORKSPACE}\tests" -PathType Container) { - foreach ($___script in $(Find-Files-Recursive "${env:DIR_WORKSPACE}\tests" ".ps1")) { - $null = Write-Host "`n`n[ INFO ] Executing '${___script}' ..." + foreach ( + $___script + in + $(HestiaKERNEL-Get-Files-FS "${env:DIR_WORKSPACE}\tests" ".ps1" -1) + ) { + # increase total count $___scripts_total += 1 - $___process = & { - $null = . $___script - if ($LASTEXITCODE -eq 0) { - return 0 - } - return 1 + # execute + if ($___only_failed -eq "") { + $null = Write-Host "`n" } + $null = Write-Host "[ INFO ] Executing '${___script}' ..." - $null = Write-Host "[ INFO ] Return code: |${___process}|" - if ($___process -ne 0) { + $___process = HestiaKERNEL-Exec-Test-Case $___script $___only_failed + if ($___process -ne ${env:HestiaKERNEL_TEST_PASSED}) { continue } + # increase passed count $___scripts_passed += 1 } } + + # report overall test report $___scripts_failed = $___scripts_total - $___scripts_passed $null = Write-Host @" `n -[ INFO ] TOTAL : ${___scripts_total} -[ INFO ] PASSED: ${___scripts_passed} -[ INFO ] FAILED: ${___scripts_failed} +[ RESULT ] +========== +TOTAL : ${___scripts_total} +PASSED: ${___scripts_passed} +FAILED: ${___scripts_failed} +========== "@ if ($___scripts_failed -ne 0) { diff --git a/Shell/shell/test.sh b/Shell/shell/test.sh index 84fe017..8b92990 100755 --- a/Shell/shell/test.sh +++ b/Shell/shell/test.sh @@ -22,38 +22,36 @@ fi -# faciliate test framework -export TEST_PASSED=0 -export TEST_FAILED=1 +# import required libraries +. "${LIBS_HESTIA}/HestiaKERNEL/Test/Codes.sh" +. "${LIBS_HESTIA}/HestiaKERNEL/Test/Exec_Test_Case.sh" # execute all test scripts -Logf "[ INFO ] BEGIN TESTS SUITE\n" ___scripts_total=0 ___scripts_passed=0 +___only_failed="" # value: 'true' (string) if [ -d "${DIR_WORKSPACE}/tests" ]; then - for ___script in $(Find_Files_Recursive "${DIR_WORKSPACE}/tests" ".sh"); do - if [ ! -f "$___script" ]; then - continue - fi - - 1>&2 printf -- "\n\n[ INFO ] Executing '${___script}' ...\n" + for ___script in $(HestiaKERNEL_Get_Files_FS "${DIR_WORKSPACE}/tests" ".sh" "-1"); do + # increase total count ___scripts_total=$(($___scripts_total + 1)) - if [ ! -x "$___script" ]; then - 1>&2 printf -- "[ ERROR ] Not executable!\n" - continue + + # execute + if [ "$___only_failed" = "" ]; then + 1>&2 printf -- "\n\n" fi - $(. "$___script") - ___process=$? + 1>&2 printf -- "[ INFO ] Executing '${___script}' ...\n" - 1>&2 printf -- "[ INFO ] Return Code: |%s|\n" "$___process" - if [ $___process -ne 0 ]; then + HestiaKERNEL_Exec_Test_Case "$___script" "$___only_failed" + if [ $? -ne $HestiaKERNEL_TEST_PASSED ]; then continue fi + + # increase passed count ___scripts_passed=$(($___scripts_passed + 1)) done fi @@ -63,14 +61,16 @@ fi # report overall test report ___scripts_failed=$(($___scripts_total - $___scripts_passed)) -Logf "\n -[ INFO ] TOTAL : %b -[ INFO ] PASSED : %b -[ INFO ] FAILED : %b +1>&2 printf -- "\n +[ RESULT ] +========== +TOTAL : %b +PASSED : %b +FAILED : %b +========== " "$___scripts_total" "$___scripts_passed" "$___scripts_failed" if [ $___scripts_total -ne $___scripts_passed ]; then return 1 fi - return 0 diff --git a/Shell/tests/FS/Get_Files/0.ps1 b/Shell/tests/FS/Get_Files/0.ps1 new file mode 100755 index 0000000..f377dde --- /dev/null +++ b/Shell/tests/FS/Get_Files/0.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can get all files. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Get_Files.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Get-Files-FS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "${env:LIBS_HESTIA}\HestiaKERNEL\FS" +$___expect = "" +$___output = HestiaKERNEL-Get-Files-FS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|not empty|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -ne $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Get_Files/0.sh b/Shell/tests/FS/Get_Files/0.sh new file mode 100755 index 0000000..a347fd4 --- /dev/null +++ b/Shell/tests/FS/Get_Files/0.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can get all files. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Get_Files.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="${LIBS_HESTIA}/HestiaKERNEL/FS" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="" +1>&2 printf -- "Given expect :\n|%s|\n\n" "not empty" + +___output="$(HestiaKERNEL_Get_Files_FS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Get_Files/1.ps1 b/Shell/tests/FS/Get_Files/1.ps1 new file mode 100755 index 0000000..6c2a308 --- /dev/null +++ b/Shell/tests/FS/Get_Files/1.ps1 @@ -0,0 +1,71 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can get all files with specified filter. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Get_Files.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Get-Files-FS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "${env:LIBS_HESTIA}\HestiaKERNEL\FS" +$___input_filter = ".ps1" +$___expect = "" +$___output = HestiaKERNEL-Get-Files-FS $___input $___input_filter +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given input filter :`n|${___input_filter}|`n" +$null = Write-Host "Given expect :`n|not empty|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -ne $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Get_Files/1.sh b/Shell/tests/FS/Get_Files/1.sh new file mode 100755 index 0000000..1f8b22b --- /dev/null +++ b/Shell/tests/FS/Get_Files/1.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can get all files with specified filter. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Get_Files.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="${LIBS_HESTIA}/HestiaKERNEL/FS" +___input_filter=".sh" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given input filter :\n|%s|\n\n" "$___input_filter" + +___expect="" +1>&2 printf -- "Given expect :\n|%s|\n\n" "not empty" + +___output="$(HestiaKERNEL_Get_Files_FS "$___input" "$___input_filter")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Get_Files/2.ps1 b/Shell/tests/FS/Get_Files/2.ps1 new file mode 100755 index 0000000..caabfc2 --- /dev/null +++ b/Shell/tests/FS/Get_Files/2.ps1 @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can get all files with specified filter recursively. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Get_Files.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Get-Files-FS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = ${env:LIBS_HESTIA} +$___input_filter = ".ps1" +$___input_recursive = -1 +$___expect = "" +$___output = HestiaKERNEL-Get-Files-FS $___input $___input_filter $___input_recursive +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given input filter :`n|${___input_filter}|`n" +$null = Write-Host "Given input recursive :`n|${___input_recursive}|`n" +$null = Write-Host "Given expect :`n|not empty|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -ne $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Get_Files/2.sh b/Shell/tests/FS/Get_Files/2.sh new file mode 100755 index 0000000..fb1d49b --- /dev/null +++ b/Shell/tests/FS/Get_Files/2.sh @@ -0,0 +1,76 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can get all files with specified filter recursively. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Get_Files.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="$LIBS_HESTIA" +___input_filter=".sh" +___input_recursive="-1" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given input filter :\n|%s|\n\n" "$___input_filter" +1>&2 printf -- "Given input recursive :\n|%s|\n\n" "$___input_recursive" + +___expect="" +1>&2 printf -- "Given expect :\n|%s|\n\n" "not empty" + +___output="$(HestiaKERNEL_Get_Files_FS "$___input" "$___input_filter" "$___input_recursive")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Get_Files/3.ps1 b/Shell/tests/FS/Get_Files/3.ps1 new file mode 100755 index 0000000..1a9fbe0 --- /dev/null +++ b/Shell/tests/FS/Get_Files/3.ps1 @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can get all files with specified filter and controlled recursively. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Get_Files.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Get-Files-FS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = ${env:LIBS_HESTIA} +$___input_filter = ".ps1" +$___input_recursive = 1 +$___expect = "" +$___output = HestiaKERNEL-Get-Files-FS $___input $___input_filter $___input_recursive +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given input filter :`n|${___input_filter}|`n" +$null = Write-Host "Given input recursive :`n|${___input_recursive}|`n" +$null = Write-Host "Given expect :`n|not empty|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -ne $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Get_Files/3.sh b/Shell/tests/FS/Get_Files/3.sh new file mode 100755 index 0000000..fabbd89 --- /dev/null +++ b/Shell/tests/FS/Get_Files/3.sh @@ -0,0 +1,76 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can get all files with specified filter and controlled recursively. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Get_Files.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="$LIBS_HESTIA" +___input_filter=".sh" +___input_recursive="1" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given input filter :\n|%s|\n\n" "$___input_filter" +1>&2 printf -- "Given input recursive :\n|%s|\n\n" "$___input_recursive" + +___expect="" +1>&2 printf -- "Given expect :\n|%s|\n\n" "not empty" + +___output="$(HestiaKERNEL_Get_Files_FS "$___input" "$___input_filter" "$___input_recursive")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Get_Files/4.ps1 b/Shell/tests/FS/Get_Files/4.ps1 new file mode 100755 index 0000000..c211c28 --- /dev/null +++ b/Shell/tests/FS/Get_Files/4.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can handle invalid path. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Get_Files.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Get-Files-FS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "${env:LIBS_HESTIA}\HestiaKERNEL\aebaebaebae" +$___expect = "" +$___output = HestiaKERNEL-Get-Files-FS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|not empty|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -eq $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Get_Files/4.sh b/Shell/tests/FS/Get_Files/4.sh new file mode 100755 index 0000000..10b120d --- /dev/null +++ b/Shell/tests/FS/Get_Files/4.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can handle invalid path. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Get_Files.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="${LIBS_HESTIA}/HestiaKERNEL/aebaebaebae" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="" +1>&2 printf -- "Given expect :\n|%s|\n\n" "empty" + +___output="$(HestiaKERNEL_Get_Files_FS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Get_Files/5.ps1 b/Shell/tests/FS/Get_Files/5.ps1 new file mode 100755 index 0000000..0b1f10c --- /dev/null +++ b/Shell/tests/FS/Get_Files/5.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can handle empty path. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Get_Files.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Get-Files-FS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "" +$___expect = "" +$___output = HestiaKERNEL-Get-Files-FS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|not empty|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -eq $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Get_Files/5.sh b/Shell/tests/FS/Get_Files/5.sh new file mode 100755 index 0000000..9c860b1 --- /dev/null +++ b/Shell/tests/FS/Get_Files/5.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can handle empty path. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Get_Files.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="" +1>&2 printf -- "Given expect :\n|%s|\n\n" "empty" + +___output="$(HestiaKERNEL_Get_Files_FS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Get_Files/6.ps1 b/Shell/tests/FS/Get_Files/6.ps1 new file mode 100755 index 0000000..0a790c1 --- /dev/null +++ b/Shell/tests/FS/Get_Files/6.ps1 @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can handle invalid path with specified filter and controlled recursively. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Get_Files.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Get-Files-FS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "${env:LIBS_HESTIA}\HestiaKERNEL\aerrgbaerbaer" +$___input_filter = ".ps1" +$___input_recursive = 1 +$___expect = "" +$___output = HestiaKERNEL-Get-Files-FS $___input $___input_filter $___input_recursive +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given input filter :`n|${___input_filter}|`n" +$null = Write-Host "Given input recursive :`n|${___input_recursive}|`n" +$null = Write-Host "Given expect :`n|not empty|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -eq $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Get_Files/6.sh b/Shell/tests/FS/Get_Files/6.sh new file mode 100755 index 0000000..0ed2f28 --- /dev/null +++ b/Shell/tests/FS/Get_Files/6.sh @@ -0,0 +1,76 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can handle invalid path with specified filter and controlled recursively. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Get_Files.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="${LIBS_HESTIA}/HestiaKERNEL/aerrgbaerbaer" +___input_filter=".sh" +___input_recursive="1" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given input filter :\n|%s|\n\n" "$___input_filter" +1>&2 printf -- "Given input recursive :\n|%s|\n\n" "$___input_recursive" + +___expect="" +1>&2 printf -- "Given expect :\n|%s|\n\n" "not empty" + +___output="$(HestiaKERNEL_Get_Files_FS "$___input" "$___input_filter" "$___input_recursive")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Get_Files/7.ps1 b/Shell/tests/FS/Get_Files/7.ps1 new file mode 100755 index 0000000..dcbdd00 --- /dev/null +++ b/Shell/tests/FS/Get_Files/7.ps1 @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can handle empty path with specified filter and controlled recursively. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Get_Files.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Get-Files-FS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "" +$___input_filter = ".ps1" +$___input_recursive = 1 +$___expect = "" +$___output = HestiaKERNEL-Get-Files-FS $___input $___input_filter $___input_recursive +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given input filter :`n|${___input_filter}|`n" +$null = Write-Host "Given input recursive :`n|${___input_recursive}|`n" +$null = Write-Host "Given expect :`n|not empty|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -eq $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Get_Files/7.sh b/Shell/tests/FS/Get_Files/7.sh new file mode 100755 index 0000000..45e06b2 --- /dev/null +++ b/Shell/tests/FS/Get_Files/7.sh @@ -0,0 +1,76 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can handle empty path with specified filter and controlled recursively. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Get_Files.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="" +___input_filter=".sh" +___input_recursive="1" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given input filter :\n|%s|\n\n" "$___input_filter" +1>&2 printf -- "Given input recursive :\n|%s|\n\n" "$___input_recursive" + +___expect="" +1>&2 printf -- "Given expect :\n|%s|\n\n" "not empty" + +___output="$(HestiaKERNEL_Get_Files_FS "$___input" "$___input_filter" "$___input_recursive")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Get_Files/8.ps1 b/Shell/tests/FS/Get_Files/8.ps1 new file mode 100755 index 0000000..19eb100 --- /dev/null +++ b/Shell/tests/FS/Get_Files/8.ps1 @@ -0,0 +1,73 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can handle file path with specified filter and controlled recursively. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Get_Files.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Get-Files-FS' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "${env:LIBS_HESTIA}\HestiaKERNEL\Vanilla.sh.ps1" +$___input_filter = ".ps1" +$___input_recursive = 1 +$___expect = "" +$___output = HestiaKERNEL-Get-Files-FS $___input $___input_filter $___input_recursive +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given input filter :`n|${___input_filter}|`n" +$null = Write-Host "Given input recursive :`n|${___input_recursive}|`n" +$null = Write-Host "Given expect :`n|not empty|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -eq $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Get_Files/8.sh b/Shell/tests/FS/Get_Files/8.sh new file mode 100755 index 0000000..33e9fd9 --- /dev/null +++ b/Shell/tests/FS/Get_Files/8.sh @@ -0,0 +1,76 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Get_Files + +DESCRIPTION: +Function can handle file path with specified filter and controlled recursively. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Get_Files.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="${LIBS_HESTIA}/HestiaKERNEL/Vanilla.sh" +___input_filter=".sh" +___input_recursive="1" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given input filter :\n|%s|\n\n" "$___input_filter" +1>&2 printf -- "Given input recursive :\n|%s|\n\n" "$___input_recursive" + +___expect="" +1>&2 printf -- "Given expect :\n|%s|\n\n" "not empty" + +___output="$(HestiaKERNEL_Get_Files_FS "$___input" "$___input_filter" "$___input_recursive")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Is_Directory/0.ps1 b/Shell/tests/FS/Is_Directory/0.ps1 new file mode 100755 index 0000000..6bb3f0c --- /dev/null +++ b/Shell/tests/FS/Is_Directory/0.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Is_Directory + +DESCRIPTION: +Function can identify a proper directory path. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_Directory.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Split-Left-String' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "${env:LIBS_HESTIA}\HestiaKERNEL" +$___expect = 0 +$___output = HestiaKERNEL-Is-Directory-FS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -eq $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Is_Directory/0.sh b/Shell/tests/FS/Is_Directory/0.sh new file mode 100755 index 0000000..4bdea92 --- /dev/null +++ b/Shell/tests/FS/Is_Directory/0.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Directory + +DESCRIPTION: +Function can identify a proper directory path. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Is_Directory.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="${LIBS_HESTIA}/HestiaKERNEL" +___expect="0" +___output="$(HestiaKERNEL_Is_Directory_FS "$___input")" +___process=$? +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given expect :\n|%s|\n\n" "$___expect" +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given return code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Is_Directory/1.ps1 b/Shell/tests/FS/Is_Directory/1.ps1 new file mode 100755 index 0000000..e4f6c52 --- /dev/null +++ b/Shell/tests/FS/Is_Directory/1.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Is_Directory + +DESCRIPTION: +Function can identify a proper file path. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_Directory.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Split-Left-String' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_Directory.ps1" +$___expect = 0 +$___output = HestiaKERNEL-Is-Directory-FS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|not ${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -ne $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Is_Directory/1.sh b/Shell/tests/FS/Is_Directory/1.sh new file mode 100755 index 0000000..3822e6b --- /dev/null +++ b/Shell/tests/FS/Is_Directory/1.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Directory + +DESCRIPTION: +Function can identify a proper file path. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Is_Directory.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="${LIBS_HESTIA}/HestiaKERNEL/FS/Is_Directory.sh" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|%s|\n\n" "not $___expect" + +___output="$(HestiaKERNEL_Is_Directory_FS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Is_Directory/2.ps1 b/Shell/tests/FS/Is_Directory/2.ps1 new file mode 100755 index 0000000..862087a --- /dev/null +++ b/Shell/tests/FS/Is_Directory/2.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Is_Directory + +DESCRIPTION: +Function can operate with empty string. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_Directory.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Split-Left-String' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "" +$___expect = 0 +$___output = HestiaKERNEL-Is-Directory-FS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -ne $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Is_Directory/2.sh b/Shell/tests/FS/Is_Directory/2.sh new file mode 100755 index 0000000..cd72c4c --- /dev/null +++ b/Shell/tests/FS/Is_Directory/2.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Directory + +DESCRIPTION: +Function can operate with empty string. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Is_Directory.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|%s|\n\n" "not $___expect" + +___output="$(HestiaKERNEL_Is_Directory_FS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Is_Directory/3.ps1 b/Shell/tests/FS/Is_Directory/3.ps1 new file mode 100755 index 0000000..8d1d16b --- /dev/null +++ b/Shell/tests/FS/Is_Directory/3.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Is_Directory + +DESCRIPTION: +Function can operate with invalid path. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_Directory.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Split-Left-String' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\aregRWEGaegeagaeG" +$___expect = 0 +$___output = HestiaKERNEL-Is-Directory-FS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|not ${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -ne $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Is_Directory/3.sh b/Shell/tests/FS/Is_Directory/3.sh new file mode 100755 index 0000000..10834d7 --- /dev/null +++ b/Shell/tests/FS/Is_Directory/3.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_Directory + +DESCRIPTION: +Function can operate with invalid path. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Is_Directory.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="${LIBS_HESTIA}/HestiaKERNEL/FS/aregRWEGaegeagaeG" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|%s|\n\n" "not $___expect" + +___output="$(HestiaKERNEL_Is_Directory_FS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Is_File/0.ps1 b/Shell/tests/FS/Is_File/0.ps1 new file mode 100755 index 0000000..ed49630 --- /dev/null +++ b/Shell/tests/FS/Is_File/0.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Is_File + +DESCRIPTION: +Function can identify a proper file path. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_File.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Split-Left-String' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_File.ps1" +$___expect = 0 +$___output = HestiaKERNEL-Is-File-FS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -eq $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Is_File/0.sh b/Shell/tests/FS/Is_File/0.sh new file mode 100755 index 0000000..937ee1d --- /dev/null +++ b/Shell/tests/FS/Is_File/0.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_File + +DESCRIPTION: +Function can identify a proper file path. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Is_File.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="${LIBS_HESTIA}/HestiaKERNEL/FS/Is_File.sh" +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" + +___expect="0" +1>&2 printf -- "Given expect :\n|%s|\n\n" "$___expect" + +___output="$(HestiaKERNEL_Is_File_FS "$___input")" +___process=$? +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given exit code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Is_File/1.ps1 b/Shell/tests/FS/Is_File/1.ps1 new file mode 100755 index 0000000..2053765 --- /dev/null +++ b/Shell/tests/FS/Is_File/1.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Is_File + +DESCRIPTION: +Function can identify a proper directory path. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_File.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Split-Left-String' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "${env:LIBS_HESTIA}\HestiaKERNEL" +$___expect = 0 +$___output = HestiaKERNEL-Is-File-FS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|not ${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -ne $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Is_File/1.sh b/Shell/tests/FS/Is_File/1.sh new file mode 100755 index 0000000..513533c --- /dev/null +++ b/Shell/tests/FS/Is_File/1.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_File + +DESCRIPTION: +Function can identify a proper directory path. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Is_File.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="${LIBS_HESTIA}/HestiaKERNEL" +___expect="0" +___output="$(HestiaKERNEL_Is_File_FS "$___input")" +___process=$? +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given expect :\n|not %s|\n\n" "$___expect" +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given return code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Is_File/2.ps1 b/Shell/tests/FS/Is_File/2.ps1 new file mode 100755 index 0000000..76c8d91 --- /dev/null +++ b/Shell/tests/FS/Is_File/2.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Is_File + +DESCRIPTION: +Function can operate with empty string. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_File.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Split-Left-String' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "" +$___expect = 0 +$___output = HestiaKERNEL-Is-File-FS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|not ${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -ne $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Is_File/2.sh b/Shell/tests/FS/Is_File/2.sh new file mode 100755 index 0000000..eec68b2 --- /dev/null +++ b/Shell/tests/FS/Is_File/2.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_File + +DESCRIPTION: +Function can operate with empty string. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Is_File.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="" +___expect="0" +___output="$(HestiaKERNEL_Is_File_FS "$___input")" +___process=$? +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given expect :\n|not %s|\n\n" "$___expect" +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given return code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/FS/Is_File/3.ps1 b/Shell/tests/FS/Is_File/3.ps1 new file mode 100755 index 0000000..de21ea8 --- /dev/null +++ b/Shell/tests/FS/Is_File/3.ps1 @@ -0,0 +1,69 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Is_File + +DESCRIPTION: +Function can operate with invalid path. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\Is_File.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Split-Left-String' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "${env:LIBS_HESTIA}\HestiaKERNEL\FS\aregRWEGaegeagaeG" +$___expect = 0 +$___output = HestiaKERNEL-Is-File-FS $___input +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given expect :`n|not ${___expect}|`n" +$null = Write-Host "Got Output :`n|${___output}|`n" + + + + +# assert result +if ($___output -ne $___expect) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/FS/Is_File/3.sh b/Shell/tests/FS/Is_File/3.sh new file mode 100755 index 0000000..20d1f51 --- /dev/null +++ b/Shell/tests/FS/Is_File/3.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Is_File + +DESCRIPTION: +Function can operate with invalid path. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/FS/Is_File.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="${LIBS_HESTIA}/HestiaKERNEL/FS/aregRWEGaegeagaeG" +___expect="0" +___output="$(HestiaKERNEL_Is_File_FS "$___input")" +___process=$? +1>&2 printf -- "Given input :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given expect :\n|not %s|\n\n" "$___expect" +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given return code :\n|%s|\n\n" "$___process" + + + + +# assert result +if [ ! "$___output" = "$___expect" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/String/Split_Left_String/0.ps1 b/Shell/tests/String/Split_Left_String/0.ps1 index f839945..d5fafb1 100755 --- a/Shell/tests/String/Split_Left_String/0.ps1 +++ b/Shell/tests/String/Split_Left_String/0.ps1 @@ -23,7 +23,7 @@ Function can split a proper string. $null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" if (${env:LIBS_HESTIA} -eq "") { $null = Write-Host "[ FAILED ] variable undefined!`n" - exit ${env:TEST_FAILED} + exit 1 } @@ -33,7 +33,7 @@ $___target = "${env:LIBS_HESTIA}\HestiaKERNEL\String\Split_Left_String.ps1" $null = Write-Host "Checking Library file (${___target})..." if (-not (Test-Path -Path $___target)) { $null = Write-Host "[ FAILED ] missing file!`n" - exit ${env:TEST_FAILED} + exit 1 } @@ -43,7 +43,7 @@ $null = Write-Host "Import function library..." $null = . $___target if (-not (Get-Command 'HestiaKERNEL-Split-Left-String' -errorAction SilentlyContinue)) { $null = Write-Host "[ FAILED ] error on import!`n" - exit ${env:TEST_FAILED} + exit 1 } @@ -67,11 +67,6 @@ $null = Write-Host "Given input :`n|${___input}|`n" $null = Write-Host "Given target:`n|${___target}|`n" $___verdict = 0 -if ($___output.Length -ne $___expect.Length) { -} else { - for ($i = 0; $i -lt $___output.Length; $i++) { - } -} $___length = $___output.Length if ($___expect.Length -gt $___length) { @@ -120,7 +115,7 @@ for ($i = 0; $i -lt $___length; $i++) { # assert result if ($___verdict -eq 0) { $null = Write-Host "[ PASSED ]" - exit ${env:TEST_PASSED} + exit 0 } $null = Write-Host "[ FAILED ] unexpected/inconsistent output!" -exit ${env:TEST_FAILED} +exit 1 diff --git a/Shell/tests/String/Split_Left_String/0.sh b/Shell/tests/String/Split_Left_String/0.sh index 949aebd..2bbfaab 100755 --- a/Shell/tests/String/Split_Left_String/0.sh +++ b/Shell/tests/String/Split_Left_String/0.sh @@ -9,7 +9,7 @@ # # You MUST ensure any interaction with the content STRICTLY COMPLIES with # the permissions and limitations set forth in the license. -Logf "%s\n" "\ +1>&2 printf -- "%s\n" "\ TEST CASE : HestiaKERNEL_Split_String @@ -20,30 +20,30 @@ Function can split a proper string. -Logf "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" if [ "$LIBS_HESTIA" = "" ]; then - Logf "[ FAILED ] variable undefined!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 fi ___target="${LIBS_HESTIA}/HestiaKERNEL/String/Split_Left_String.sh" -Logf "Checking Library file (%s)\n" "$___target" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" if [ ! -f "$___target" ]; then - Logf "[ FAILED ] missing file!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 fi -Logf "Import function library...\n" +1>&2 printf -- "Import function library...\n" . "$___target" if [ $? -ne 0 ]; then - Logf "[ FAILED ] error on import!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 fi @@ -61,14 +61,14 @@ ___expect_fallback="\ 101, 103, 69, 63, 70" ___output="$(HestiaKERNEL_Split_Left_String "$___input" "$___target")" ___process=$? -Logf "Given sample :\n|%s|\n\n" "$___input" -Logf "Given target :\n|%s|\n\n" "$___target" -Logf "Given expect :\n|%s|\n\n" "$___expect" -Logf "Given expect (fallback):\n|%s|\n\n" "$___expect_fallback" -Logf "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given sample :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given target :\n|%s|\n\n" "$___target" +1>&2 printf -- "Given expect :\n|%s|\n\n" "$___expect" +1>&2 printf -- "Given expect (fallback):\n|%s|\n\n" "$___expect_fallback" +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" if [ $___process -ne 0 ]; then - Logf "[ FAILED ] error on execution!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] error on execution!\n" + exit 1 fi @@ -76,8 +76,8 @@ fi # assert result if [ "$___output" = "$___expect" ] || [ "$___output" = "$___expect_fallback" ]; then - Logf "[ PASSED ]\n" - exit $TEST_PASSED + 1>&2 printf -- "[ PASSED ]\n" + exit 0 fi -Logf "[ FAILED ] unexpected/inconsistent output!\n" -exit $TEST_FAILED +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/String/Split_Left_String/1.ps1 b/Shell/tests/String/Split_Left_String/1.ps1 index 5f143e4..58e4ac4 100755 --- a/Shell/tests/String/Split_Left_String/1.ps1 +++ b/Shell/tests/String/Split_Left_String/1.ps1 @@ -23,7 +23,7 @@ Function can split a proper string with non-ASCII character. $null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" if (${env:LIBS_HESTIA} -eq "") { $null = Write-Host "[ FAILED ] variable undefined!`n" - exit ${env:TEST_FAILED} + exit 1 } @@ -33,7 +33,7 @@ $___target = "${env:LIBS_HESTIA}\HestiaKERNEL\String\Split_Left_String.ps1" $null = Write-Host "Checking Library file (${___target})..." if (-not (Test-Path -Path $___target)) { $null = Write-Host "[ FAILED ] missing file!`n" - exit ${env:TEST_FAILED} + exit 1 } @@ -43,7 +43,7 @@ $null = Write-Host "Import function library..." $null = . $___target if (-not (Get-Command 'HestiaKERNEL-Split-Left-String' -errorAction SilentlyContinue)) { $null = Write-Host "[ FAILED ] error on import!`n" - exit ${env:TEST_FAILED} + exit 1 } @@ -71,11 +71,6 @@ $null = Write-Host "Given input :`n|${___input}|`n" $null = Write-Host "Given target:`n|${___target}|`n" $___verdict = 0 -if ($___output.Length -ne $___expect.Length) { -} else { - for ($i = 0; $i -lt $___output.Length; $i++) { - } -} $___length = $___output.Length if ($___expect.Length -gt $___length) { @@ -124,7 +119,7 @@ for ($i = 0; $i -lt $___length; $i++) { # assert result if ($___verdict -eq 0) { $null = Write-Host "[ PASSED ]" - exit ${env:TEST_PASSED} + exit 0 } $null = Write-Host "[ FAILED ] unexpected/inconsistent output!" -exit ${env:TEST_FAILED} +exit 1 diff --git a/Shell/tests/String/Split_Left_String/1.sh b/Shell/tests/String/Split_Left_String/1.sh index 965cbe0..c7ca197 100755 --- a/Shell/tests/String/Split_Left_String/1.sh +++ b/Shell/tests/String/Split_Left_String/1.sh @@ -9,7 +9,7 @@ # # You MUST ensure any interaction with the content STRICTLY COMPLIES with # the permissions and limitations set forth in the license. -Logf "%s\n" "\ +1>&2 printf -- "%s\n" "\ TEST CASE : HestiaKERNEL_Split_String @@ -20,30 +20,30 @@ Function can split a proper string with non-ASCII character. -Logf "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" if [ "$LIBS_HESTIA" = "" ]; then - Logf "[ FAILED ] variable undefined!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 fi ___target="${LIBS_HESTIA}/HestiaKERNEL/String/Split_Left_String.sh" -Logf "Checking Library file (%s)\n" "$___target" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" if [ ! -f "$___target" ]; then - Logf "[ FAILED ] missing file!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 fi -Logf "Import function library...\n" +1>&2 printf -- "Import function library...\n" . "$___target" if [ $? -ne 0 ]; then - Logf "[ FAILED ] error on import!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 fi @@ -65,14 +65,14 @@ ___expect_fallback="\ 70" ___output="$(HestiaKERNEL_Split_Left_String "$___input" "$___target")" ___process=$? -Logf "Given sample :\n|%s|\n\n" "$___input" -Logf "Given target :\n|%s|\n\n" "$___target" -Logf "Given expect :\n|%s|\n\n" "$___expect" -Logf "Given expect (fallback):\n|%s|\n\n" "$___expect_fallback" -Logf "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given sample :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given target :\n|%s|\n\n" "$___target" +1>&2 printf -- "Given expect :\n|%s|\n\n" "$___expect" +1>&2 printf -- "Given expect (fallback):\n|%s|\n\n" "$___expect_fallback" +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" if [ $___process -ne 0 ]; then - Logf "[ FAILED ] error on execution!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] error on execution!\n" + exit 1 fi @@ -80,8 +80,8 @@ fi # assert result if [ "$___output" = "$___expect" ] || [ "$___output" = "$___expect_fallback" ]; then - Logf "[ PASSED ]\n" - exit $TEST_PASSED + 1>&2 printf -- "[ PASSED ]\n" + exit 0 fi -Logf "[ FAILED ] unexpected/inconsistent output!\n" -exit $TEST_FAILED +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/String/Split_Left_String/2.ps1 b/Shell/tests/String/Split_Left_String/2.ps1 index 5f2bcde..016aa1f 100755 --- a/Shell/tests/String/Split_Left_String/2.ps1 +++ b/Shell/tests/String/Split_Left_String/2.ps1 @@ -23,7 +23,7 @@ Function can split a proper string when target is the same as sample. $null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" if (${env:LIBS_HESTIA} -eq "") { $null = Write-Host "[ FAILED ] variable undefined!`n" - exit ${env:TEST_FAILED} + exit 1 } @@ -33,7 +33,7 @@ $___target = "${env:LIBS_HESTIA}\HestiaKERNEL\String\Split_Left_String.ps1" $null = Write-Host "Checking Library file (${___target})..." if (-not (Test-Path -Path $___target)) { $null = Write-Host "[ FAILED ] missing file!`n" - exit ${env:TEST_FAILED} + exit 1 } @@ -43,7 +43,7 @@ $null = Write-Host "Import function library..." $null = . $___target if (-not (Get-Command 'HestiaKERNEL-Split-Left-String' -errorAction SilentlyContinue)) { $null = Write-Host "[ FAILED ] error on import!`n" - exit ${env:TEST_FAILED} + exit 1 } @@ -59,11 +59,6 @@ $null = Write-Host "Given input :`n|${___input}|`n" $null = Write-Host "Given target:`n|${___target}|`n" $___verdict = 0 -if ($___output.Length -ne $___expect.Length) { -} else { - for ($i = 0; $i -lt $___output.Length; $i++) { - } -} $___length = $___output.Length if ($___expect.Length -gt $___length) { @@ -112,7 +107,7 @@ for ($i = 0; $i -lt $___length; $i++) { # assert result if ($___verdict -eq 0) { $null = Write-Host "[ PASSED ]" - exit ${env:TEST_PASSED} + exit 0 } $null = Write-Host "[ FAILED ] unexpected/inconsistent output!" -exit ${env:TEST_FAILED} +exit 1 diff --git a/Shell/tests/String/Split_Left_String/2.sh b/Shell/tests/String/Split_Left_String/2.sh index f4ab652..5f2e273 100755 --- a/Shell/tests/String/Split_Left_String/2.sh +++ b/Shell/tests/String/Split_Left_String/2.sh @@ -9,7 +9,7 @@ # # You MUST ensure any interaction with the content STRICTLY COMPLIES with # the permissions and limitations set forth in the license. -Logf "%s\n" "\ +1>&2 printf -- "%s\n" "\ TEST CASE : HestiaKERNEL_Split_String @@ -20,30 +20,30 @@ Function can split a proper string when target is the same as sample. -Logf "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" if [ "$LIBS_HESTIA" = "" ]; then - Logf "[ FAILED ] variable undefined!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 fi ___target="${LIBS_HESTIA}/HestiaKERNEL/String/Split_Left_String.sh" -Logf "Checking Library file (%s)\n" "$___target" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" if [ ! -f "$___target" ]; then - Logf "[ FAILED ] missing file!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 fi -Logf "Import function library...\n" +1>&2 printf -- "Import function library...\n" . "$___target" if [ $? -ne 0 ]; then - Logf "[ FAILED ] error on import!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 fi @@ -55,14 +55,14 @@ ___expect="" ___expect_fallback="" ___output="$(HestiaKERNEL_Split_Left_String "$___input" "$___target")" ___process=$? -Logf "Given sample :\n|%s|\n\n" "$___input" -Logf "Given target :\n|%s|\n\n" "$___target" -Logf "Given expect :\n|%s|\n\n" "$___expect" -Logf "Given expect (fallback):\n|%s|\n\n" "$___expect_fallback" -Logf "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given sample :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given target :\n|%s|\n\n" "$___target" +1>&2 printf -- "Given expect :\n|%s|\n\n" "$___expect" +1>&2 printf -- "Given expect (fallback):\n|%s|\n\n" "$___expect_fallback" +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" if [ $___process -ne 0 ]; then - Logf "[ FAILED ] error on execution!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] error on execution!\n" + exit 1 fi @@ -70,8 +70,8 @@ fi # assert result if [ "$___output" = "$___expect" ] || [ "$___output" = "$___expect_fallback" ]; then - Logf "[ PASSED ]\n" - exit $TEST_PASSED + 1>&2 printf -- "[ PASSED ]\n" + exit 0 fi -Logf "[ FAILED ] unexpected/inconsistent output!\n" -exit $TEST_FAILED +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/String/Split_Left_String/3.ps1 b/Shell/tests/String/Split_Left_String/3.ps1 index 12fdd19..2f8f22d 100755 --- a/Shell/tests/String/Split_Left_String/3.ps1 +++ b/Shell/tests/String/Split_Left_String/3.ps1 @@ -23,7 +23,7 @@ Function can split an empty string. $null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" if (${env:LIBS_HESTIA} -eq "") { $null = Write-Host "[ FAILED ] variable undefined!`n" - exit ${env:TEST_FAILED} + exit 1 } @@ -33,7 +33,7 @@ $___target = "${env:LIBS_HESTIA}\HestiaKERNEL\String\Split_Left_String.ps1" $null = Write-Host "Checking Library file (${___target})..." if (-not (Test-Path -Path $___target)) { $null = Write-Host "[ FAILED ] missing file!`n" - exit ${env:TEST_FAILED} + exit 1 } @@ -43,7 +43,7 @@ $null = Write-Host "Import function library..." $null = . $___target if (-not (Get-Command 'HestiaKERNEL-Split-Left-String' -errorAction SilentlyContinue)) { $null = Write-Host "[ FAILED ] error on import!`n" - exit ${env:TEST_FAILED} + exit 1 } @@ -59,11 +59,6 @@ $null = Write-Host "Given input :`n|${___input}|`n" $null = Write-Host "Given target:`n|${___target}|`n" $___verdict = 0 -if ($___output.Length -ne $___expect.Length) { -} else { - for ($i = 0; $i -lt $___output.Length; $i++) { - } -} $___length = $___output.Length if ($___expect.Length -gt $___length) { @@ -112,7 +107,7 @@ for ($i = 0; $i -lt $___length; $i++) { # assert result if ($___verdict -eq 0) { $null = Write-Host "[ PASSED ]" - exit ${env:TEST_PASSED} + exit 0 } $null = Write-Host "[ FAILED ] unexpected/inconsistent output!" -exit ${env:TEST_FAILED} +exit 1 diff --git a/Shell/tests/String/Split_Left_String/3.sh b/Shell/tests/String/Split_Left_String/3.sh index ad6d1b9..a726512 100755 --- a/Shell/tests/String/Split_Left_String/3.sh +++ b/Shell/tests/String/Split_Left_String/3.sh @@ -9,7 +9,7 @@ # # You MUST ensure any interaction with the content STRICTLY COMPLIES with # the permissions and limitations set forth in the license. -Logf "%s\n" "\ +1>&2 printf -- "%s\n" "\ TEST CASE : HestiaKERNEL_Split_String @@ -20,30 +20,30 @@ Function can split an empty string. -Logf "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" if [ "$LIBS_HESTIA" = "" ]; then - Logf "[ FAILED ] variable undefined!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 fi ___target="${LIBS_HESTIA}/HestiaKERNEL/String/Split_Left_String.sh" -Logf "Checking Library file (%s)\n" "$___target" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" if [ ! -f "$___target" ]; then - Logf "[ FAILED ] missing file!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 fi -Logf "Import function library...\n" +1>&2 printf -- "Import function library...\n" . "$___target" if [ $? -ne 0 ]; then - Logf "[ FAILED ] error on import!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 fi @@ -55,14 +55,14 @@ ___expect="" ___expect_fallback="" ___output="$(HestiaKERNEL_Split_Left_String "$___input" "$___target")" ___process=$? -Logf "Given sample :\n|%s|\n\n" "$___input" -Logf "Given target :\n|%s|\n\n" "$___target" -Logf "Given expect :\n|%s|\n\n" "$___expect" -Logf "Given expect (fallback):\n|%s|\n\n" "$___expect_fallback" -Logf "Given output :\n|%s|\n\n" "$___output" +1>&2 printf -- "Given sample :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given target :\n|%s|\n\n" "$___target" +1>&2 printf -- "Given expect :\n|%s|\n\n" "$___expect" +1>&2 printf -- "Given expect (fallback):\n|%s|\n\n" "$___expect_fallback" +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" if [ $___process -ne 0 ]; then - Logf "[ FAILED ] error on execution!\n" - exit $TEST_FAILED + 1>&2 printf -- "[ FAILED ] error on execution!\n" + exit 1 fi @@ -70,8 +70,8 @@ fi # assert result if [ "$___output" = "$___expect" ] || [ "$___output" = "$___expect_fallback" ]; then - Logf "[ PASSED ]\n" - exit $TEST_PASSED + 1>&2 printf -- "[ PASSED ]\n" + exit 0 fi -Logf "[ FAILED ] unexpected/inconsistent output!\n" -exit $TEST_FAILED +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1 diff --git a/Shell/tests/String/Split_Left_String/4.ps1 b/Shell/tests/String/Split_Left_String/4.ps1 new file mode 100755 index 0000000..d5fafb1 --- /dev/null +++ b/Shell/tests/String/Split_Left_String/4.ps1 @@ -0,0 +1,121 @@ +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +$null = Write-Host @" +TEST CASE : +HestiaKERNEL_Split_String + +DESCRIPTION: +Function can split a proper string. + +"@ + + + + +$null = Write-Host "Checking LIBS_HESTIA pathing: (${env:LIBS_HESTIA})" +if (${env:LIBS_HESTIA} -eq "") { + $null = Write-Host "[ FAILED ] variable undefined!`n" + exit 1 +} + + + + +$___target = "${env:LIBS_HESTIA}\HestiaKERNEL\String\Split_Left_String.ps1" +$null = Write-Host "Checking Library file (${___target})..." +if (-not (Test-Path -Path $___target)) { + $null = Write-Host "[ FAILED ] missing file!`n" + exit 1 +} + + + + +$null = Write-Host "Import function library..." +$null = . $___target +if (-not (Get-Command 'HestiaKERNEL-Split-Left-String' -errorAction SilentlyContinue)) { + $null = Write-Host "[ FAILED ] error on import!`n" + exit 1 +} + + + + +$___input = "e你feeeff你你aerg aegE你F" +$___target = "a" +$___expect = @( + "e你feeeff你你", + "erg ", + "egE你F" +) +$___expect_fallback = @( + "e?feeeff??", + "erg ", + "egE?F" +) +$___output = HestiaKERNEL-Split-Left-String $___input $___target + +$null = Write-Host "Given input :`n|${___input}|`n" +$null = Write-Host "Given target:`n|${___target}|`n" + +$___verdict = 0 + +$___length = $___output.Length +if ($___expect.Length -gt $___length) { + $___length = $___expect.Length + $___verdict = 1 +} + +if ($___expect_fallback.Length -gt $___length) { + $___length = $___expect_fallback.Length + $___verdict = 1 +} + +$null = Write-Host "Got :`n|index|expect|expect_fallback|output|" +for ($i = 0; $i -lt $___length; $i++) { + try { + $___char_output = $___output[$i] + } catch { + $___char_output = "" + } + + try { + $___char_expect = $___expect[$i] + } catch { + $___char_expect = "" + } + + try { + $___char_expect_fallback = $___expect_fallback[$i] + } catch { + $___char_expect_fallback = "" + } + + if ( + ($___char_output -ne $___char_expect) -and + ($___char_output -ne $___char_expect_fallback) + ) { + $___verdict = 1 + } + + $null = Write-Host "|${i}|${___char_expect}|${___char_expect_fallback}|${___char_output}|" +} + + + + +# assert result +if ($___verdict -eq 0) { + $null = Write-Host "[ PASSED ]" + exit 0 +} +$null = Write-Host "[ FAILED ] unexpected/inconsistent output!" +exit 1 diff --git a/Shell/tests/String/Split_Left_String/4.sh b/Shell/tests/String/Split_Left_String/4.sh new file mode 100755 index 0000000..2bbfaab --- /dev/null +++ b/Shell/tests/String/Split_Left_String/4.sh @@ -0,0 +1,83 @@ +#!/bin/sh +# Copyright 2024 (Holloway) Chew, Kean Ho +# +# +# Licensed under (Holloway) Chew, Kean Ho’s Liberal License (the "License"). +# You must comply with the license to use the content. Get the License at: +# +# https://doi.org/10.5281/zenodo.13770769 +# +# You MUST ensure any interaction with the content STRICTLY COMPLIES with +# the permissions and limitations set forth in the license. +1>&2 printf -- "%s\n" "\ +TEST CASE : +HestiaKERNEL_Split_String + +DESCRIPTION: +Function can split a proper string. +" + + + + +1>&2 printf -- "Checking LIBS_HESTIA pathing: (%s)\n" "$LIBS_HESTIA" +if [ "$LIBS_HESTIA" = "" ]; then + 1>&2 printf -- "[ FAILED ] variable undefined!\n" + exit 1 +fi + + + + +___target="${LIBS_HESTIA}/HestiaKERNEL/String/Split_Left_String.sh" +1>&2 printf -- "Checking Library file (%s)\n" "$___target" +if [ ! -f "$___target" ]; then + 1>&2 printf -- "[ FAILED ] missing file!\n" + exit 1 +fi + + + + +1>&2 printf -- "Import function library...\n" +. "$___target" +if [ $? -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on import!\n" + exit 1 +fi + + + + +___input="e你feeeff你你aergaegE你F" +___target="a" +___expect="\ +101, 20320, 102, 101, 101, 101, 102, 102, 20320, 20320 +101, 114, 103 +101, 103, 69, 20320, 70" +___expect_fallback="\ +101, 63, 102, 101, 101, 101, 102, 102, 63, 63 +101, 114, 103 +101, 103, 69, 63, 70" +___output="$(HestiaKERNEL_Split_Left_String "$___input" "$___target")" +___process=$? +1>&2 printf -- "Given sample :\n|%s|\n\n" "$___input" +1>&2 printf -- "Given target :\n|%s|\n\n" "$___target" +1>&2 printf -- "Given expect :\n|%s|\n\n" "$___expect" +1>&2 printf -- "Given expect (fallback):\n|%s|\n\n" "$___expect_fallback" +1>&2 printf -- "Given output :\n|%s|\n\n" "$___output" +if [ $___process -ne 0 ]; then + 1>&2 printf -- "[ FAILED ] error on execution!\n" + exit 1 +fi + + + + +# assert result +if [ "$___output" = "$___expect" ] || [ "$___output" = "$___expect_fallback" ]; then + 1>&2 printf -- "[ PASSED ]\n" + exit 0 +fi +1>&2 printf -- "[ FAILED ] unexpected/inconsistent output!\n" +exit 1