CS3413/Assignment1/tests/test.sh

36 lines
777 B
Bash
Raw Normal View History

2023-09-15 23:55:52 -03:00
#!/usr/bin/bash
function files() {
if [ ! -f "$1.txt" ]; then
echo "Creating $1.txt"
touch "$1.txt"
fi
if [ ! -f "$1_Expected.txt" ]; then
echo "Creating $1_Expected.txt"
touch "$1_Expected.txt"
fi
if [ ! -f "$1_Result.txt" ]; then
echo "Creating $1_Result.txt"
touch "$1_Result.txt"
fi
}
function test() {
# Check if the files exist and if not, create them
files "$1"
2023-09-16 01:32:53 -03:00
"$(pwd)"/../build/Assignment1 < "$1.txt" > "$1_Result.txt"
2023-09-15 23:55:52 -03:00
if diff -u "$1_Result.txt" "$1_Expected.txt";
then
echo "$1 test passed"
else
echo "$1 test failed"
fi
}
test "findAndReplace"
test "add"
test "delete"
test "pdf1"
test "pdf2"
test "exit"
test "deleteEmpty"