mirror of
https://github.com/google/benchmark.git
synced 2024-12-27 04:50:19 +08:00
6cf7725ea1
* Allow specifying number of iterations via --benchmark_min_time. Make the flag accept two new suffixes: + <integer>x: number of iterations + <floag>s: minimum number of seconds. This matches the internal benchmark API. * forgot to change flag type to string * used tagged union instead of std::variant, which is not available pre C++14 * update decl in benchmark_runner.h too * fixed errors * refactor * backward compat * typo * use IterationCount type * fixed test * const_cast * ret type * remove extra _ * debug * fixed bug from reporting that caused the new configs not to be included in the final report * addressed review comments * restore unnecessary changes in test/BUILD * fix float comparisons warnings from Release builds * clang format * fix visibility warning * remove misc file * removed backup files * addressed review comments * fix shorten in warning * use suffix for existing min_time specs to silent warnings in tests * fix leaks * use default min-time value in flag decl for consistency * removed double kMinTimeDecl from benchmark.h * dont need to preserve errno * add death tests * Add BENCHMARK_EXPORT to hopefully fix missing def errors * only enable death tests in debug mode because bm_check is no-op in release mode * guard death tests with additional support-check macros * Add additional guard to prevent running in Release mode --------- Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
31 lines
951 B
C++
31 lines
951 B
C++
#include "../src/benchmark_runner.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
namespace {
|
|
|
|
TEST(ParseMinTimeTest, InvalidInput) {
|
|
#if GTEST_HAS_DEATH_TEST
|
|
// Tests only runnable in debug mode (when BM_CHECK is enabled).
|
|
#ifndef NDEBUG
|
|
#ifndef TEST_BENCHMARK_LIBRARY_HAS_NO_ASSERTIONS
|
|
ASSERT_DEATH_IF_SUPPORTED(
|
|
{ benchmark::internal::ParseBenchMinTime("abc"); },
|
|
"Malformed seconds value passed to --benchmark_min_time: `abc`");
|
|
|
|
ASSERT_DEATH_IF_SUPPORTED(
|
|
{ benchmark::internal::ParseBenchMinTime("123ms"); },
|
|
"Malformed seconds value passed to --benchmark_min_time: `123ms`");
|
|
|
|
ASSERT_DEATH_IF_SUPPORTED(
|
|
{ benchmark::internal::ParseBenchMinTime("1z"); },
|
|
"Malformed seconds value passed to --benchmark_min_time: `1z`");
|
|
|
|
ASSERT_DEATH_IF_SUPPORTED(
|
|
{ benchmark::internal::ParseBenchMinTime("1hs"); },
|
|
"Malformed seconds value passed to --benchmark_min_time: `1hs`");
|
|
#endif
|
|
#endif
|
|
#endif
|
|
}
|
|
} // namespace
|