From fa708f553a3c314aa1eda75cee3c4e5e3b4f40db Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 21 Dec 2017 22:20:53 -0800 Subject: 4162 --- subx/002test.cc | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'subx') diff --git a/subx/002test.cc b/subx/002test.cc index f6623c90..33560a9d 100644 --- a/subx/002test.cc +++ b/subx/002test.cc @@ -82,30 +82,5 @@ void run_test(size_t i) { // End Test Teardown } -bool is_integer(const string& s) { - 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 -} - -int to_integer(string n) { - char* end = NULL; - // safe because string.c_str() is guaranteed to be null-terminated - int result = strtoll(n.c_str(), &end, /*any base*/0); - if (*end != '\0') cerr << "tried to convert " << n << " to number\n"; - assert(*end == '\0'); - return result; -} - -void test_is_integer() { - CHECK(is_integer("1234")); - CHECK(is_integer("-1")); - CHECK(!is_integer("234.0")); - CHECK(is_integer("-567")); - CHECK(!is_integer("89-0")); - CHECK(!is_integer("-")); - CHECK(!is_integer("1e3")); // not supported -} - :(before "End Includes") #include -- cgit 1.4.1-2-gfad0