/******************************************************************************
* Copyright (c) 2000-2019 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
******************************************************************************/
///////////////////////////////////////////////////////////////////////////////
//
//  File:               TCCMaths_Example.ttcn
//  Description:        TCC Useful testcases: Maths testcases.
//  Rev:                R36B
//  Prodnr:             CNL 113 472
//  Updated:            2007-12-09
//  Contact:            http://ttcn.ericsson.se
///////////////////////////////////////////////

module TCCMaths_Example
{

import from TCCMaths_Functions all;
import from TCCMaths_GenericTypes all;

modulepar float LIMIT := 0.01;

type component Maths_CT {
  // math
  var float tmpFloat;
  var integer tmpInt;
  var float sum;
  var float resFZero := 0.0;

  // integer
  var IntegerList ilist1 := { 1, 2, 3, 4, 5};
  var IntegerList ilist2 := { 6, 7, 8, 9, 10};
  var IntegerList ilist_one_value := {42};
  var IntegerList ilist_empty := {};
  var IntegerList ilist_unbound;
  var IntegerList ires;

  var IntegerList maxIL1 := {5, 4};
  var IntegerList minIL1 := {1, 0};
  var IntegerList errIL := {0, -1};
  var float avgIL1 := 3.0;
  var IntegerList updIL1 := { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  var float stdIL1 := 1.581139;
  var float stdILL1 := 1.581139;

  // float
  var FloatList flist1 := { 1.0, 2.0, 3.0, 4.0, 5.0};
  var FloatList flist2 := { 6.0, 7.0, 8.0, 9.0, 10.0};
  var FloatList flist_one_value := {42.0};
  var FloatList flist_empty := {};
  var FloatList flist_unbound;
  var FloatList fres;

  var FloatList maxFL1 := {5.0, 4.0};
  var FloatList minFL1 := {1.0, 0.0};
  var FloatList errFL := {0.0, -1.0};
  var float avgFL1 := 3.0;
  var FloatList updFL1 := { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
  var float stdFL1 := 1.58;
  var float stdFLL1 := 1.58;

  // sin/cos
  var float freq := 10.0;
  var float alti := 5.0;
  var float startval := 0.0;
  var float step := 0.37;
  var integer len := 5;

  var FloatList sin1 := {0.0, -4.755283, 2.938926, 2.938926, -4.755283};
  var FloatList cos1 := {5.0, -1.545085, -4.045085, 4.045085, 1.545085};
};

//////////////////////////////////////////////////////////////
// Maths testcases
//////////////////////////////////////////////////////////////

//type record of integer BLABLA;

// test f_maxIL testcase
testcase f_test_maxIL() runs on Maths_CT
{
  // Note this is (of course erroneous situation) - TYPE MISMATCH
  // IntegerList type in TCCMaths_GenericTypes or dircet valuelist
  // e.g. {1, 2, ....} shall be used

  //var BLABLA vv := {1, 2, 3, 4, 5};
  //ires := f_maxIL(vv);

  log(" ----------- f_maxIL ----------- ");
  log("Original integer list: ", ilist1);
  ires := f_maxIL(ilist1);
  log("MaxIL (maxVal, maxIdx): ", ires);

  if (ires == maxIL1) { setverdict(pass); }
  else { setverdict(fail); }

  log("Max of empty integer list");
  ires := f_maxIL(ilist_empty);
  log("MaxIL (maxVal, maxIdx): ", ires);

  if (ires == errIL) { setverdict(pass); }
  else { setverdict(fail); }

  log("Max of unbound integer list");
  ires := f_maxIL(ilist_unbound);
  log("MaxIL (maxVal, maxIdx): ", ires);

  if (ires == errIL) { setverdict(pass); }
  else { setverdict(fail); }
}

// test f_minIL testcase
testcase f_test_minIL() runs on Maths_CT
{
  // Note this is (of course erroneous situation) - TYPE MISMATCH
  // IntegerList type in TCCMaths_GenericTypes or dircet valuelist
  // e.g. {1, 2, ....} shall be used

  //var BLABLA vv := {1, 2, 3, 4, 5};
  //ires := f_minIL(vv);

  log(" ----------- f_minIL ----------- ");
  log("Original integer list: ", ilist1);
  ires := f_minIL(ilist1);
  log("MinIL (minVal, minIdx): ", ires);

  if (ires == minIL1) { setverdict(pass); }
  else { setverdict(fail); }

  log("Min of empty integer list");
  ires := f_minIL(ilist_empty);
  log("MinIL (minVal, minIdx): ", ires);

  if (ires == errIL) { setverdict(pass); }
  else { setverdict(fail); }

  log("Min of unbound integer list");
  ires := f_minIL(ilist_unbound);
  log("MinIL (minVal, minIdx): ", ires);

  if (ires == errIL) { setverdict(pass); }
  else { setverdict(fail); }
}

// test f_averageIL testcase
testcase f_test_averageIL() runs on Maths_CT
{
  // Note this is (of course erroneous situation) - TYPE MISMATCH
  // IntegerList type in TCCMaths_GenericTypes or dircet valuelist
  // e.g. {1, 2, ....} shall be used

  //var BLABLA vv := {1, 2, 3, 4, 5};
  //ires := f_averageIL(vv);

  log(" ----------- f_averageIL ----------- ");
  log("Original integer list: ", ilist1);
  tmpFloat := f_averageIL(ilist1);
  log("AverageIL: ", tmpFloat);

  if (tmpFloat == avgIL1) { setverdict(pass); }
  else { setverdict(fail); }

  log("Average for one value list");
  tmpFloat := f_averageIL(ilist_one_value);
  log("AverageIL: ", tmpFloat);
  if (tmpFloat == int2float(ilist_one_value[0])) { setverdict(pass); }
  else { setverdict(fail); }

  log("Average for empty list");
  tmpFloat := f_averageIL(ilist_empty);
  log("AverageIL: ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }

  log("Average for unbound list");
  tmpFloat := f_averageIL(ilist_unbound);
  log("AverageIL: ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }
}

// test f_averageIL testcase
testcase f_test_updateIL() runs on Maths_CT
{
  // Note this is (of course erroneous situation) - TYPE MISMATCH
  // IntegerList type in TCCMaths_GenericTypes or dircet valuelist
  // e.g. {1, 2, ....} shall be used

  //var BLABLA vv1 := {1, 2, 3, 4, 5};
  //var BLABLA vv2 := {1, 2, 3, 4, 5};
  //f_updateIL(vv1, vv2)

  log(" ----------- f_updateIL ----------- ");
  log("Original integer lists: ", ilist1, " and ", ilist2);
  ires := ilist1;
  f_updateIL(ires, ilist2)
  log("Updated list: ", ires);

  if (ires == updIL1) { setverdict(pass); }
  else { setverdict(fail); }
}

// test f_averageIL testcase
testcase f_test_stdIL() runs on Maths_CT
{
  // Note this is (of course erroneous situation) - TYPE MISMATCH
  // IntegerList type in TCCMaths_GenericTypes or dircet valuelist
  // e.g. {1, 2, ....} shall be used

  //var BLABLA vv := {1, 2, 3, 4, 5};
  //ires := f_stdIL(vv);

  log(" ----------- f_stdIL ----------- ");
  log("Original integer list: ", ilist1);
  tmpFloat := f_stdIL(ilist1);
  log("Normalized, standard derivation (IL): ", tmpFloat);

  if ((tmpFloat - stdIL1) * (tmpFloat - stdIL1) < LIMIT) {
    setverdict(pass);
  }
  else {
    setverdict(fail);
  }

  log("Normalized, standard derivation for one value list");
  tmpFloat := f_stdIL(ilist_one_value);
  log("Normalized, standard derivation (IL): ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }

  log("Normalized, standard derivation for empty list");
  tmpFloat := f_stdIL(ilist_empty);
  log("Normalized, standard derivation (IL): ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }

  log("Normalized, standard derivation for unbound list");
  tmpFloat := f_stdIL(ilist_unbound);
  log("Normalized, standard derivation (IL): ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }
}

// test f_averageILL testcase
testcase f_test_stdILL() runs on Maths_CT
{
  // Note this is (of course erroneous situation) - TYPE MISMATCH
  // IntegerList type in TCCMaths_GenericTypes or dircet valuelist
  // e.g. {1, 2, ....} shall be used

  //var BLABLA vv := {1, 2, 3, 4, 5};
  //ires := f_stdIL(vv);

  log(" ----------- f_stdILL ----------- ");
  log("Original integer list: ", ilist1);
  tmpFloat := f_stdILL(ilist1, f_averageIL(ilist1));
  log("Normalized, standard derivation (ILL): ", tmpFloat);

  if ((tmpFloat - stdILL1) * (tmpFloat - stdILL1) < LIMIT) {
    setverdict(pass);
  }
  else {
    setverdict(fail);
  }

  log("Normalized, standard derivation for one value list");
  tmpFloat := f_stdILL(ilist_one_value, f_averageIL(ilist1));
  log("Normalized, standard derivation (IL): ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }

  log("Normalized, standard derivation for empty list");
  tmpFloat := f_stdILL(ilist_empty, f_averageIL(ilist1));
  log("Normalized, standard derivation (IL): ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }

  log("Normalized, standard derivation for unbound list");
  tmpFloat := f_stdILL(ilist_unbound, f_averageIL(ilist1));
  log("Normalized, standard derivation (IL): ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }
}

// test f_maxIL testcase
testcase f_test_maxFL() runs on Maths_CT
{
  // Note this is (of course erroneous situation) - TYPE MISMATCH
  // IntegerList type in TCCMaths_GenericTypes or dircet valuelist
  // e.g. {1.0, 2.0, ....} shall be used

  //var BLABLA vv := {1.0, 2.0, 3.0, 4.0, 5.0};
  //ires := f_maxFL(vv);

  log(" ----------- f_maxFL ----------- ");
  log("Original float list: ", flist1);
  fres := f_maxFL(flist1);
  log("MaxFL (maxVal, maxIdx): ", fres);

  if (fres == maxFL1) { setverdict(pass); }
  else { setverdict(fail); }

  log("Max of empty float list");
  fres := f_maxFL(flist_empty);
  log("MaxFL (maxVal, maxIdx): ", fres);

  if (fres == errFL) { setverdict(pass); }
  else { setverdict(fail); }

  log("Max of unbound float list");
  fres := f_maxFL(flist_unbound);
  log("MaxFL (maxVal, maxIdx): ", fres);

  if (fres == errFL) { setverdict(pass); }
  else { setverdict(fail); }
}

// test f_minIL testcase
testcase f_test_minFL() runs on Maths_CT
{
  // Note this is (of course erroneous situation) - TYPE MISMATCH
  // IntegerList type in TCCMaths_GenericTypes or dircet valuelist
  // e.g. {1.0, 2.0, ....} shall be used

  //var BLABLA vv := {1.0, 2.0, 3.0, 4.0, 5.0};
  //ires := f_minFL(vv);

  log(" ----------- f_minFL ----------- ");
  log("Original float list: ", flist1);
  fres := f_minFL(flist1);
  log("MinFL (minVal, minIdx): ", fres);

  if (fres == minFL1) { setverdict(pass); }
  else { setverdict(fail); }

  log("Min of empty float list");
  fres := f_minFL(flist_empty);
  log("MinFL (minVal, minIdx): ", fres);

  if (fres == errFL) { setverdict(pass); }
  else { setverdict(fail); }

  log("Min of unbound float list");
  fres := f_minFL(flist_unbound);
  log("MinFL (minVal, minIdx): ", fres);

  if (fres == errFL) { setverdict(pass); }
  else { setverdict(fail); }
}

// test f_averageIL testcase
testcase f_test_averageFL() runs on Maths_CT
{
  // Note this is (of course erroneous situation) - TYPE MISMATCH
  // IntegerList type in TCCMaths_GenericTypes or dircet valuelist
  // e.g. {1.0, 2.0, ....} shall be used

  //var BLABLA vv := {1.0, 2.0, 3.0, 4.0, 5.0};
  //ires := f_averageFL(vv);

  log(" ----------- f_averageFL ----------- ");
  log("Original float list: ", flist1);
  tmpFloat := f_averageFL(flist1);
  log("AverageFL: ", tmpFloat);

  if (tmpFloat == avgFL1) { setverdict(pass); }
  else { setverdict(fail); }

  log("Average for one value list");
  tmpFloat := f_averageFL(flist_one_value);
  log("AverageFL: ", tmpFloat);
  if (tmpFloat == flist_one_value[0]) { setverdict(pass); }
  else { setverdict(fail); }

  log("Average for empty list");
  tmpFloat := f_averageFL(flist_empty);
  log("AverageFL: ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }

  log("Average for unbound list");
  tmpFloat := f_averageFL(flist_unbound);
  log("AverageFL: ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }
}

// test f_averageIL testcase
testcase f_test_updateFL() runs on Maths_CT
{
  // Note this is (of course erroneous situation) - TYPE MISMATCH
  // IntegerList type in TCCMaths_GenericTypes or dircet valuelist
  // e.g. {1.0, 2.0, ....} shall be used

  //var BLABLA vv1.0 := {1.0, 2.0, 3.0, 4.0, 5.0};
  //var BLABLA vv2.0 := {1.0, 2.0, 3.0, 4.0, 5.0};
  //f_updateFL(vv1.0, vv2.0)

  log(" ----------- f_updateFL ----------- ");
  log("Original float lists: ", flist1, " and ", flist2);
  fres := flist1;
  f_updateFL(fres, flist2)
  log("Updated list: ", fres);

  if (fres == updFL1) { setverdict(pass); }
  else { setverdict(fail); }
}

// test f_averageIL testcase
testcase f_test_stdFL() runs on Maths_CT
{
  // Note this is (of course erroneous situation) - TYPE MISMATCH
  // IntegerList type in TCCMaths_GenericTypes or dircet valuelist
  // e.g. {1.0, 2.0, ....} shall be used

  //var BLABLA vv := {1.0, 2.0, 3.0, 4.0, 5.0};
  //ires := f_stdFL(vv);

  log(" ----------- f_stdFL ----------- ");
  log("Original float list: ", flist1);
  tmpFloat := f_stdFL(flist1);
  log("Normalized, standard derivation (FL): ", tmpFloat);

  if ((tmpFloat - stdFL1) * (tmpFloat - stdFL1) < LIMIT) {
    setverdict(pass);
  }
  else {
    setverdict(fail);
  }

  log("Normalized, standard derivation for one value list");
  tmpFloat := f_stdFL(flist_one_value);
  log("Normalized, standard derivation (FL): ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }

  log("Normalized, standard derivation for empty list");
  tmpFloat := f_stdFL(flist_empty);
  log("Normalized, standard derivation (FL): ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }

  log("Normalized, standard derivation for unbound list");
  tmpFloat := f_stdFL(flist_unbound);
  log("Normalized, standard derivation (FL): ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }
}

// test f_averageFLL testcase
testcase f_test_stdFLL() runs on Maths_CT
{
  // Note this is (of course erroneous situation) - TYPE MISMATCH
  // IntegerList type in TCCMaths_GenericTypes or dircet valuelist
  // e.g. {1.0, 2.0, ....} shall be used

  //var BLABLA vv := {1.0, 2.0, 3.0, 4.0, 5.0};
  //ires := f_stdFL(vv);

  log(" ----------- f_stdFLL ----------- ");
  log("Original float list: ", flist1);
  tmpFloat := f_stdFLL(flist1, f_averageFL(flist1));
  log("Normalized, standard derivation (FLL): ", tmpFloat);

  if ((tmpFloat - stdFLL1) * (tmpFloat - stdFLL1) < LIMIT) {
    setverdict(pass);
  }
  else {
    setverdict(fail);

  log("Normalized, standard derivation for one value list");
  tmpFloat := f_stdFLL(flist_one_value, f_averageFL(flist1));
  log("Normalized, standard derivation (FL): ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }

  log("Normalized, standard derivation for empty list");
  tmpFloat := f_stdFLL(flist_empty, f_averageFL(flist1));
  log("Normalized, standard derivation (FL): ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }

  log("Normalized, standard derivation for unbound list");
  tmpFloat := f_stdFLL(flist_unbound, f_averageFL(flist1));
  log("Normalized, standard derivation (FL): ", tmpFloat);
  if (tmpFloat == resFZero) { setverdict(pass); }
  else { setverdict(fail); }
  }
}

// test f_sin testcase
testcase f_test_sinVL() runs on Maths_CT
{
  log(" ----------- f_sinVL ----------- ");
  log("SINUS (Frequency: ", freq,
    ", altitude: ", alti,
    ", startval: ", startval,
    ", step: ", step,
    ", return length: ", len, "):");

  fres := f_sinVL(freq, alti, startval, len, step);
  log("Sinus values returned: ", fres);

  // check
  sum := 0.0;
  for (var integer i := 0; i < len; i := i + 1)
  {
    tmpFloat := fres[i] - sin1[i];
    sum := sum + tmpFloat * tmpFloat;
  }
  if (sum < LIMIT) { setverdict(pass); }
  else { setverdict(fail); }
}

// test f_cos testcase
testcase f_test_cosVL() runs on Maths_CT
{
  log(" ----------- f_cosVL ----------- ");
  log("COSINUS (Frequency: ", freq,
    ", altitude: ", alti,
    ", startval: ", startval,
    ", step: ", step,
    ", return length: ", len, "):");

  fres := f_cosVL(freq, alti, startval, len, step);
  log("Cosinus values returned: ", fres);

  // check
  sum := 0.0;
  for (var integer i := 0; i < len; i := i + 1)
  {
    tmpFloat := fres[i] - cos1[i];
    sum := sum + tmpFloat * tmpFloat;
  }
  if (sum < LIMIT) { setverdict(pass); }
  else { setverdict(fail); }
}

// test function pi
testcase f_test_pi() runs on Maths_CT
{
  log(" ----------- f_pi ----------- ");

  log ("PI value: ", pi);

  setverdict(pass);
}

testcase f_test_sin() runs on Maths_CT
{
  log(" ----------- f_sin ----------- ");

  tmpFloat := f_sin(3.1415926535 / 2.0);
  log("Sine of PI/2: ", tmpFloat);

  tmpFloat := tmpFloat - 1.0;
  if (tmpFloat * tmpFloat < LIMIT)  { setverdict(pass); }
  else { setverdict(fail); }
}

testcase f_test_cos() runs on Maths_CT
{
  log(" ----------- f_cos ----------- ");

  tmpFloat := f_cos(3.1415926535 / 2.0);
  log("Cosine of PI/2: ", tmpFloat);

  if (tmpFloat * tmpFloat < LIMIT)  { setverdict(pass); }
  else { setverdict(fail); }
}

testcase f_test_asin() runs on Maths_CT
{
  log(" ----------- f_asin ----------- ");

  tmpFloat := f_asin(1.0);
  log("Arc sine of 1.0: ", tmpFloat);

  tmpFloat := tmpFloat - 3.1415926535 / 2.0;
  if (tmpFloat * tmpFloat < LIMIT )  {
    setverdict(pass);
  }
  else { setverdict(fail); }
}

testcase f_test_acos() runs on Maths_CT
{
  log(" ----------- f_acos ----------- ");

  tmpFloat := f_acos(0.0);
  log("Arc cosine of 0.0: ", tmpFloat);

  tmpFloat := tmpFloat - 3.1415926535 / 2.0;
  if (tmpFloat * tmpFloat < LIMIT)  {
    setverdict(pass);
  }
  else { setverdict(fail); }
}

testcase f_test_powFF() runs on Maths_CT
{
  log(" ----------- f_powFF ----------- ");

  tmpFloat := f_powFF(2.0, 3.0);
  log("Raise 2.0 to power 3.0: ", tmpFloat);

  tmpFloat := tmpFloat - 8.0;
  if ( tmpFloat * tmpFloat < LIMIT) {
    setverdict(pass);
  }
  else { setverdict(fail); }
}

testcase f_test_powII() runs on Maths_CT
{
  log(" ----------- f_powII ----------- ");

  tmpInt := f_powII(2, 3);
  log("Raise 2 to power 3: ", tmpInt);

  if ( tmpInt == 8) {
    setverdict(pass);
  }
  else { setverdict(fail); }
}

testcase f_test_powIF() runs on Maths_CT
{
  log(" ----------- f_powIF ----------- ");

  tmpFloat := f_powIF(2, 3.0);
  log("Raise 2 to power 3.0: ", tmpFloat);

  tmpFloat := tmpFloat - 8.0;
  if ( tmpFloat * tmpFloat < LIMIT) {
    setverdict(pass);
  }
  else { setverdict(fail); }
}

testcase f_test_powFI() runs on Maths_CT
{
  log(" ----------- f_powFI ----------- ");

  tmpFloat := f_powFI(2.0, 3);
  log("Raise 2.0 to power 3: ", tmpFloat);

  tmpFloat := tmpFloat - 8.0;
  if ( tmpFloat * tmpFloat < LIMIT) {
    setverdict(pass);
  }
  else { setverdict(fail); }
}

testcase f_test_powFF_cubicRootOfTwo() runs on Maths_CT
{
  log(" ----------- f_powFF (Cubic root) ----------- ");

  tmpFloat := f_powFF(2.0, 1.0/3.0);
  log("Raise 2.0 to power 0.3333: ", tmpFloat);

  tmpFloat := tmpFloat - 1.2599215;
  if ( tmpFloat * tmpFloat < LIMIT) {
    setverdict(pass);
  }
  else { setverdict(fail); }
}

testcase f_test_sqrF() runs on Maths_CT
{
  log(" ----------- f_sqrF ----------- ");

  tmpFloat := f_sqrF(2.0);
  log("Square of 2.0: ", tmpFloat);

  tmpFloat := tmpFloat - 4.0;
  if ( tmpFloat * tmpFloat < LIMIT) {
    setverdict(pass);
  }
  else { setverdict(fail); }
}

testcase f_test_sqrI() runs on Maths_CT
{
  log(" ----------- f_sqrI ----------- ");

  tmpInt := f_sqrI(2);
  log("Square of 2: ", tmpInt);

  if ( tmpInt == 4) {
    setverdict(pass);
  }
  else { setverdict(fail); }
}

testcase f_test_sqrtF() runs on Maths_CT
{
  log(" ----------- f_sqrtF ----------- ");

  tmpFloat := f_sqrtF(2.0);
  log("Square root of 2.0: ", tmpFloat);

  tmpFloat := tmpFloat - 1.4142145;
  if ( tmpFloat * tmpFloat < LIMIT) {
    setverdict(pass);
  }
  else { setverdict(fail); }
}

testcase f_test_sqrtI() runs on Maths_CT
{
  log(" ----------- f_sqrtI ----------- ");

  tmpFloat := f_sqrtI(2);
  log("Square root of 2: ", tmpFloat);

  tmpFloat := tmpFloat - 1.4142145;
  if ( tmpFloat * tmpFloat < LIMIT) {
    setverdict(pass);
  }
  else { setverdict(fail); }
}

testcase f_test_ceil() runs on Maths_CT
{
  log(" ----------- f_ceil ----------- ");

  tmpInt := f_ceil(3.1);
  log("ceil of 3.1: ", tmpInt);

  if (tmpInt == 4) {
    setverdict(pass);
  }
  else { setverdict(fail); }
}

testcase f_test_floor() runs on Maths_CT
{
  log(" ----------- f_floor ----------- ");

  tmpInt := f_floor(3.1);
  log("ceil of 3.1: ", tmpInt);

  if ( tmpInt == 3) {
    setverdict(pass);
  }
  else { setverdict(fail); }
}

testcase f_test_poisson() runs on Maths_CT
{
  log(" ----------- f_poisson ----------- ");

  var float i;
  var t_Poisson_Table vl_poissonTable;
  var boolean vl_success;

  for(i:=1.0; i < 10.0; i := i + 1.0)
  {

    vl_success:=f_generate_poissonTable(i,vl_poissonTable);
    log("Poisson table Nr:",i," ,",vl_success);
    log(vl_poissonTable);

  }
  setverdict(pass);
}

testcase f_test_next_poisson() runs on Maths_CT
{
  log(" ----------- f_next_poisson ----------- ");

  var float i;
  var integer vl_nextValue;
  var t_Poisson_Table vl_poissonTable := {false,0.0,{}};
  var boolean vl_success;

  for(i:= 1.0; i < 10.0; i := i + 1.0)
  {
    vl_nextValue := f_getNext_poissonValue(i, vl_poissonTable, vl_success);

    log("Next Poisson value:",vl_nextValue," ,",vl_success);
    log(vl_poissonTable);
  }
  setverdict(pass);
}


// execute security tests
control
{
  log(" ################### MATH ################### ");

  // integer
  execute(f_test_maxIL());
  execute(f_test_minIL());
  execute(f_test_averageIL());
  execute(f_test_updateIL());
  execute(f_test_stdIL());
  execute(f_test_stdILL());

  // float
  execute(f_test_maxFL());
  execute(f_test_minFL());
  execute(f_test_averageFL());
  execute(f_test_updateFL());
  execute(f_test_stdFL());
  execute(f_test_stdFLL());

  // sinVL, cosVL
  execute(f_test_sin());
  execute(f_test_cos());

  // others
  execute(f_test_pi());
  execute(f_test_sin());
  execute(f_test_cos());
  execute(f_test_asin());
  execute(f_test_acos());
  execute(f_test_powFF());
  execute(f_test_powII());
  execute(f_test_powIF());
  execute(f_test_powFI());
  execute(f_test_powFF_cubicRootOfTwo());
  execute(f_test_sqrF());
  execute(f_test_sqrI());
  execute(f_test_sqrtF());
  execute(f_test_sqrtI());
  execute(f_test_ceil());
  execute(f_test_floor());

  //poisson
  execute(f_test_poisson());
  execute(f_test_next_poisson());
}

}
