1 | #include "benchmark/benchmark.h" |
2 | #include "gtest/gtest.h" |
3 | |
4 | namespace { |
5 | |
6 | using namespace benchmark; |
7 | using namespace benchmark::internal; |
8 | |
9 | TEST(BenchmarkNameTest, Empty) { |
10 | const auto name = BenchmarkName(); |
11 | EXPECT_EQ(name.str(), std::string()); |
12 | } |
13 | |
14 | TEST(BenchmarkNameTest, FunctionName) { |
15 | auto name = BenchmarkName(); |
16 | name.function_name = "function_name" ; |
17 | EXPECT_EQ(name.str(), "function_name" ); |
18 | } |
19 | |
20 | TEST(BenchmarkNameTest, FunctionNameAndArgs) { |
21 | auto name = BenchmarkName(); |
22 | name.function_name = "function_name" ; |
23 | name.args = "some_args:3/4/5" ; |
24 | EXPECT_EQ(name.str(), "function_name/some_args:3/4/5" ); |
25 | } |
26 | |
27 | TEST(BenchmarkNameTest, MinTime) { |
28 | auto name = BenchmarkName(); |
29 | name.function_name = "function_name" ; |
30 | name.args = "some_args:3/4" ; |
31 | name.min_time = "min_time:3.4s" ; |
32 | EXPECT_EQ(name.str(), "function_name/some_args:3/4/min_time:3.4s" ); |
33 | } |
34 | |
35 | TEST(BenchmarkNameTest, MinWarmUpTime) { |
36 | auto name = BenchmarkName(); |
37 | name.function_name = "function_name" ; |
38 | name.args = "some_args:3/4" ; |
39 | name.min_warmup_time = "min_warmup_time:3.5s" ; |
40 | EXPECT_EQ(name.str(), "function_name/some_args:3/4/min_warmup_time:3.5s" ); |
41 | } |
42 | |
43 | TEST(BenchmarkNameTest, Iterations) { |
44 | auto name = BenchmarkName(); |
45 | name.function_name = "function_name" ; |
46 | name.min_time = "min_time:3.4s" ; |
47 | name.iterations = "iterations:42" ; |
48 | EXPECT_EQ(name.str(), "function_name/min_time:3.4s/iterations:42" ); |
49 | } |
50 | |
51 | TEST(BenchmarkNameTest, Repetitions) { |
52 | auto name = BenchmarkName(); |
53 | name.function_name = "function_name" ; |
54 | name.min_time = "min_time:3.4s" ; |
55 | name.repetitions = "repetitions:24" ; |
56 | EXPECT_EQ(name.str(), "function_name/min_time:3.4s/repetitions:24" ); |
57 | } |
58 | |
59 | TEST(BenchmarkNameTest, TimeType) { |
60 | auto name = BenchmarkName(); |
61 | name.function_name = "function_name" ; |
62 | name.min_time = "min_time:3.4s" ; |
63 | name.time_type = "hammer_time" ; |
64 | EXPECT_EQ(name.str(), "function_name/min_time:3.4s/hammer_time" ); |
65 | } |
66 | |
67 | TEST(BenchmarkNameTest, Threads) { |
68 | auto name = BenchmarkName(); |
69 | name.function_name = "function_name" ; |
70 | name.min_time = "min_time:3.4s" ; |
71 | name.threads = "threads:256" ; |
72 | EXPECT_EQ(name.str(), "function_name/min_time:3.4s/threads:256" ); |
73 | } |
74 | |
75 | TEST(BenchmarkNameTest, TestEmptyFunctionName) { |
76 | auto name = BenchmarkName(); |
77 | name.args = "first:3/second:4" ; |
78 | name.threads = "threads:22" ; |
79 | EXPECT_EQ(name.str(), "first:3/second:4/threads:22" ); |
80 | } |
81 | |
82 | } // end namespace |
83 | |