diff --git a/userspace/Shell/main.cpp b/userspace/Shell/main.cpp index 0ee1f4ffbe..6adaed1105 100644 --- a/userspace/Shell/main.cpp +++ b/userspace/Shell/main.cpp @@ -448,6 +448,27 @@ BAN::Optional execute_builtin(BAN::Vector& args, int fd_in, in return ret; } + else if (args.front() == "test-strtol") + { +#define TEST(num, base) do { errno = 0; printf("strtol(\"" num "\", nullptr, " #base ") = %ld ", strtol(num, nullptr, base)); puts(errno ? strerrorname_np(errno) : ""); } while (false) + TEST("0", 10); + TEST("", 10); + TEST("+", 10); + TEST("123", 10); + TEST("-123", 10); + TEST("7fffffffffffffff", 10); + TEST("7fffffffffffffff", 16); + TEST("8000000000000000", 16); + TEST("-8000000000000000", 16); + TEST("-8000000000000001", 16); + TEST("123", 0); + TEST("0123", 0); + TEST("0x123", 0); + TEST("123", 1); + TEST("hello", 10); + TEST("hello", 36); +#undef TEST + } else { return {};