Skip to content

Instantly share code, notes, and snippets.

@HirbodBehnam
Created February 28, 2021 13:31
Show Gist options
  • Save HirbodBehnam/40b00ab211e32d23484f88057a5b9c4e to your computer and use it in GitHub Desktop.
Save HirbodBehnam/40b00ab211e32d23484f88057a5b9c4e to your computer and use it in GitHub Desktop.
Some scripts for creating test cases for java applications.
@echo off
setlocal EnableDelayedExpansion
javac %1
set /A Counter=1
set ClassName=%1
set ClassName=%ClassName:~0,-5%
:loop
set "i=in%Counter%.txt"
set "o=out%Counter%.txt"
if exist %i% (
java "%ClassName%" < "%i%" > tmp.txt
fc tmp.txt "%o%"
del tmp.txt
set /A Counter=Counter+1
goto loop
) else (
echo Done
)
#!/bin/bash
COUNTER=1
javac "$1"
JAVA_FILE="$1"
CLASS_NAME=${JAVA_FILE:0:-5}
while :
do
[ ! -f "in$COUNTER.txt" ] && break
echo "Checking in$COUNTER.txt..."
diff <(cat "out$COUNTER.txt") <(java "$CLASS_NAME" < "in$COUNTER.txt")
COUNTER=$((COUNTER+1))
done
@echo off
setlocal EnableDelayedExpansion
javac %1
set /A Counter=1
set ClassName=%1
set ClassName=%ClassName:~0,-5%
:loop
set "i=in%Counter%.txt"
set "o=out%Counter%.txt"
if exist %i% (
java %ClassName% < %i% > %o%
set /A Counter=Counter+1
goto loop
) else (
echo Done
)
#!/bin/bash
COUNTER=1
javac "$1"
JAVA_FILE="$1"
CLASS_NAME=${JAVA_FILE:0:-5}
while :
do
[ ! -f "in$COUNTER.txt" ] && break
echo "Generating in$COUNTER.txt..."
java "$CLASS_NAME" < "in$COUNTER.txt" > "out$COUNTER.txt"
COUNTER=$((COUNTER+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment