test_Statistics.cpp 1.33 KB
Newer Older
1
/**
2
 * @file test_Statistics.cpp
3
 *
4
 * @brief Tests for Statistics header
5
6
7
8
 *
 * @author Andi Braimllari
 */

9
#include "Statistics.h"
10
11
12
13
14
15
16
17
18
19
#include "DataContainer.h"
#include "VolumeDescriptor.h"

#include "doctest/doctest.h"
#include <testHelpers.h>

using namespace elsa;
using namespace doctest;

TEST_SUITE_BEGIN("core");
20
21
// TODO do the Statistics' tests here
TEST_CASE_TEMPLATE("Statistics: Testing the metrics", TestType, float, double)
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{
    GIVEN("a DataContainer")
    {
        IndexVector_t sizeVector(2);
        sizeVector << 2, 4;
        VolumeDescriptor volDescr(sizeVector);

        DataContainer<TestType> dataCont1(volDescr);
        dataCont1 = 5;
        DataContainer<TestType> dataCont2(volDescr);
        dataCont2 = 8;

        WHEN("running the Relative Error")
        {
36
37
            Statistics statistics;

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
            long double relErr = relativeError<TestType>(dataCont1, dataCont2);
            THEN("it produces the correct result")
            {
                REQUIRE_UNARY(checkApproxEq(relErr, 3.0 / 8));
            }
        }

        WHEN("running the Peak Signal-to-Noise Ratio")
        {
            long double psnr = peakSignalToNoiseRatio<TestType>(dataCont1, dataCont2, 255);
            THEN("it produces the correct result") { REQUIRE_UNARY(checkApproxEq(psnr, 38.58837)); }
        }
    }
}

TEST_SUITE_END();