[NFC] Add libcxx python reformat SHA to .git-blame-ignore-revs
[llvm-project.git] / third-party / benchmark / test / benchmark_name_gtest.cc
blobafb401c1f5328cecf284449d99a9716dc1eea419
1 #include "benchmark/benchmark.h"
2 #include "gtest/gtest.h"
4 namespace {
6 using namespace benchmark;
7 using namespace benchmark::internal;
9 TEST(BenchmarkNameTest, Empty) {
10 const auto name = BenchmarkName();
11 EXPECT_EQ(name.str(), std::string());
14 TEST(BenchmarkNameTest, FunctionName) {
15 auto name = BenchmarkName();
16 name.function_name = "function_name";
17 EXPECT_EQ(name.str(), "function_name");
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");
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");
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");
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");
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");
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");
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");
74 } // end namespace