1 #include "benchmark/benchmark.h"
2 #include "gtest/gtest.h"
3
4 namespace {
5
6 using namespace benchmark;
7 using namespace benchmark::internal;
8
TEST(BenchmarkNameTest,Empty)9 TEST(BenchmarkNameTest, Empty) {
10 const auto name = BenchmarkName();
11 EXPECT_EQ(name.str(), std::string());
12 }
13
TEST(BenchmarkNameTest,FunctionName)14 TEST(BenchmarkNameTest, FunctionName) {
15 auto name = BenchmarkName();
16 name.function_name = "function_name";
17 EXPECT_EQ(name.str(), "function_name");
18 }
19
TEST(BenchmarkNameTest,FunctionNameAndArgs)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
TEST(BenchmarkNameTest,MinTime)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
TEST(BenchmarkNameTest,Iterations)35 TEST(BenchmarkNameTest, Iterations) {
36 auto name = BenchmarkName();
37 name.function_name = "function_name";
38 name.min_time = "min_time:3.4s";
39 name.iterations = "iterations:42";
40 EXPECT_EQ(name.str(), "function_name/min_time:3.4s/iterations:42");
41 }
42
TEST(BenchmarkNameTest,Repetitions)43 TEST(BenchmarkNameTest, Repetitions) {
44 auto name = BenchmarkName();
45 name.function_name = "function_name";
46 name.min_time = "min_time:3.4s";
47 name.repetitions = "repetitions:24";
48 EXPECT_EQ(name.str(), "function_name/min_time:3.4s/repetitions:24");
49 }
50
TEST(BenchmarkNameTest,TimeType)51 TEST(BenchmarkNameTest, TimeType) {
52 auto name = BenchmarkName();
53 name.function_name = "function_name";
54 name.min_time = "min_time:3.4s";
55 name.time_type = "hammer_time";
56 EXPECT_EQ(name.str(), "function_name/min_time:3.4s/hammer_time");
57 }
58
TEST(BenchmarkNameTest,Threads)59 TEST(BenchmarkNameTest, Threads) {
60 auto name = BenchmarkName();
61 name.function_name = "function_name";
62 name.min_time = "min_time:3.4s";
63 name.threads = "threads:256";
64 EXPECT_EQ(name.str(), "function_name/min_time:3.4s/threads:256");
65 }
66
TEST(BenchmarkNameTest,TestEmptyFunctionName)67 TEST(BenchmarkNameTest, TestEmptyFunctionName) {
68 auto name = BenchmarkName();
69 name.args = "first:3/second:4";
70 name.threads = "threads:22";
71 EXPECT_EQ(name.str(), "first:3/second:4/threads:22");
72 }
73
74 } // end namespace
75