Sha256: b6b8ee25274e23203d327baaf5c4789c397a81b1cf3efca67af5c4da73deacf1

Contents?: true

Size: 880 Bytes

Versions: 14

Compression:

Stored size: 880 Bytes

Contents

#include <catch.hpp>
#include <leatherman/util/timer.hpp>

using namespace leatherman::util;

SCENARIO("Using Timer", "[util]") {
    SECTION("can instantiate") {
        REQUIRE_NOTHROW(Timer());
    }

    SECTION("can reset") {
        Timer t {};
        REQUIRE_NOTHROW(t.reset());
    }

    SECTION("can retrieve durations [s]") {
        Timer t {};
        auto d1_s = t.elapsed_seconds();
        auto d2_s = t.elapsed_seconds();

        REQUIRE(d1_s <= d2_s);
    }

    SECTION("can retrieve durations [ms]") {
        Timer t {};
        auto d1_ms = t.elapsed_milliseconds();
        auto d2_ms = t.elapsed_milliseconds();

        REQUIRE(d1_ms <= d2_ms);
    }

    SECTION("can retrieve durations after resetting") {
        Timer t {};
        t.reset();

        REQUIRE_NOTHROW(t.elapsed_seconds());
        REQUIRE_NOTHROW(t.elapsed_milliseconds());
    }
}

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/leatherman/util/tests/timer.cc
facter-3.12.1.cfacter.20181031 ext/facter/leatherman/util/tests/timer.cc
facter-3.11.6.cfacter.20181031 ext/facter/leatherman/util/tests/timer.cc
facter-3.12.1.cfacter.20181023 ext/facter/leatherman/util/tests/timer.cc
facter-3.11.5.cfacter.20181022 ext/facter/leatherman/util/tests/timer.cc
facter-3.12.0.cfacter.20181004 ext/facter/leatherman/util/tests/timer.cc
facter-3.12.0.cfacter.20181001 ext/facter/leatherman/util/tests/timer.cc
facter-3.12.0.cfacter.20180918 ext/facter/leatherman/util/tests/timer.cc
facter-3.11.4.cfacter.20180821 ext/facter/leatherman/util/tests/timer.cc
facter-3.11.3.cfacter.20180716 ext/facter/leatherman/util/tests/timer.cc
facter-3.11.2.cfacter.20180612 ext/facter/leatherman/util/tests/timer.cc
facter-3.11.2.cfacter.20180606 ext/facter/leatherman/util/tests/timer.cc
facter-3.11.0.cfacter.20180319 ext/facter/leatherman/util/tests/timer.cc
cfacter-3.11.0.rc.20180314 ext/facter/leatherman/util/tests/timer.cc