1 | #include "../include/benchmark/benchmark.h" |
---|---|
2 | #include "gtest/gtest.h" |
3 | |
4 | namespace benchmark { |
5 | namespace internal { |
6 | |
7 | namespace { |
8 | |
9 | class DummyBenchmark : public Benchmark { |
10 | public: |
11 | DummyBenchmark() : Benchmark("dummy") {} |
12 | void Run(State&) override {} |
13 | }; |
14 | |
15 | TEST(DefaultTimeUnitTest, TimeUnitIsNotSet) { |
16 | DummyBenchmark benchmark; |
17 | EXPECT_EQ(benchmark.GetTimeUnit(), kNanosecond); |
18 | } |
19 | |
20 | TEST(DefaultTimeUnitTest, DefaultIsSet) { |
21 | DummyBenchmark benchmark; |
22 | EXPECT_EQ(benchmark.GetTimeUnit(), kNanosecond); |
23 | SetDefaultTimeUnit(kMillisecond); |
24 | EXPECT_EQ(benchmark.GetTimeUnit(), kMillisecond); |
25 | } |
26 | |
27 | TEST(DefaultTimeUnitTest, DefaultAndExplicitUnitIsSet) { |
28 | DummyBenchmark benchmark; |
29 | benchmark.Unit(unit: kMillisecond); |
30 | SetDefaultTimeUnit(kMicrosecond); |
31 | |
32 | EXPECT_EQ(benchmark.GetTimeUnit(), kMillisecond); |
33 | } |
34 | |
35 | } // namespace |
36 | } // namespace internal |
37 | } // namespace benchmark |
38 |