1 |
#include "cute/cute.h"
|
2 |
#include "cute/cute_suite.h"
|
3 |
|
4 |
#include "../interface/EventCounter.h"
|
5 |
|
6 |
static const unsigned int dimension1 = 4;
|
7 |
static const unsigned int dimension2 = 2;
|
8 |
static const unsigned int dimension3 = 5;
|
9 |
|
10 |
struct TestEventCounter {
|
11 |
|
12 |
public:
|
13 |
TestEventCounter() {
|
14 |
}
|
15 |
|
16 |
void testStandardCounterConstructor() {
|
17 |
Counter standardCounter = Counter();
|
18 |
ASSERT_EQUAL(0, standardCounter.getSizeOfFirstDimension());
|
19 |
ASSERT_EQUAL(0, standardCounter.getSizeOfSecondDimension());
|
20 |
ASSERT_EQUAL(0, standardCounter.getSizeOfThirdDimension());
|
21 |
}
|
22 |
|
23 |
void testCounterConstructor() {
|
24 |
Counter counter = Counter(dimension1, dimension2, dimension3);
|
25 |
ASSERT_EQUAL(dimension1, counter.getSizeOfFirstDimension());
|
26 |
ASSERT_EQUAL(dimension2, counter.getSizeOfSecondDimension());
|
27 |
ASSERT_EQUAL(dimension3, counter.getSizeOfThirdDimension());
|
28 |
}
|
29 |
void testIncereaseCoutner() {
|
30 |
Counter counter = Counter(dimension1, dimension2, dimension3);
|
31 |
counter.increase(0, 0, 0, 2.4);
|
32 |
ASSERT_EQUAL(1, counter.getEntries(0, 0, 0));
|
33 |
}
|
34 |
|
35 |
void testIncreaseWeightedCounter() {
|
36 |
Counter counter = Counter(dimension1, dimension2, dimension3);
|
37 |
counter.increase(0, 0, 0, 2.4);
|
38 |
ASSERT_EQUAL_DELTA(2.4, counter.getWeightedEntries(0, 0, 0), 0.1);
|
39 |
}
|
40 |
};
|
41 |
|
42 |
extern cute::suite make_suite_TestEventCounter() {
|
43 |
cute::suite s;
|
44 |
|
45 |
s.push_back(CUTE_SMEMFUN(TestEventCounter, testStandardCounterConstructor));
|
46 |
s.push_back(CUTE_SMEMFUN(TestEventCounter, testCounterConstructor));
|
47 |
s.push_back(CUTE_SMEMFUN(TestEventCounter, testIncereaseCoutner));
|
48 |
s.push_back(CUTE_SMEMFUN(TestEventCounter, testIncreaseWeightedCounter));
|
49 |
|
50 |
return s;
|
51 |
}
|