@@ -224,18 +224,18 @@ Runner& Runner::add(TestCaseFactory factory) {
224
224
return *this ;
225
225
}
226
226
227
- unsigned int Runner::testCount () const {
228
- return static_cast < unsigned int >( tests_.size () );
227
+ size_t Runner::testCount () const {
228
+ return tests_.size ();
229
229
}
230
230
231
- JSONCPP_STRING Runner::testNameAt (unsigned int index) const {
231
+ JSONCPP_STRING Runner::testNameAt (size_t index) const {
232
232
TestCase* test = tests_[index ]();
233
233
JSONCPP_STRING name = test->testName ();
234
234
delete test;
235
235
return name;
236
236
}
237
237
238
- void Runner::runTestAt (unsigned int index, TestResult& result) const {
238
+ void Runner::runTestAt (size_t index, TestResult& result) const {
239
239
TestCase* test = tests_[index ]();
240
240
result.setTestName (test->testName ());
241
241
printf (" Testing %s: " , test->testName ());
@@ -257,9 +257,9 @@ void Runner::runTestAt(unsigned int index, TestResult& result) const {
257
257
}
258
258
259
259
bool Runner::runAllTest (bool printSummary) const {
260
- unsigned int count = testCount ();
260
+ size_t const count = testCount ();
261
261
std::deque<TestResult> failures;
262
- for (unsigned int index = 0 ; index < count; ++index ) {
262
+ for (size_t index = 0 ; index < count; ++index ) {
263
263
TestResult result;
264
264
runTestAt (index , result);
265
265
if (result.failed ()) {
@@ -269,7 +269,7 @@ bool Runner::runAllTest(bool printSummary) const {
269
269
270
270
if (failures.empty ()) {
271
271
if (printSummary) {
272
- printf (" All %u tests passed\n " , count);
272
+ printf (" All %zu tests passed\n " , count);
273
273
}
274
274
return true ;
275
275
} else {
@@ -278,19 +278,19 @@ bool Runner::runAllTest(bool printSummary) const {
278
278
}
279
279
280
280
if (printSummary) {
281
- auto failedCount = static_cast < unsigned int >( failures.size () );
282
- unsigned int passedCount = count - failedCount;
283
- printf (" %u/%u tests passed (%u failure(s))\n " , passedCount, count ,
284
- failedCount);
281
+ size_t const failedCount = failures.size ();
282
+ size_t const passedCount = count - failedCount;
283
+ printf (" %zu/%zu tests passed (%zu failure(s))\n " ,
284
+ passedCount, count, failedCount);
285
285
}
286
286
return false ;
287
287
}
288
288
}
289
289
290
290
bool Runner::testIndex (const JSONCPP_STRING& testName,
291
- unsigned int & indexOut) const {
292
- unsigned int count = testCount ();
293
- for (unsigned int index = 0 ; index < count; ++index ) {
291
+ size_t & indexOut) const {
292
+ const size_t count = testCount ();
293
+ for (size_t index = 0 ; index < count; ++index ) {
294
294
if (testNameAt (index ) == testName) {
295
295
indexOut = index ;
296
296
return true ;
@@ -300,8 +300,8 @@ bool Runner::testIndex(const JSONCPP_STRING& testName,
300
300
}
301
301
302
302
void Runner::listTests () const {
303
- unsigned int count = testCount ();
304
- for (unsigned int index = 0 ; index < count; ++index ) {
303
+ const size_t count = testCount ();
304
+ for (size_t index = 0 ; index < count; ++index ) {
305
305
printf (" %s\n " , testNameAt (index ).c_str ());
306
306
}
307
307
}
@@ -319,7 +319,7 @@ int Runner::runCommandLine(int argc, const char* argv[]) const {
319
319
} else if (opt == " --test" ) {
320
320
++index ;
321
321
if (index < argc) {
322
- unsigned int testNameIndex;
322
+ size_t testNameIndex;
323
323
if (testIndex (argv[index ], testNameIndex)) {
324
324
subrunner.add (tests_[testNameIndex]);
325
325
} else {
0 commit comments