#!/bin/bash

set -e
javac doall_password.java

rm -rf ../tests
mkdir ../tests
pushd ../tests

echo "[ Generate tests ]"

java -cp ../src doall_password

echo "[ Validate tests ]"
g++ -O2 -Wall -o validate ../src/validate.cpp
for f in {0..9}{0..9} ; do
  if [ -e $f ] ; then
    echo "Test $f"
    ./validate < $f
  fi
done

echo "[ Generate answers ]"
pushd ../solutions/
javac password_sm.java
popd
for f in {00..99} ; do
  if [ -e $f ] ; then
    echo "Test $f"
    cp $f password.in
    java -cp ../solutions password_sm
    cp password.out $f.a
  fi
done

popd
