#!/bin/sh

set -e

SRCDIR="$PWD"

test_ObserverTest() {
    cd "$AUTOPKGTEST_TMP"
    cp $SRCDIR/control/src/tests/ObserverTest.hpp .
    cp $SRCDIR/control/src/tests/ObserverTest.cpp .
    cat $SRCDIR/kernel/tests-common/TestMain.cpp >> ObserverTest.cpp
    siconos -I/usr/include/siconos -lcppunit -DWRAPPER -DEMULATOR ObserverTest.cpp
    assertEquals "OK (4 tests)" "$(./ObserverTest ObserverTest | sed /^$/d | tail -n1)"
}

test_PIDTest() {
    cd "$AUTOPKGTEST_TMP"
    cp $SRCDIR/control/src/tests/PIDTest.hpp .
    cp $SRCDIR/control/src/tests/PIDTest.cpp .
    ln -s $SRCDIR/control/src/tests/PID.ref .
    cat $SRCDIR/kernel/tests-common/TestMain.cpp >> PIDTest.cpp
    siconos -I/usr/include/siconos -lcppunit -DWRAPPER -DEMULATOR PIDTest.cpp
    assertEquals "OK (2 tests)" "$(./PIDTest PIDTest | sed /^$/d | tail -n1)"
}

# some SMC tests fail
test_SMCTest() {
    cd "$AUTOPKGTEST_TMP"
    cp $SRCDIR/control/src/tests/SMCTest.hpp .
    cp $SRCDIR/control/src/tests/SMCTest.cpp .
    cat $SRCDIR/kernel/tests-common/TestMain.cpp >> SMCTest.cpp
    siconos -I/usr/include/siconos -lcppunit -DWRAPPER -DEMULATOR SMCTest.cpp
    assertEquals "OK (4 tests)" "$(./SMCTest SMCTest | sed /^$/d | tail -n1)"
}

. shunit2
