1 | #include <string.h> |
2 | |
3 | #include <iostream> |
4 | |
5 | #include "benchmark/benchmark.h" |
6 | |
7 | // Tests that the user specified verbosity level can be get. |
8 | static void BM_Verbosity(benchmark::State& state) { |
9 | for (auto _ : state) { |
10 | } |
11 | } |
12 | BENCHMARK(BM_Verbosity); |
13 | |
14 | int main(int argc, char** argv) { |
15 | const int32_t flagv = 42; |
16 | |
17 | // Verify that argv specify --v=42. |
18 | bool found = false; |
19 | for (int i = 0; i < argc; ++i) { |
20 | if (strcmp(s1: "--v=42" , s2: argv[i]) == 0) { |
21 | found = true; |
22 | break; |
23 | } |
24 | } |
25 | if (!found) { |
26 | std::cerr << "This test requires '--v=42' to be passed as a command-line " |
27 | << "argument.\n" ; |
28 | return 1; |
29 | } |
30 | |
31 | benchmark::Initialize(argc: &argc, argv); |
32 | |
33 | // Check that the current flag value is reported accurately via the |
34 | // GetBenchmarkVerbosity() function. |
35 | if (flagv != benchmark::GetBenchmarkVerbosity()) { |
36 | std::cerr |
37 | << "Seeing different value for flags. GetBenchmarkVerbosity() returns [" |
38 | << benchmark::GetBenchmarkVerbosity() << "] expected flag=[" << flagv |
39 | << "]\n" ; |
40 | return 1; |
41 | } |
42 | return 0; |
43 | } |
44 | |