blob: 8f8eb6d37c590641600a04221e876cd03ae3fbc7 [file] [log] [blame]
Matthdonau37be1e82022-05-17 18:59:36 +02001#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.
8static void BM_Verbosity(benchmark::State& state) {
9 for (auto _ : state) {
10 }
11}
12BENCHMARK(BM_Verbosity);
13
14int 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("--v=42", 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, 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}