/*
  movingAverage.h ‚ÌƒeƒXƒg
  Satofumi KAMIMURA
  $Id: MovingAverageTest.cpp 286 2008-10-20 09:40:22Z satofumi $
*/

#include "MovingAverageTest.h"

CPPUNIT_TEST_SUITE_REGISTRATION(MovingAverageTest);
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(MovingAverageTest, "MovingAverageTest");


void MovingAverageTest::getAverageValueTest(void) {

  movingAverage_t ma;
  int buffer[2];
  initMovingAverage(&ma, buffer, 1);
  CPPUNIT_ASSERT_EQUAL(0, getAverageValue(&ma));
  
  setMovingAverage(&ma, 2);
  CPPUNIT_ASSERT_EQUAL(1, getAverageValue(&ma));
  
  setMovingAverage(&ma, 2);
  CPPUNIT_ASSERT_EQUAL(2, getAverageValue(&ma));

  setMovingAverage(&ma, 0);
  CPPUNIT_ASSERT_EQUAL(1, getAverageValue(&ma));

  setMovingAverage(&ma, 0);
  CPPUNIT_ASSERT_EQUAL(0, getAverageValue(&ma));
}
