You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
872 B

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