aboutsummaryrefslogtreecommitdiff
path: root/Practical2/tester
diff options
context:
space:
mode:
Diffstat (limited to 'Practical2/tester')
-rw-r--r--Practical2/tester/samples/small_1.in3
-rw-r--r--Practical2/tester/samples/small_1.out2
-rw-r--r--Practical2/tester/samples/small_2.in3
-rw-r--r--Practical2/tester/samples/small_2.out2
-rwxr-xr-xPractical2/tester/test.sh31
5 files changed, 41 insertions, 0 deletions
diff --git a/Practical2/tester/samples/small_1.in b/Practical2/tester/samples/small_1.in
new file mode 100644
index 0000000..b4e65e4
--- /dev/null
+++ b/Practical2/tester/samples/small_1.in
@@ -0,0 +1,3 @@
+5 1
+10 23 43 637 45
+
diff --git a/Practical2/tester/samples/small_1.out b/Practical2/tester/samples/small_1.out
new file mode 100644
index 0000000..2a3ce5a
--- /dev/null
+++ b/Practical2/tester/samples/small_1.out
@@ -0,0 +1,2 @@
+755
+
diff --git a/Practical2/tester/samples/small_2.in b/Practical2/tester/samples/small_2.in
new file mode 100644
index 0000000..47817f7
--- /dev/null
+++ b/Practical2/tester/samples/small_2.in
@@ -0,0 +1,3 @@
+6 2
+1 1 1 1 1 1
+
diff --git a/Practical2/tester/samples/small_2.out b/Practical2/tester/samples/small_2.out
new file mode 100644
index 0000000..77ac542
--- /dev/null
+++ b/Practical2/tester/samples/small_2.out
@@ -0,0 +1,2 @@
+0
+
diff --git a/Practical2/tester/test.sh b/Practical2/tester/test.sh
new file mode 100755
index 0000000..f0f46e8
--- /dev/null
+++ b/Practical2/tester/test.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+java="/usr/lib/jvm/java-8-openjdk-amd64/bin/java"
+
+failed=0
+
+cd "$(dirname $0)/../out/production/Practical2"
+for tc in ../../../tester/samples/*.in; do
+ answer=$(cat ${tc/in/out})
+ header=$(head -n1 "$tc" | tr -d '\n')
+ echo -n "Running $(basename $tc) $(printf '%-12s' "($answer ")$(printf '%-12s' "/ $header)") ... "
+ time_start=$(($(date +%s%N)/1000000))
+ result=$(eval "cat '$tc' | /usr/lib/jvm/java-8-openjdk-amd64/bin/java nl.camilstaps.cs.Main")
+ time_end=$(($(date +%s%N)/1000000))
+ time=`expr $time_end - $time_start`
+ if [ $result != $answer ]; then
+ echo "failure ($time ms)."
+ failed=$(($failed+1))
+ else
+ echo "success ($time ms)."
+ fi
+done
+cd - >/dev/null
+
+if [ $failed -eq 0 ]; then
+ echo "All tests passed."
+elif [ $failed -eq 1 ]; then
+ echo "1 test failed."
+else
+ echo "$failed tests failed."
+fi
+