diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-12-21 22:20:53 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-12-22 00:45:48 -0800 |
commit | fa708f553a3c314aa1eda75cee3c4e5e3b4f40db (patch) | |
tree | 2ad692ae2c9ebe177bbf9ad4073eaffc58dce4d5 /subx | |
parent | fe8bf967a945c7d9e6aba36e42518262d54bd348 (diff) | |
download | mu-fa708f553a3c314aa1eda75cee3c4e5e3b4f40db.tar.gz |
4162
Diffstat (limited to 'subx')
-rw-r--r-- | subx/002test.cc | 25 |
1 files changed, 0 insertions, 25 deletions
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 <stdlib.h> |