aboutsummaryrefslogtreecommitdiff
path: root/test/skip_with_error_test.cc
diff options
context:
space:
mode:
authorPaweł Bylica <chfast@gmail.com>2020-02-21 15:53:25 +0100
committerGitHub <noreply@github.com>2020-02-21 17:53:25 +0300
commitc078337494086f9372a46b4ed31a3ae7b3f1a6a2 (patch)
treee73e2e2307fe3cb4bcb56db46f85e48d6b98a7a8 /test/skip_with_error_test.cc
parent168604d8f8e84c1f991de85f1a723c0df9a5b944 (diff)
downloadgoogle-benchmark-c078337494086f9372a46b4ed31a3ae7b3f1a6a2.tar.gz
Relax CHECK condition in benchmark_runner.cc (#938)
* Add State::error_occurred() * Relax CHECK condition in benchmark_runner.cc If the benchmark state contains an error, do not expect any iterations has been run. This allows using SkipWithError() and return early from the benchmark function. * README.md: document new possible usage of SkipWithError()
Diffstat (limited to 'test/skip_with_error_test.cc')
-rw-r--r--test/skip_with_error_test.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/skip_with_error_test.cc b/test/skip_with_error_test.cc
index 0657977..97a2e3c 100644
--- a/test/skip_with_error_test.cc
+++ b/test/skip_with_error_test.cc
@@ -61,6 +61,12 @@ int AddCases(const char* base_name, std::initializer_list<TestCase> const& v) {
} // end namespace
+void BM_error_no_running(benchmark::State& state) {
+ state.SkipWithError("error message");
+}
+BENCHMARK(BM_error_no_running);
+ADD_CASES("BM_error_no_running", {{"", true, "error message"}});
+
void BM_error_before_running(benchmark::State& state) {
state.SkipWithError("error message");
while (state.KeepRunning()) {