mirror of
https://gitee.com/openharmony/third_party_benchmark
synced 2024-11-27 01:22:14 +00:00
f9e826db52
Signed-off-by: CrazyRong <zzr189911@163.com>
38 lines
872 B
C++
38 lines
872 B
C++
#include "../include/benchmark/benchmark.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
namespace benchmark {
|
|
namespace internal {
|
|
|
|
namespace {
|
|
|
|
class DummyBenchmark : public Benchmark {
|
|
public:
|
|
DummyBenchmark() : Benchmark("dummy") {}
|
|
void Run(State&) override {}
|
|
};
|
|
|
|
TEST(DefaultTimeUnitTest, TimeUnitIsNotSet) {
|
|
DummyBenchmark benchmark;
|
|
EXPECT_EQ(benchmark.GetTimeUnit(), kNanosecond);
|
|
}
|
|
|
|
TEST(DefaultTimeUnitTest, DefaultIsSet) {
|
|
DummyBenchmark benchmark;
|
|
EXPECT_EQ(benchmark.GetTimeUnit(), kNanosecond);
|
|
SetDefaultTimeUnit(kMillisecond);
|
|
EXPECT_EQ(benchmark.GetTimeUnit(), kMillisecond);
|
|
}
|
|
|
|
TEST(DefaultTimeUnitTest, DefaultAndExplicitUnitIsSet) {
|
|
DummyBenchmark benchmark;
|
|
benchmark.Unit(kMillisecond);
|
|
SetDefaultTimeUnit(kMicrosecond);
|
|
|
|
EXPECT_EQ(benchmark.GetTimeUnit(), kMillisecond);
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace internal
|
|
} // namespace benchmark
|