From a8ec7eec0b8ff9c63ecbf2f5bf501b59136a227f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 22 Feb 2022 23:58:38 +0000 Subject: [PATCH] Allow passing default value to Bench::GetXXXParameter() Just an extra convenience for the benchmark functions. --- tests/benchmarks/bench.cpp | 10 ++++++---- tests/benchmarks/bench.h | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/benchmarks/bench.cpp b/tests/benchmarks/bench.cpp index 7cf00fe981..f40351584e 100644 --- a/tests/benchmarks/bench.cpp +++ b/tests/benchmarks/bench.cpp @@ -87,14 +87,16 @@ wxIMPLEMENT_APP_CONSOLE(BenchApp); Bench::Function *Bench::Function::ms_head = NULL; -long Bench::GetNumericParameter() +long Bench::GetNumericParameter(long defVal) { - return wxGetApp().GetNumericParameter(); + const long val = wxGetApp().GetNumericParameter(); + return val ? val : defVal; } -wxString Bench::GetStringParameter() +wxString Bench::GetStringParameter(const wxString& defVal) { - return wxGetApp().GetStringParameter(); + const wxString& val = wxGetApp().GetStringParameter(); + return !val.empty() ? val : defVal; } // ============================================================================ diff --git a/tests/benchmarks/bench.h b/tests/benchmarks/bench.h index 11c38fdb84..9eef60bcec 100644 --- a/tests/benchmarks/bench.h +++ b/tests/benchmarks/bench.h @@ -83,7 +83,7 @@ private: Tests may use this parameter in whatever way they see fit, by default it is 1 but can be set to a different value by user from the command line. */ -long GetNumericParameter(); +long GetNumericParameter(long defValue = 1); /** Get the string parameter. @@ -91,7 +91,7 @@ long GetNumericParameter(); Tests may use this parameter in whatever way they see fit, by default it is empty but can be set to a different value by user from the command line. */ -wxString GetStringParameter(); +wxString GetStringParameter(const wxString& defValue = wxString()); } // namespace Bench