aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDominic Hamon <dominichamon@users.noreply.github.com>2021-11-10 16:22:31 +0000
committerGitHub <noreply@github.com>2021-11-10 16:22:31 +0000
commitc07a498924aba9983f78b8204f157c107998389d (patch)
tree573f84cec9c4bc3ad5c37587a604cc053eb62202 /test
parentfcef4fb6697c78d7b7ace62da1bf7d6e329f5b1e (diff)
downloadgoogle-benchmark-c07a498924aba9983f78b8204f157c107998389d.tar.gz
format tests with clang-format (#1282)
Diffstat (limited to 'test')
-rw-r--r--test/args_product_test.cc4
-rw-r--r--test/basic_test.cc9
-rw-r--r--test/benchmark_test.cc8
-rw-r--r--test/clobber_memory_assembly_test.cc1
-rw-r--r--test/complexity_test.cc9
-rw-r--r--test/cxx03_test.cc7
-rw-r--r--test/diagnostics_test.cc6
-rw-r--r--test/donotoptimize_assembly_test.cc8
-rw-r--r--test/donotoptimize_test.cc13
-rw-r--r--test/filter_test.cc2
-rw-r--r--test/fixture_test.cc6
-rw-r--r--test/internal_threading_test.cc1
-rw-r--r--test/map_test.cc4
-rw-r--r--test/multiple_ranges_test.cc4
-rw-r--r--test/options_test.cc7
-rw-r--r--test/output_test.h4
-rw-r--r--test/output_test_helper.cc12
-rw-r--r--test/perf_counters_gtest.cc2
-rw-r--r--test/spec_arg_test.cc8
-rw-r--r--test/string_util_gtest.cc149
-rw-r--r--test/templated_fixture_test.cc4
21 files changed, 126 insertions, 142 deletions
diff --git a/test/args_product_test.cc b/test/args_product_test.cc
index 32a75d5..d081f6f 100644
--- a/test/args_product_test.cc
+++ b/test/args_product_test.cc
@@ -1,10 +1,10 @@
-#include "benchmark/benchmark.h"
-
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
+#include "benchmark/benchmark.h"
+
class ArgsProductFixture : public ::benchmark::Fixture {
public:
ArgsProductFixture()
diff --git a/test/basic_test.cc b/test/basic_test.cc
index da59b18..3a8fd42 100644
--- a/test/basic_test.cc
+++ b/test/basic_test.cc
@@ -96,7 +96,6 @@ void BM_empty_stop_start(benchmark::State& state) {
BENCHMARK(BM_empty_stop_start);
BENCHMARK(BM_empty_stop_start)->ThreadPerCpu();
-
void BM_KeepRunning(benchmark::State& state) {
benchmark::IterationCount iter_count = 0;
assert(iter_count == state.iterations());
@@ -171,8 +170,10 @@ BENCHMARK(BM_TwoTemplateFunc<double, int>)->Arg(1);
// Ensure that StateIterator provides all the necessary typedefs required to
// instantiate std::iterator_traits.
-static_assert(std::is_same<
- typename std::iterator_traits<benchmark::State::StateIterator>::value_type,
- typename benchmark::State::StateIterator::value_type>::value, "");
+static_assert(
+ std::is_same<typename std::iterator_traits<
+ benchmark::State::StateIterator>::value_type,
+ typename benchmark::State::StateIterator::value_type>::value,
+ "");
BENCHMARK_MAIN();
diff --git a/test/benchmark_test.cc b/test/benchmark_test.cc
index c63fc31..2906cdc 100644
--- a/test/benchmark_test.cc
+++ b/test/benchmark_test.cc
@@ -93,8 +93,9 @@ static void BM_SetInsert(benchmark::State& state) {
state.SetBytesProcessed(state.iterations() * state.range(1) * sizeof(int));
}
-// Test many inserts at once to reduce the total iterations needed. Otherwise, the slower,
-// non-timed part of each iteration will make the benchmark take forever.
+// Test many inserts at once to reduce the total iterations needed. Otherwise,
+// the slower, non-timed part of each iteration will make the benchmark take
+// forever.
BENCHMARK(BM_SetInsert)->Ranges({{1 << 10, 8 << 10}, {128, 512}});
template <typename Container,
@@ -214,7 +215,8 @@ BENCHMARK_CAPTURE(BM_with_args, string_and_pair_test, std::string("abc"),
std::pair<int, double>(42, 3.8));
void BM_non_template_args(benchmark::State& state, int, double) {
- while(state.KeepRunning()) {}
+ while (state.KeepRunning()) {
+ }
}
BENCHMARK_CAPTURE(BM_non_template_args, basic_test, 0, 0);
diff --git a/test/clobber_memory_assembly_test.cc b/test/clobber_memory_assembly_test.cc
index f41911a..ab26913 100644
--- a/test/clobber_memory_assembly_test.cc
+++ b/test/clobber_memory_assembly_test.cc
@@ -9,7 +9,6 @@ extern "C" {
extern int ExternInt;
extern int ExternInt2;
extern int ExternInt3;
-
}
// CHECK-LABEL: test_basic:
diff --git a/test/complexity_test.cc b/test/complexity_test.cc
index 7407359..132d3ae 100644
--- a/test/complexity_test.cc
+++ b/test/complexity_test.cc
@@ -4,6 +4,7 @@
#include <cmath>
#include <cstdlib>
#include <vector>
+
#include "benchmark/benchmark.h"
#include "output_test.h"
@@ -65,7 +66,7 @@ int AddComplexityTest(std::string test_name, std::string big_o_test_name,
// --------------------------- Testing BigO O(1) --------------------------- //
// ========================================================================= //
-void BM_Complexity_O1(benchmark::State& state) {
+void BM_Complexity_O1(benchmark::State &state) {
for (auto _ : state) {
for (int i = 0; i < 1024; ++i) {
benchmark::DoNotOptimize(&i);
@@ -114,7 +115,7 @@ std::vector<int> ConstructRandomVector(int64_t size) {
return v;
}
-void BM_Complexity_O_N(benchmark::State& state) {
+void BM_Complexity_O_N(benchmark::State &state) {
auto v = ConstructRandomVector(state.range(0));
// Test worst case scenario (item not in vector)
const int64_t item_not_in_vector = state.range(0) * 2;
@@ -156,7 +157,7 @@ ADD_COMPLEXITY_CASES(n_test_name, big_o_n_test_name, rms_o_n_test_name,
// ------------------------- Testing BigO O(N*lgN) ------------------------- //
// ========================================================================= //
-static void BM_Complexity_O_N_log_N(benchmark::State& state) {
+static void BM_Complexity_O_N_log_N(benchmark::State &state) {
auto v = ConstructRandomVector(state.range(0));
for (auto _ : state) {
std::sort(v.begin(), v.end());
@@ -199,7 +200,7 @@ ADD_COMPLEXITY_CASES(n_lg_n_test_name, big_o_n_lg_n_test_name,
// -------- Testing formatting of Complexity with captured args ------------ //
// ========================================================================= //
-void BM_ComplexityCaptureArgs(benchmark::State& state, int n) {
+void BM_ComplexityCaptureArgs(benchmark::State &state, int n) {
for (auto _ : state) {
// This test requires a non-zero CPU time to avoid divide-by-zero
benchmark::DoNotOptimize(state.iterations());
diff --git a/test/cxx03_test.cc b/test/cxx03_test.cc
index c4c9a52..9711c1b 100644
--- a/test/cxx03_test.cc
+++ b/test/cxx03_test.cc
@@ -44,8 +44,7 @@ BENCHMARK_TEMPLATE(BM_template1, long);
BENCHMARK_TEMPLATE1(BM_template1, int);
template <class T>
-struct BM_Fixture : public ::benchmark::Fixture {
-};
+struct BM_Fixture : public ::benchmark::Fixture {};
BENCHMARK_TEMPLATE_F(BM_Fixture, BM_template1, long)(benchmark::State& state) {
BM_empty(state);
@@ -55,8 +54,8 @@ BENCHMARK_TEMPLATE1_F(BM_Fixture, BM_template2, int)(benchmark::State& state) {
}
void BM_counters(benchmark::State& state) {
- BM_empty(state);
- state.counters["Foo"] = 2;
+ BM_empty(state);
+ state.counters["Foo"] = 2;
}
BENCHMARK(BM_counters);
diff --git a/test/diagnostics_test.cc b/test/diagnostics_test.cc
index dd64a33..c54d5b0 100644
--- a/test/diagnostics_test.cc
+++ b/test/diagnostics_test.cc
@@ -26,7 +26,8 @@ void TestHandler() {
}
void try_invalid_pause_resume(benchmark::State& state) {
-#if !defined(TEST_BENCHMARK_LIBRARY_HAS_NO_ASSERTIONS) && !defined(TEST_HAS_NO_EXCEPTIONS)
+#if !defined(TEST_BENCHMARK_LIBRARY_HAS_NO_ASSERTIONS) && \
+ !defined(TEST_HAS_NO_EXCEPTIONS)
try {
state.PauseTiming();
std::abort();
@@ -57,13 +58,12 @@ void BM_diagnostic_test(benchmark::State& state) {
}
BENCHMARK(BM_diagnostic_test);
-
void BM_diagnostic_test_keep_running(benchmark::State& state) {
static bool called_once = false;
if (called_once == false) try_invalid_pause_resume(state);
- while(state.KeepRunning()) {
+ while (state.KeepRunning()) {
benchmark::DoNotOptimize(state.iterations());
}
diff --git a/test/donotoptimize_assembly_test.cc b/test/donotoptimize_assembly_test.cc
index d4b0bab..2e86a51 100644
--- a/test/donotoptimize_assembly_test.cc
+++ b/test/donotoptimize_assembly_test.cc
@@ -15,7 +15,7 @@ inline int Add42(int x) { return x + 42; }
struct NotTriviallyCopyable {
NotTriviallyCopyable();
explicit NotTriviallyCopyable(int x) : value(x) {}
- NotTriviallyCopyable(NotTriviallyCopyable const&);
+ NotTriviallyCopyable(NotTriviallyCopyable const &);
int value;
};
@@ -23,7 +23,6 @@ struct Large {
int value;
int data[2];
};
-
}
// CHECK-LABEL: test_with_rvalue:
extern "C" void test_with_rvalue() {
@@ -118,8 +117,7 @@ extern "C" int test_div_by_two(int input) {
// CHECK-LABEL: test_inc_integer:
extern "C" int test_inc_integer() {
int x = 0;
- for (int i=0; i < 5; ++i)
- benchmark::DoNotOptimize(++x);
+ for (int i = 0; i < 5; ++i) benchmark::DoNotOptimize(++x);
// CHECK: movl $1, [[DEST:.*]]
// CHECK: {{(addl \$1,|incl)}} [[DEST]]
// CHECK: {{(addl \$1,|incl)}} [[DEST]]
@@ -147,7 +145,7 @@ extern "C" void test_pointer_const_lvalue() {
// CHECK-CLANG: movq %rax, -{{[0-9]+}}(%[[REG:[a-z]+]])
// CHECK: ret
int x = 42;
- int * const xp = &x;
+ int *const xp = &x;
benchmark::DoNotOptimize(xp);
}
diff --git a/test/donotoptimize_test.cc b/test/donotoptimize_test.cc
index 2ce92d1..c321f15 100644
--- a/test/donotoptimize_test.cc
+++ b/test/donotoptimize_test.cc
@@ -1,27 +1,28 @@
-#include "benchmark/benchmark.h"
-
#include <cstdint>
+#include "benchmark/benchmark.h"
+
namespace {
#if defined(__GNUC__)
std::uint64_t double_up(const std::uint64_t x) __attribute__((const));
#endif
std::uint64_t double_up(const std::uint64_t x) { return x * 2; }
-}
+} // namespace
// Using DoNotOptimize on types like BitRef seem to cause a lot of problems
// with the inline assembly on both GCC and Clang.
struct BitRef {
int index;
- unsigned char &byte;
+ unsigned char& byte;
-public:
+ public:
static BitRef Make() {
static unsigned char arr[2] = {};
BitRef b(1, arr[0]);
return b;
}
-private:
+
+ private:
BitRef(int i, unsigned char& b) : index(i), byte(b) {}
};
diff --git a/test/filter_test.cc b/test/filter_test.cc
index 1c19891..a567de2 100644
--- a/test/filter_test.cc
+++ b/test/filter_test.cc
@@ -70,7 +70,7 @@ static void BM_FooBa(benchmark::State& state) {
}
BENCHMARK(BM_FooBa);
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
bool list_only = false;
for (int i = 0; i < argc; ++i)
list_only |= std::string(argv[i]).find("--benchmark_list_tests") !=
diff --git a/test/fixture_test.cc b/test/fixture_test.cc
index 452dd87..af650db 100644
--- a/test/fixture_test.cc
+++ b/test/fixture_test.cc
@@ -1,9 +1,9 @@
-#include "benchmark/benchmark.h"
-
#include <cassert>
#include <memory>
+#include "benchmark/benchmark.h"
+
#define FIXTURE_BECHMARK_NAME MyFixture
class FIXTURE_BECHMARK_NAME : public ::benchmark::Fixture {
@@ -27,7 +27,7 @@ class FIXTURE_BECHMARK_NAME : public ::benchmark::Fixture {
std::unique_ptr<int> data;
};
-BENCHMARK_F(FIXTURE_BECHMARK_NAME, Foo)(benchmark::State &st) {
+BENCHMARK_F(FIXTURE_BECHMARK_NAME, Foo)(benchmark::State& st) {
assert(data.get() != nullptr);
assert(*data == 42);
for (auto _ : st) {
diff --git a/test/internal_threading_test.cc b/test/internal_threading_test.cc
index 039d7c1..62b5b95 100644
--- a/test/internal_threading_test.cc
+++ b/test/internal_threading_test.cc
@@ -3,6 +3,7 @@
#include <chrono>
#include <thread>
+
#include "../src/timers.h"
#include "benchmark/benchmark.h"
#include "output_test.h"
diff --git a/test/map_test.cc b/test/map_test.cc
index 86391b3..5096134 100644
--- a/test/map_test.cc
+++ b/test/map_test.cc
@@ -1,8 +1,8 @@
-#include "benchmark/benchmark.h"
-
#include <cstdlib>
#include <map>
+#include "benchmark/benchmark.h"
+
namespace {
std::map<int, int> ConstructRandomMap(int size) {
diff --git a/test/multiple_ranges_test.cc b/test/multiple_ranges_test.cc
index 6b61f3a..8f1b962 100644
--- a/test/multiple_ranges_test.cc
+++ b/test/multiple_ranges_test.cc
@@ -1,10 +1,10 @@
-#include "benchmark/benchmark.h"
-
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
+#include "benchmark/benchmark.h"
+
class MultipleRangesFixture : public ::benchmark::Fixture {
public:
MultipleRangesFixture()
diff --git a/test/options_test.cc b/test/options_test.cc
index 9f9a786..d424d40 100644
--- a/test/options_test.cc
+++ b/test/options_test.cc
@@ -1,7 +1,8 @@
-#include "benchmark/benchmark.h"
#include <chrono>
#include <thread>
+#include "benchmark/benchmark.h"
+
#if defined(NDEBUG)
#undef NDEBUG
#endif
@@ -65,11 +66,9 @@ void BM_explicit_iteration_count(benchmark::State& state) {
// Test that the requested iteration count is respected.
assert(state.max_iterations == 42);
size_t actual_iterations = 0;
- for (auto _ : state)
- ++actual_iterations;
+ for (auto _ : state) ++actual_iterations;
assert(state.iterations() == state.max_iterations);
assert(state.iterations() == 42);
-
}
BENCHMARK(BM_explicit_iteration_count)->Iterations(42);
diff --git a/test/output_test.h b/test/output_test.h
index 3b12f37..82ae752 100644
--- a/test/output_test.h
+++ b/test/output_test.h
@@ -113,9 +113,7 @@ struct Results {
return NumIterations() * GetTime(kRealTime);
}
// get the cpu_time duration of the benchmark in seconds
- double DurationCPUTime() const {
- return NumIterations() * GetTime(kCpuTime);
- }
+ double DurationCPUTime() const { return NumIterations() * GetTime(kCpuTime); }
// get the string for a result by name, or nullptr if the name
// is not found
diff --git a/test/output_test_helper.cc b/test/output_test_helper.cc
index 871e6de..b7f06f5 100644
--- a/test/output_test_helper.cc
+++ b/test/output_test_helper.cc
@@ -317,9 +317,7 @@ int Results::NumThreads() const {
return num;
}
-double Results::NumIterations() const {
- return GetAs<double>("iterations");
-}
+double Results::NumIterations() const { return GetAs<double>("iterations"); }
double Results::GetTime(BenchmarkTime which) const {
BM_CHECK(which == kCpuTime || which == kRealTime);
@@ -468,9 +466,8 @@ static char RandomHexChar() {
static std::string GetRandomFileName() {
std::string model = "test.%%%%%%";
- for (auto & ch : model) {
- if (ch == '%')
- ch = RandomHexChar();
+ for (auto& ch : model) {
+ if (ch == '%') ch = RandomHexChar();
}
return model;
}
@@ -487,8 +484,7 @@ static std::string GetTempFileName() {
int retries = 3;
while (--retries) {
std::string name = GetRandomFileName();
- if (!FileExists(name))
- return name;
+ if (!FileExists(name)) return name;
}
std::cerr << "Failed to create unique temporary file name" << std::endl;
std::abort();
diff --git a/test/perf_counters_gtest.cc b/test/perf_counters_gtest.cc
index ddeddf4..3eac624 100644
--- a/test/perf_counters_gtest.cc
+++ b/test/perf_counters_gtest.cc
@@ -5,7 +5,7 @@
#ifndef GTEST_SKIP
struct MsgHandler {
- void operator=(std::ostream&){}
+ void operator=(std::ostream&) {}
};
#define GTEST_SKIP() return MsgHandler() = std::cout
#endif
diff --git a/test/spec_arg_test.cc b/test/spec_arg_test.cc
index 624f17f..043db1b 100644
--- a/test/spec_arg_test.cc
+++ b/test/spec_arg_test.cc
@@ -81,16 +81,14 @@ int main(int argc, char** argv) {
TestReporter test_reporter;
const char* const spec = "BM_Chosen";
const size_t returned_count =
- benchmark::RunSpecifiedBenchmarks(&test_reporter,
- spec);
+ benchmark::RunSpecifiedBenchmarks(&test_reporter, spec);
assert(returned_count == 1);
const std::vector<std::string> matched_functions =
test_reporter.GetMatchedFunctions();
assert(matched_functions.size() == 1);
if (strcmp(spec, matched_functions.front().c_str()) != 0) {
- std::cerr
- << "Expected benchmark [" << spec << "] to run, but got ["
- << matched_functions.front() << "]\n";
+ std::cerr << "Expected benchmark [" << spec << "] to run, but got ["
+ << matched_functions.front() << "]\n";
return 2;
}
return 0;
diff --git a/test/string_util_gtest.cc b/test/string_util_gtest.cc
index c7061b4..698f2d4 100644
--- a/test/string_util_gtest.cc
+++ b/test/string_util_gtest.cc
@@ -2,8 +2,8 @@
// statistics_test - Unit tests for src/statistics.cc
//===---------------------------------------------------------------------===//
-#include "../src/string_util.h"
#include "../src/internal_macros.h"
+#include "../src/string_util.h"
#include "gtest/gtest.h"
namespace {
@@ -32,7 +32,8 @@ TEST(StringUtilTest, stoul) {
#elif ULONG_MAX == 0xFFFFFFFFFFFFFFFFul
{
size_t pos = 0;
- EXPECT_EQ(0xFFFFFFFFFFFFFFFFul, benchmark::stoul("18446744073709551615", &pos));
+ EXPECT_EQ(0xFFFFFFFFFFFFFFFFul,
+ benchmark::stoul("18446744073709551615", &pos));
EXPECT_EQ(20ul, pos);
}
#endif
@@ -62,91 +63,81 @@ TEST(StringUtilTest, stoul) {
EXPECT_EQ(4ul, pos);
}
#ifndef BENCHMARK_HAS_NO_EXCEPTIONS
- {
- ASSERT_THROW(benchmark::stoul("this is a test"), std::invalid_argument);
- }
+ { ASSERT_THROW(benchmark::stoul("this is a test"), std::invalid_argument); }
#endif
}
-TEST(StringUtilTest, stoi) {
- {
- size_t pos = 0;
- EXPECT_EQ(0, benchmark::stoi("0", &pos));
- EXPECT_EQ(1ul, pos);
- }
- {
- size_t pos = 0;
- EXPECT_EQ(-17, benchmark::stoi("-17", &pos));
- EXPECT_EQ(3ul, pos);
- }
- {
- size_t pos = 0;
- EXPECT_EQ(1357, benchmark::stoi("1357", &pos));
- EXPECT_EQ(4ul, pos);
- }
- {
- size_t pos = 0;
- EXPECT_EQ(10, benchmark::stoi("1010", &pos, 2));
- EXPECT_EQ(4ul, pos);
- }
- {
- size_t pos = 0;
- EXPECT_EQ(520, benchmark::stoi("1010", &pos, 8));
- EXPECT_EQ(4ul, pos);
- }
- {
- size_t pos = 0;
- EXPECT_EQ(1010, benchmark::stoi("1010", &pos, 10));
- EXPECT_EQ(4ul, pos);
- }
- {
- size_t pos = 0;
- EXPECT_EQ(4112, benchmark::stoi("1010", &pos, 16));
- EXPECT_EQ(4ul, pos);
- }
- {
- size_t pos = 0;
- EXPECT_EQ(0xBEEF, benchmark::stoi("BEEF", &pos, 16));
- EXPECT_EQ(4ul, pos);
- }
+TEST(StringUtilTest, stoi){{size_t pos = 0;
+EXPECT_EQ(0, benchmark::stoi("0", &pos));
+EXPECT_EQ(1ul, pos);
+} // namespace
+{
+ size_t pos = 0;
+ EXPECT_EQ(-17, benchmark::stoi("-17", &pos));
+ EXPECT_EQ(3ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(1357, benchmark::stoi("1357", &pos));
+ EXPECT_EQ(4ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(10, benchmark::stoi("1010", &pos, 2));
+ EXPECT_EQ(4ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(520, benchmark::stoi("1010", &pos, 8));
+ EXPECT_EQ(4ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(1010, benchmark::stoi("1010", &pos, 10));
+ EXPECT_EQ(4ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(4112, benchmark::stoi("1010", &pos, 16));
+ EXPECT_EQ(4ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(0xBEEF, benchmark::stoi("BEEF", &pos, 16));
+ EXPECT_EQ(4ul, pos);
+}
#ifndef BENCHMARK_HAS_NO_EXCEPTIONS
- {
- ASSERT_THROW(benchmark::stoi("this is a test"), std::invalid_argument);
- }
+{ ASSERT_THROW(benchmark::stoi("this is a test"), std::invalid_argument); }
#endif
}
-TEST(StringUtilTest, stod) {
- {
- size_t pos = 0;
- EXPECT_EQ(0.0, benchmark::stod("0", &pos));
- EXPECT_EQ(1ul, pos);
- }
- {
- size_t pos = 0;
- EXPECT_EQ(-84.0, benchmark::stod("-84", &pos));
- EXPECT_EQ(3ul, pos);
- }
- {
- size_t pos = 0;
- EXPECT_EQ(1234.0, benchmark::stod("1234", &pos));
- EXPECT_EQ(4ul, pos);
- }
- {
- size_t pos = 0;
- EXPECT_EQ(1.5, benchmark::stod("1.5", &pos));
- EXPECT_EQ(3ul, pos);
- }
- {
- size_t pos = 0;
- /* Note: exactly representable as double */
- EXPECT_EQ(-1.25e+9, benchmark::stod("-1.25e+9", &pos));
- EXPECT_EQ(8ul, pos);
- }
+TEST(StringUtilTest, stod){{size_t pos = 0;
+EXPECT_EQ(0.0, benchmark::stod("0", &pos));
+EXPECT_EQ(1ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(-84.0, benchmark::stod("-84", &pos));
+ EXPECT_EQ(3ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(1234.0, benchmark::stod("1234", &pos));
+ EXPECT_EQ(4ul, pos);
+}
+{
+ size_t pos = 0;
+ EXPECT_EQ(1.5, benchmark::stod("1.5", &pos));
+ EXPECT_EQ(3ul, pos);
+}
+{
+ size_t pos = 0;
+ /* Note: exactly representable as double */
+ EXPECT_EQ(-1.25e+9, benchmark::stod("-1.25e+9", &pos));
+ EXPECT_EQ(8ul, pos);
+}
#ifndef BENCHMARK_HAS_NO_EXCEPTIONS
- {
- ASSERT_THROW(benchmark::stod("this is a test"), std::invalid_argument);
- }
+{ ASSERT_THROW(benchmark::stod("this is a test"), std::invalid_argument); }
#endif
}
diff --git a/test/templated_fixture_test.cc b/test/templated_fixture_test.cc
index fe9865c..af239c3 100644
--- a/test/templated_fixture_test.cc
+++ b/test/templated_fixture_test.cc
@@ -1,9 +1,9 @@
-#include "benchmark/benchmark.h"
-
#include <cassert>
#include <memory>
+#include "benchmark/benchmark.h"
+
template <typename T>
class MyFixture : public ::benchmark::Fixture {
public: