about summary refs log tree commit diff stats
path: root/002test.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-02-24 18:07:54 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-02-24 18:08:20 -0800
commitad6eb92329d3c21a7c8439eeed5587d20fe97f4e (patch)
tree457f58ecd791e3c115d96179349c323280ec1392 /002test.cc
parentb17de7ba5219efe67ecd80b71c20769fbbf423a9 (diff)
downloadmu-ad6eb92329d3c21a7c8439eeed5587d20fe97f4e.tar.gz
2697
Diffstat (limited to '002test.cc')
-rw-r--r--002test.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/002test.cc b/002test.cc
index 17de608c..f857c2a1 100644
--- a/002test.cc
+++ b/002test.cc
@@ -82,9 +82,9 @@ void run_test(size_t i) {
 }
 
 bool is_integer(const string& s) {
-  return s.find_first_not_of("0123456789-") == string::npos
-      && s.find('-', 1) == string::npos
-      && s.find_first_of("0123456789") != string::npos;
+  return s.find_first_not_of("0123456789-") == string::npos  // no other characters
+      && s.find_first_of("0123456789") != string::npos  // at least one digit
+      && s.find('-', 1) == string::npos;  // '-' only at first position
 }
 
 long long int to_integer(string n) {