From 6990a6bce401e5831f15b0c2866ceb742290600a Mon Sep 17 00:00:00 2001 From: Murat Kirazkaya <77299279+GroophyLifefor@users.noreply.github.com> Date: Fri, 12 Jan 2024 19:39:21 +0300 Subject: [PATCH 1/2] feat: removed old files --- exercises/practice/hello-world/Greeter.bat | 1 - .../practice/hello-world/GreeterTest.bat | 23 ------------------- 2 files changed, 24 deletions(-) delete mode 100644 exercises/practice/hello-world/Greeter.bat delete mode 100644 exercises/practice/hello-world/GreeterTest.bat diff --git a/exercises/practice/hello-world/Greeter.bat b/exercises/practice/hello-world/Greeter.bat deleted file mode 100644 index 3db3b5c..0000000 --- a/exercises/practice/hello-world/Greeter.bat +++ /dev/null @@ -1 +0,0 @@ -@Echo Goodbye, Mars! diff --git a/exercises/practice/hello-world/GreeterTest.bat b/exercises/practice/hello-world/GreeterTest.bat deleted file mode 100644 index 204eca6..0000000 --- a/exercises/practice/hello-world/GreeterTest.bat +++ /dev/null @@ -1,23 +0,0 @@ -@echo off -REM --------------------------------------------------- -REM testThatGreeterReturnsTheCorrectGreeting -REM --------------------------------------------------- - -REM Initalize result variable -set "result=" -set "expected=Hello, World!" -REM Run the program and store the output in the result variable -for /f "delims=" %%a in ('%~1') do set result=%%a - -REM Check if the result is correct -if "%result%" == "%expected%" ( - REM If the result is correct, exit with code 0 - echo Test passed - exit /b 0 -) else ( - REM If the result is incorrect, exit with code 1 - echo Expected: %expected% - echo Actually: %result% - echo Test failed - exit /b 1 -) From a42c299cfaeadf81a227f8ab3a9c8cbde0eee8e3 Mon Sep 17 00:00:00 2001 From: Groophylifefor Date: Fri, 16 Feb 2024 15:17:37 +0300 Subject: [PATCH 2/2] feat: test case update in helloworld --- .../practice/hello-world/HelloWorldTest.bat | 95 ++++++++++++++----- 1 file changed, 71 insertions(+), 24 deletions(-) diff --git a/exercises/practice/hello-world/HelloWorldTest.bat b/exercises/practice/hello-world/HelloWorldTest.bat index 0235927..f7276be 100644 --- a/exercises/practice/hello-world/HelloWorldTest.bat +++ b/exercises/practice/hello-world/HelloWorldTest.bat @@ -1,41 +1,88 @@ @echo off REM --------------------------------------------------- -REM testThatGreeterReturnsTheCorrectGreeting +REM Hello World Unit Test REM --------------------------------------------------- -REM Initalize result variable -set "slug=HelloWorld" -set "result=" -set "expected=Hello, World!" +:Main + REM Initalize result variable + set "slug=HelloWorld" -REM Run the program and store the output in the result variable -if exist %~dp0%slug%.bat ( - REM If the file exists in the full path, run it from there - for /f "delims=" %%a in ('%~dp0%slug%.bat') do set result=%%a + CALL :Initialize -) else ( - if exist %slug%.bat ( - REM If the file exists in the wildcard search path, run it from there - for /f "delims=" %%a in ('%slug%.bat') do set result=%%a + REM -------------------- + REM Test Case Start \/\/ + REM -------------------- + set "expected=Hello, World!" + set "if_success=Test passed" + set "if_failed=Test failed: Your output have to be 'Hello, World!'" + CALL :Assert - ) else ( - REM Errorlevel = 2: The system cannot find the file specified. - REM Indicates that the file cannot be found in specified location. - echo Could not find "%~dp0%slug%.bat" or "%slug%.bat" - exit /b 2 + REM -------------------- + REM Test Case End /\/\/\ + REM -------------------- - ) -) + CALL :ResolveStatus + exit /b %errorlevel% +REM End of Main + +REM --------------------------------------------------- +REM Assert [..Parameters(up to 9)] +REM --------------------------------------------------- +GOTO :End REM Prevents the code below from being executed +:Assert +set "stdout=" + +REM Run the program and capture the output then delete the file +CALL %slug%.bat %~1 %~2 %~3 %~4 %~5 %~6 %~7 %~8 %~9 > stdout.bin 2>&1 +set /p stdout=