~xavi-garcia-mena/keeper/mcloud-provided-crash-test

« back to all changes in this revision

Viewing changes to tests/unit/helper/speed-test.cpp

  • Committer: Tarmac
  • Author(s): Charles Kerr
  • Date: 2016-08-18 17:55:44 UTC
  • mfrom: (91.1.2 fix-fixed-speed-test)
  • Revision ID: tarmac-20160818175544-1te9cvve7aw98f2j
Corrected fix for the speed test failures. Fixes: https://bugs.launchpad.net/bugs/1607393.

Approved by unity-api-1-bot, Xavi Garcia.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include <gtest/gtest.h>
25
25
 
 
26
#include <cmath> // std::pow()
 
27
#include <iostream>
 
28
 
26
29
 
27
30
TEST(HelperClass, PercentDone)
28
31
{
33
36
    EXPECT_EQ(n_bytes, helper.expected_size());
34
37
 
35
38
    auto n_left = n_bytes;
 
39
    static constexpr int checked_decimal_places {4};
 
40
    static const double test_multiplier = std::pow(10, checked_decimal_places);
36
41
    while (n_left > 0)
37
42
    {
38
43
        helper.record_data_transferred(1);
39
44
        --n_left;
40
 
        EXPECT_EQ(int((10*(n_bytes-n_left)/double(n_bytes))), int(10*double(helper.percent_done())));
 
45
        auto expect = std::round(test_multiplier * (n_bytes-n_left) / double(n_bytes));
 
46
        auto actual = std::round(test_multiplier * helper.percent_done());
 
47
        EXPECT_EQ(expect, actual);
41
48
    }
42
49
}
43
50