From f0d15813cf587dd3b46103337fb0bef3e38650b8 Mon Sep 17 00:00:00 2001
From: Jan Vesely <janvesely@janvesely.net>
Date: Sun, 27 Apr 2014 19:56:02 +0200
Subject: [PATCH] add test bash script for adeterminize

---
 tests.adeterminize.sh | 103 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)
 create mode 100644 tests.adeterminize.sh

diff --git a/tests.adeterminize.sh b/tests.adeterminize.sh
new file mode 100644
index 0000000000..dd85005438
--- /dev/null
+++ b/tests.adeterminize.sh
@@ -0,0 +1,103 @@
+#!/usr/bin/env bash
+
+# -------------------- Constants --------------------
+
+ADETERMINIZE_EXECUTABLE="adeterminize"
+NFSM_TESTS_COUNT="4"
+NIDPDA_TESTS_COUNT="3"
+
+
+
+# -------------------- Functions --------------------
+
+function checkAdeterminizeExecutable
+{
+    if [ ! -f $ADETERMINIZE_EXECUTABLE ]; then
+        echo "Make sure $ADETERMINIZE_EXECUTABLE, which is necessary for running this test, exists in bin folder."
+        exit 1
+    fi
+}
+
+
+function compareTmpAutomatons
+{
+    TMP=$(./adiff.automaton tmp1.xml tmp2.xml)
+    if [ $? == 0 ]; then
+        ((SUCCESS_COUNT++))
+        echo "    Test $1: successful"
+    else
+        ((FAILED_COUNT++))
+        echo "    Test $1: FAILED"
+    fi
+    rm tmp1.xml tmp2.xml
+}
+
+
+function testFsm
+{
+    echo "FSM:"
+    for i in $(seq 1 $NFSM_TESTS_COUNT); do
+        NFSM="../examples/automaton/NFSM$i.xml"
+        DFSM="../examples/automaton/NFSM$i.DET.xml"
+        ./adeterminize --type=fsm < $NFSM > tmp1.xml
+        cp $DFSM tmp2.xml
+        compareTmpAutomatons "NFSM$i"
+    done
+}
+
+
+function testIdpda
+{
+    echo "IDPDA:"
+    for i in $(seq 1 $NIDPDA_TESTS_COUNT); do
+        NIDPDA="../examples/automaton/NIDPDA$i.xml"
+        DIDPDA="../examples/automaton/NIDPDA$i.DET.xml"
+        ./adeterminize --type=idpda < $NIDPDA > tmp1.xml
+        cp $DIDPDA tmp2.xml
+        compareTmpAutomatons "IDPDA$i"
+    done
+}
+
+
+function testVpa
+{
+    echo "VPA:"
+    echo "    Tests not implemented yet."
+}
+
+
+function testRhdpda
+{
+    echo "RHDPDA:"
+    echo "    Tests not implemented yet."
+}
+
+
+function printIntroduction
+{
+    echo "adeterminize tests:"
+    echo "-------------------------"
+}
+
+
+function printResults
+{
+    echo "-------------------------"
+    echo "Results: $SUCCESS_COUNT successful, $FAILED_COUNT failed"
+}
+
+
+
+# -------------------- Run test --------------------
+
+SUCCESS_COUNT=0
+FAILED_COUNT=0
+
+cd bin
+printIntroduction
+checkAdeterminizeExecutable
+testFsm
+testIdpda
+testVpa
+testRhdpda
+printResults
-- 
GitLab