#!/bin/bash
set -e

pkg=sweed

if [ "${AUTOPKGTEST_TMP}" = "" ] ; then
  AUTOPKGTEST_TMP=$(mktemp -d /tmp/${pkg}-test.XXXXXX)
  trap "rm -rf ${AUTOPKGTEST_TMP}" 0 INT QUIT ABRT PIPE TERM
fi

cd "${AUTOPKGTEST_TMP}"

function check_compare()
{
	# $1: result of the command
	# $2: value to compare result with
	if (( $(echo "$1 < $2" |bc -l) ))
	then
			exit 1
	fi
}

# Comparing values with a threshold since decimal precision maybe unreliable on different archs
echo 'Test 1'
result=`Q80_model_4_0_commandLine 25 0.5 0 0 0.3 0 0 26 2 0 5 120 0 10 ""`
echo "$result"
check_compare $result 0.1
echo "PASS"

echo 'Test 2'
result=`Q80_model_4_0_commandLine 25 0.5 0.2 0.2 0.3 0.5 0.5 26 7 0 6 120 4 10 ""`
echo "$result"
check_compare $result 0.3
echo "PASS"

