Skip to content

Commit b12d0c8

Browse files
authored
Merge b7387f0 into c9311a4
2 parents c9311a4 + b7387f0 commit b12d0c8

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/benchmark_register.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,16 @@ bool BenchmarkFamilies::FindBenchmarks(
182182
}
183183
}
184184

185-
instance.name += StrFormat("%d", arg);
185+
// we know that the args are always non-negative (see 'AddRange()'),
186+
// thus print as 'unsigned'. BUT, do a cast due to the 32-bit builds.
187+
instance.name += StrFormat("%zu", static_cast<size_t>(arg));
186188
++arg_i;
187189
}
188190

189191
if (!IsZero(family->min_time_))
190192
instance.name += StrFormat("/min_time:%0.3f", family->min_time_);
191193
if (family->iterations_ != 0)
192-
instance.name += StrFormat("/iterations:%d", family->iterations_);
194+
instance.name += StrFormat("/iterations:%zu", family->iterations_);
193195
if (family->repetitions_ != 0)
194196
instance.name += StrFormat("/repeats:%d", family->repetitions_);
195197

src/string_util.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ void AppendHumanReadable(int n, std::string* str);
1212

1313
std::string HumanReadableNumber(double n, double one_k = 1024.0);
1414

15-
std::string StrFormat(const char* format, ...);
15+
#ifdef __GNUC__
16+
__attribute__((format(printf, 1, 2)))
17+
#endif
18+
std::string
19+
StrFormat(const char* format, ...);
1620

1721
inline std::ostream& StrCatImp(std::ostream& out) BENCHMARK_NOEXCEPT {
1822
return out;

test/reporter_output_test.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,18 @@ ADD_CASES(TC_JSONOut,
219219
{"\"run_type\": \"iteration\",$", MR_Next}});
220220
ADD_CASES(TC_CSVOut, {{"^\"BM_arg_names/first:2/5/third:4\",%csv_report$"}});
221221

222+
// ========================================================================= //
223+
// ------------------------ Testing Big Args Output ------------------------ //
224+
// ========================================================================= //
225+
226+
void BM_BigArgs(benchmark::State& state) {
227+
for (auto _ : state) {
228+
}
229+
}
230+
BENCHMARK(BM_BigArgs)->RangeMultiplier(2)->Range(1U << 30U, 1U << 31U);
231+
ADD_CASES(TC_ConsoleOut, {{"^BM_BigArgs/1073741824 %console_report$"},
232+
{"^BM_BigArgs/2147483648 %console_report$"}});
233+
222234
// ========================================================================= //
223235
// ----------------------- Testing Complexity Output ----------------------- //
224236
// ========================================================================= //

0 commit comments

Comments
 (0)