aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Danielsson <anton.danielsson@dirac.se>2015-10-07 09:12:56 +0200
committerAnton Danielsson <anton.danielsson@dirac.se>2015-10-09 08:47:36 +0200
commit6abd53777bf013d5bf6bab2cd1ddce78c3b5b9ad (patch)
tree54f7e8d3f88be5c6c6a06a52d686be86ede69c0e
parentdf0df4aba9d5997cdcddcec351ed5b5af180bb88 (diff)
downloadgoogle-benchmark-6abd53777bf013d5bf6bab2cd1ddce78c3b5b9ad.tar.gz
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...
-rw-r--r--test/filter_test.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/test/filter_test.cc b/test/filter_test.cc
index ca9f6cc..2a278ff 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;
}