Unverified Commit e94d1c55 authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

add function to query whether ErrorStats class has data

parent 2edad432
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ public:
    double dev() const;
    double max() const { return maxerr; }
    double idx() const { return maxidx; }
    bool has_data() const { return num > 0; }

private:
    double sum, sumsq, maxerr;
+2 −0
Original line number Diff line number Diff line
@@ -29,12 +29,14 @@ TEST(ErrorStats, test)
    ASSERT_EQ(out.str(), "Average:  5.800e-01 StdDev:  7.305e-01 MaxErr:  2.000e+00 @ item: 3.0");

    stats.reset();
    ASSERT_EQ(stats.has_data(), false);
    ASSERT_DOUBLE_EQ(stats.avg(), 0.0);
    ASSERT_DOUBLE_EQ(stats.dev(), 0.0);
    ASSERT_DOUBLE_EQ(stats.max(), 0.0);
    ASSERT_EQ(stats.idx(), -1);

    stats.add(1.0);
    ASSERT_EQ(stats.has_data(), true);
    ASSERT_DOUBLE_EQ(stats.avg(), 1.0);
    ASSERT_DOUBLE_EQ(stats.dev(), 0.0);
    ASSERT_DOUBLE_EQ(stats.max(), 1.0);