// 功能:跳过字符串前导空白与正负符号
// ih: 输入字符串
// cnt: 输入字符个数
const char* __SkipLeadSignBlank(const char ih, unsigned int cnt)
{
    const char *s = ih, *h = ih;
    do {
        const auto c = *s;
        if (('-') == c) continue;
        if (('+') == c) continue;
        if (::isblank(c)) continue;//(c == (' ')) || (c == ('\t'))
        if (0 == c) return NULL;
        break;
    } while (++s, unsigned int(s - h) < cnt);
    return s;
}
// 功能:检测输入字符串是否为合法的包含正负的数字文本
// ih: 输入字符串
// cnt: 输入字符个数
bool isInteger(const char* ih, unsigned int cnt = ~0u)
{
    if (0 == ih) return false;
    if (0 == cnt) return false;

    // 跳过合法的乱七八糟头
    auto s = __SkipLeadSignBlank(ih, cnt);
    if (s == nullptr) return false;

    // 检验是否为数字
    const char *h = ih;
    do {
        const auto c = *s;
        if (::isdigit(c)) continue;
        if (0 == c) break;
        return false;
    } while (++s, unsigned int(s - h) < cnt);
    return true;
}
TEST_CASE("string function test", "好看的白盒测试哟")
{
    SECTION("check raw integer string is number") {
        CHECK(_isInteger(NULL) == false);
        CHECK(_isInteger("") == false);
        CHECK(_isInteger("9a") == false);
        CHECK(_isInteger("9a", 1) == true);
        CHECK(_isInteger("908") == true);
        CHECK(_isInteger("-908") == true);
        CHECK(_isInteger("+09") == true);
        CHECK(_isInteger("-+9") == true);
        CHECK(_isInteger("  007") == true);
        CHECK(_isInteger("0") == true);
        CHECK(_isInteger("0x") == false);
        CHECK(_isInteger("0x9a8F") == false);
        CHECK(_isInteger("0x9a8Fi") == false);
        CHECK(_isInteger("-0xAB") == false);
        CHECK(_isInteger("-9.380") == false);
        CHECK(_isInteger("-9.38e") == false);
        CHECK(_isInteger("-9.38e7") == false);
        CHECK(_isInteger("-9.38e+7") == false);
        CHECK(_isInteger("-9.38e-7") == false);
        CHECK(_isInteger("-9.38e-7a") == false);
        CHECK(_isInteger("-9.38ea-7") == false);
        CHECK(_isInteger("-0xFF.3") == false);
    }
}