From 6abd53777bf013d5bf6bab2cd1ddce78c3b5b9ad Mon Sep 17 00:00:00 2001 From: Anton Danielsson Date: Wed, 7 Oct 2015 09:12:56 +0200 Subject: [PATCH] Use stringstream instead of atoi to avoid sign error. The sane thing here would be to use std::stoul but this is not available in the android-ndk... --- test/filter_test.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/test/filter_test.cc b/test/filter_test.cc index ca9f6cc9..2a278ff4 100644 --- a/test/filter_test.cc +++ b/test/filter_test.cc @@ -74,12 +74,18 @@ int main(int argc, char* argv[]) { TestReporter test_reporter; benchmark::RunSpecifiedBenchmarks(&test_reporter); - // Make sure we ran all of the tests - const size_t count = test_reporter.GetCount(); - const size_t expected = (argc == 2) ? std::atol(argv[1]) : count; - if (count != expected) { - std::cerr << "ERROR: Expected " << expected << " tests to be ran but only " - << count << " completed" << std::endl; - return -1; + if (argc == 2) { + // Make sure we ran all of the tests + std::stringstream ss(argv[1]); + size_t expected; + ss >> expected; + + const size_t count = test_reporter.GetCount(); + if (count != expected) { + std::cerr << "ERROR: Expected " << expected << " tests to be ran but only " + << count << " completed" << std::endl; + return -1; + } } + return 0; }