--- a/tests/test_string.c Sun Dec 28 18:43:21 2025 +0100 +++ b/tests/test_string.c Mon Dec 29 10:45:55 2025 +0100 @@ -490,18 +490,19 @@ CX_TEST(test_strcmp) { cxstring str = cx_str("compare this"); CX_TEST_DO { - CX_TEST_ASSERT(0 == cx_strcmp(cx_str(""), cx_str(""))); - CX_TEST_ASSERT(0 < cx_strcmp(str, cx_str(""))); - CX_TEST_ASSERT(0 == cx_strcmp(str, cx_str("compare this"))); - CX_TEST_ASSERT(0 != cx_strcmp(str, cx_str("Compare This"))); - CX_TEST_ASSERT(0 > cx_strcmp(str, cx_str("compare tool"))); - CX_TEST_ASSERT(0 < cx_strcmp(str, cx_str("compare shit"))); - CX_TEST_ASSERT(0 > cx_strcmp(str, cx_str("compare this not"))); - CX_TEST_ASSERT(0 < cx_strcmp(str, cx_str("compare"))); - CX_TEST_ASSERT(0 > cx_strcmp(str, cx_str("lex"))); - CX_TEST_ASSERT(0 < cx_strcmp(str, cx_str("another lex test"))); - CX_TEST_ASSERT(0 < cx_strcmp(str, cx_str("Lex"))); - CX_TEST_ASSERT(0 < cx_strcmp(str, cx_str("Another lex test"))); + CX_TEST_ASSERT(0 == cx_strcmp(cx_str(""), "")); + CX_TEST_ASSERT(0 == cx_strcmp(CX_NULLSTR, "")); + CX_TEST_ASSERT(0 < cx_strcmp(str, "")); + CX_TEST_ASSERT(0 == cx_strcmp(str, "compare this")); + CX_TEST_ASSERT(0 != cx_strcmp(str, "Compare This")); + CX_TEST_ASSERT(0 > cx_strcmp(str, "compare tool")); + CX_TEST_ASSERT(0 < cx_strcmp(str, "compare shit")); + CX_TEST_ASSERT(0 > cx_strcmp(str, "compare this not")); + CX_TEST_ASSERT(0 < cx_strcmp(str, "compare")); + CX_TEST_ASSERT(0 > cx_strcmp(str, "lex")); + CX_TEST_ASSERT(0 < cx_strcmp(str, "another lex test")); + CX_TEST_ASSERT(0 < cx_strcmp(str, "Lex")); + CX_TEST_ASSERT(0 < cx_strcmp(str, "Another lex test")); cxstring str2 = cx_str("Compare This"); CX_TEST_ASSERT(0 != cx_strcmp_p(&str, &str2)); @@ -513,18 +514,19 @@ CX_TEST(test_strcasecmp) { cxstring str = cx_str("compare this"); CX_TEST_DO { - CX_TEST_ASSERT(0 == cx_strcasecmp(cx_str(""), cx_str(""))); - CX_TEST_ASSERT(0 < cx_strcasecmp(str, cx_str(""))); - CX_TEST_ASSERT(0 == cx_strcasecmp(str, cx_str("compare this"))); - CX_TEST_ASSERT(0 == cx_strcasecmp(str, cx_str("Compare This"))); - CX_TEST_ASSERT(0 > cx_strcasecmp(str, cx_str("compare tool"))); - CX_TEST_ASSERT(0 < cx_strcasecmp(str, cx_str("compare shit"))); - CX_TEST_ASSERT(0 > cx_strcasecmp(str, cx_str("compare this not"))); - CX_TEST_ASSERT(0 < cx_strcasecmp(str, cx_str("compare"))); - CX_TEST_ASSERT(0 > cx_strcasecmp(str, cx_str("lex"))); - CX_TEST_ASSERT(0 < cx_strcasecmp(str, cx_str("another lex test"))); - CX_TEST_ASSERT(0 > cx_strcasecmp(str, cx_str("Lex"))); - CX_TEST_ASSERT(0 < cx_strcasecmp(str, cx_str("Another lex test"))); + CX_TEST_ASSERT(0 == cx_strcasecmp(cx_str(""), "")); + CX_TEST_ASSERT(0 == cx_strcasecmp(CX_NULLSTR, "")); + CX_TEST_ASSERT(0 < cx_strcasecmp(str, "")); + CX_TEST_ASSERT(0 == cx_strcasecmp(str, "compare this")); + CX_TEST_ASSERT(0 == cx_strcasecmp(str, "Compare This")); + CX_TEST_ASSERT(0 > cx_strcasecmp(str, "compare tool")); + CX_TEST_ASSERT(0 < cx_strcasecmp(str, "compare shit")); + CX_TEST_ASSERT(0 > cx_strcasecmp(str, "compare this not")); + CX_TEST_ASSERT(0 < cx_strcasecmp(str, "compare")); + CX_TEST_ASSERT(0 > cx_strcasecmp(str, "lex")); + CX_TEST_ASSERT(0 < cx_strcasecmp(str, "another lex test")); + CX_TEST_ASSERT(0 > cx_strcasecmp(str, "Lex")); + CX_TEST_ASSERT(0 < cx_strcasecmp(str, "Another lex test")); cxstring str2 = cx_str("Compare This"); CX_TEST_ASSERT(0 == cx_strcasecmp_p(&str, &str2)); @@ -858,11 +860,11 @@ cxstring str = cx_str("test my prefix and my suffix"); cxstring empty = cx_str(""); CX_TEST_DO { - CX_TEST_ASSERT(!cx_strprefix(empty, cx_str("pref"))); - CX_TEST_ASSERT(cx_strprefix(str, empty)); - CX_TEST_ASSERT(cx_strprefix(empty, empty)); - CX_TEST_ASSERT(cx_strprefix(str, cx_str("test "))); - CX_TEST_ASSERT(!cx_strprefix(str, cx_str("8-) fsck "))); + CX_TEST_ASSERT(!cx_strprefix(empty, "pref")); + CX_TEST_ASSERT(cx_strprefix(str, "")); + CX_TEST_ASSERT(cx_strprefix(empty, "")); + CX_TEST_ASSERT(cx_strprefix(str, "test ")); + CX_TEST_ASSERT(!cx_strprefix(str, "8-) fsck ")); } } @@ -870,11 +872,11 @@ cxstring str = cx_str("test my prefix and my suffix"); cxstring empty = cx_str(""); CX_TEST_DO { - CX_TEST_ASSERT(!cx_strsuffix(empty, cx_str("suf"))); - CX_TEST_ASSERT(cx_strsuffix(str, empty)); - CX_TEST_ASSERT(cx_strsuffix(empty, empty)); - CX_TEST_ASSERT(cx_strsuffix(str, cx_str("fix"))); - CX_TEST_ASSERT(!cx_strsuffix(str, cx_str("fox"))); + CX_TEST_ASSERT(!cx_strsuffix(empty, "suf")); + CX_TEST_ASSERT(cx_strsuffix(str, "")); + CX_TEST_ASSERT(cx_strsuffix(empty, "")); + CX_TEST_ASSERT(cx_strsuffix(str, "fix")); + CX_TEST_ASSERT(!cx_strsuffix(str, "fox")); } } @@ -882,11 +884,11 @@ cxstring str = cx_str("test my prefix and my suffix"); cxstring empty = cx_str(""); CX_TEST_DO { - CX_TEST_ASSERT(!cx_strcaseprefix(empty, cx_str("pREf"))); - CX_TEST_ASSERT(cx_strcaseprefix(str, empty)); - CX_TEST_ASSERT(cx_strcaseprefix(empty, empty)); - CX_TEST_ASSERT(cx_strcaseprefix(str, cx_str("TEST "))); - CX_TEST_ASSERT(!cx_strcaseprefix(str, cx_str("8-) fsck "))); + CX_TEST_ASSERT(!cx_strcaseprefix(empty, "pREf")); + CX_TEST_ASSERT(cx_strcaseprefix(str, "")); + CX_TEST_ASSERT(cx_strcaseprefix(empty, "")); + CX_TEST_ASSERT(cx_strcaseprefix(str, "TEST ")); + CX_TEST_ASSERT(!cx_strcaseprefix(str, "8-) fsck ")); } } @@ -894,11 +896,11 @@ cxstring str = cx_str("test my prefix and my suffix"); cxstring empty = cx_str(""); CX_TEST_DO { - CX_TEST_ASSERT(!cx_strcasesuffix(empty, cx_str("sUf"))); - CX_TEST_ASSERT(cx_strcasesuffix(str, empty)); - CX_TEST_ASSERT(cx_strcasesuffix(empty, empty)); - CX_TEST_ASSERT(cx_strcasesuffix(str, cx_str("FIX"))); - CX_TEST_ASSERT(!cx_strcasesuffix(str, cx_str("fox"))); + CX_TEST_ASSERT(!cx_strcasesuffix(empty, "sUf")); + CX_TEST_ASSERT(cx_strcasesuffix(str, "")); + CX_TEST_ASSERT(cx_strcasesuffix(empty, "")); + CX_TEST_ASSERT(cx_strcasesuffix(str, "FIX")); + CX_TEST_ASSERT(!cx_strcasesuffix(str, "fox")); } } @@ -1056,7 +1058,7 @@ ret = cx_strtok_next(&ctx, &tok); CX_TEST_ASSERT(ret); - CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("a"))); + CX_TEST_ASSERT(0 == cx_strcmp(tok, "a")); CX_TEST_ASSERT(ctx.pos == 0); CX_TEST_ASSERT(ctx.next_pos == 2); CX_TEST_ASSERT(ctx.delim_pos == 1); @@ -1064,7 +1066,7 @@ ret = cx_strtok_next(&ctx, &tok); CX_TEST_ASSERT(ret); - CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("comma"))); + CX_TEST_ASSERT(0 == cx_strcmp(tok, "comma")); CX_TEST_ASSERT(ctx.pos == 2); CX_TEST_ASSERT(ctx.next_pos == 8); CX_TEST_ASSERT(ctx.delim_pos == 7); @@ -1072,7 +1074,7 @@ ret = cx_strtok_next(&ctx, &tok); CX_TEST_ASSERT(ret); - CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("separated"))); + CX_TEST_ASSERT(0 == cx_strcmp(tok, "separated")); CX_TEST_ASSERT(ctx.pos == 8); CX_TEST_ASSERT(ctx.next_pos == 18); CX_TEST_ASSERT(ctx.delim_pos == 17); @@ -1097,7 +1099,7 @@ ret = cx_strtok_next(&ctx, &tok); CX_TEST_ASSERT(ret); - CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("some"))); + CX_TEST_ASSERT(0 == cx_strcmp(tok, "some")); CX_TEST_ASSERT(ctx.pos == 0); CX_TEST_ASSERT(ctx.next_pos == 7); CX_TEST_ASSERT(ctx.delim_pos == 4); @@ -1105,7 +1107,7 @@ ret = cx_strtok_next(&ctx, &tok); CX_TEST_ASSERT(ret); - CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("otherwise"))); + CX_TEST_ASSERT(0 == cx_strcmp(tok, "otherwise")); CX_TEST_ASSERT(ctx.pos == 7); CX_TEST_ASSERT(ctx.next_pos == 19); CX_TEST_ASSERT(ctx.delim_pos == 16); @@ -1113,7 +1115,7 @@ ret = cx_strtok_next(&ctx, &tok); CX_TEST_ASSERT(ret); - CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("separated"))); + CX_TEST_ASSERT(0 == cx_strcmp(tok, "separated")); CX_TEST_ASSERT(ctx.pos == 19); CX_TEST_ASSERT(ctx.next_pos == 31); CX_TEST_ASSERT(ctx.delim_pos == 28); @@ -1121,7 +1123,7 @@ ret = cx_strtok_next(&ctx, &tok); CX_TEST_ASSERT(ret); - CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str("string"))); + CX_TEST_ASSERT(0 == cx_strcmp(tok, "string")); CX_TEST_ASSERT(ctx.pos == 31); CX_TEST_ASSERT(ctx.next_pos == 40); CX_TEST_ASSERT(ctx.delim_pos == 37); @@ -1129,7 +1131,7 @@ ret = cx_strtok_next(&ctx, &tok); CX_TEST_ASSERT(ret); - CX_TEST_ASSERT(0 == cx_strcmp(tok, cx_str(""))); + CX_TEST_ASSERT(0 == cx_strcmp(tok, "")); CX_TEST_ASSERT(ctx.pos == 40); CX_TEST_ASSERT(ctx.next_pos == 40); CX_TEST_ASSERT(ctx.delim_pos == 40); @@ -1302,91 +1304,91 @@ // can fit only in unsigned long long errno = 0; - CX_TEST_ASSERT(0 != cx_strtoll(cx_str("0x8df9CE03AbC90815"), &ll, 16)); + CX_TEST_ASSERT(0 != cx_strtoll("0x8df9CE03AbC90815", &ll, 16)); CX_TEST_ASSERT(errno == ERANGE); // negative overflow (we only test for 64 bit long long) #if LLONG_MAX == 9223372036854775807ll errno = 0; - CX_TEST_ASSERT(0 == cx_strtoll(cx_str("-9223372036854775808"), &ll, 10)); + CX_TEST_ASSERT(0 == cx_strtoll("-9223372036854775808", &ll, 10)); CX_TEST_ASSERT(ll == LLONG_MIN); CX_TEST_ASSERT(errno == 0); - CX_TEST_ASSERT(0 != cx_strtoll(cx_str("-9223372036854775809"), &ll, 10)); + CX_TEST_ASSERT(0 != cx_strtoll("-9223372036854775809", &ll, 10)); CX_TEST_ASSERT(errno == ERANGE); #endif // edge case: empty and NULL string errno = 0; - CX_TEST_ASSERT(0 != cx_strtoll(cx_str(""), &ll, 16)); + CX_TEST_ASSERT(0 != cx_strtoll("", &ll, 16)); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoll(cx_str(NULL), &ll, 16)); + CX_TEST_ASSERT(0 != cx_strtoll(CX_NULLSTR, &ll, 16)); CX_TEST_ASSERT(errno == EINVAL); // edge case: unsupported base errno = 0; - CX_TEST_ASSERT(0 != cx_strtoll(cx_str("7"), &ll, 12)); + CX_TEST_ASSERT(0 != cx_strtoll("7", &ll, 12)); CX_TEST_ASSERT(errno == EINVAL); // edge case: incorrect sign characters errno = 0; - CX_TEST_ASSERT(0 != cx_strtoll(cx_str("-"), &ll, 10)); + CX_TEST_ASSERT(0 != cx_strtoll("-", &ll, 10)); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoll(cx_str("+"), &ll, 10)); + CX_TEST_ASSERT(0 != cx_strtoll("+", &ll, 10)); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoll(cx_str("-+15"), &ll, 10)); + CX_TEST_ASSERT(0 != cx_strtoll("-+15", &ll, 10)); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoll(cx_str("--15"), &ll, 10)); + CX_TEST_ASSERT(0 != cx_strtoll("--15", &ll, 10)); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoll(cx_str("+-15"), &ll, 10)); + CX_TEST_ASSERT(0 != cx_strtoll("+-15", &ll, 10)); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoll(cx_str("++15"), &ll, 10)); + CX_TEST_ASSERT(0 != cx_strtoll("++15", &ll, 10)); CX_TEST_ASSERT(errno == EINVAL); // edge case: only the sign bit is set errno = 0; - CX_TEST_ASSERT(0 != cx_strtoi16(cx_str("0x8000"), &i16, 16)); + CX_TEST_ASSERT(0 != cx_strtoi16("0x8000", &i16, 16)); CX_TEST_ASSERT(errno == ERANGE); errno = 0; - CX_TEST_ASSERT(0 == cx_strtoi16(cx_str("-0x8000"), &i16, 16)); + CX_TEST_ASSERT(0 == cx_strtoi16("-0x8000", &i16, 16)); CX_TEST_ASSERT(errno == 0); CX_TEST_ASSERT(i16 == INT16_MIN); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoi64(cx_str("X8000000000000000"), &i64, 16)); + CX_TEST_ASSERT(0 != cx_strtoi64("X8000000000000000", &i64, 16)); CX_TEST_ASSERT(errno == ERANGE); errno = 0; - CX_TEST_ASSERT(0 == cx_strtoi64(cx_str("-X8000000000000000"), &i64, 16)); + CX_TEST_ASSERT(0 == cx_strtoi64("-X8000000000000000", &i64, 16)); CX_TEST_ASSERT(errno == 0); CX_TEST_ASSERT(i64 == INT64_MIN); // group separators - CX_TEST_ASSERT(0 == cx_strtoi32(cx_str("-123,456"), &i32, 10)); + CX_TEST_ASSERT(0 == cx_strtoi32("-123,456", &i32, 10)); CX_TEST_ASSERT(i32 == -123456); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoi16_lc(cx_str("-Xab,cd"), &i16, 16, "'")); + CX_TEST_ASSERT(0 != cx_strtoi16_lc("-Xab,cd", &i16, 16, "'")); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoi16_lc(cx_str("-X'ab'cd"), &i16, 16, "'")); + CX_TEST_ASSERT(0 != cx_strtoi16_lc("-X'ab'cd", &i16, 16, "'")); CX_TEST_ASSERT(errno == ERANGE); errno = 0; - CX_TEST_ASSERT(0 == cx_strtoi16_lc(cx_str("-X'67'89"), &i16, 16, "'")); + CX_TEST_ASSERT(0 == cx_strtoi16_lc("-X'67'89", &i16, 16, "'")); CX_TEST_ASSERT(errno == 0); CX_TEST_ASSERT(i16 == -0x6789); // binary and (unusual notation of) signed binary errno = 0; - CX_TEST_ASSERT(0 != cx_strtoi8_lc(cx_str("-1010 1011"), &i8, 2, " ")); + CX_TEST_ASSERT(0 != cx_strtoi8_lc("-1010 1011", &i8, 2, " ")); CX_TEST_ASSERT(errno == ERANGE); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoi8_lc(cx_str("1010 1011"), &i8, 2, " ")); + CX_TEST_ASSERT(0 != cx_strtoi8_lc("1010 1011", &i8, 2, " ")); CX_TEST_ASSERT(errno == ERANGE); errno = 0; - CX_TEST_ASSERT(0 == cx_strtoi8_lc(cx_str("-0101 0101"), &i8, 2, " ")); + CX_TEST_ASSERT(0 == cx_strtoi8_lc("-0101 0101", &i8, 2, " ")); CX_TEST_ASSERT(errno == 0); CX_TEST_ASSERT(i8 == -0x55); } @@ -1443,57 +1445,57 @@ // -------------------------- // leading plus - CX_TEST_ASSERT(0 == cx_strtou32(cx_str("+5"), &u32, 10)); + CX_TEST_ASSERT(0 == cx_strtou32("+5", &u32, 10)); CX_TEST_ASSERT(u32 == 5); // group separators - CX_TEST_ASSERT(0 == cx_strtou32(cx_str("123,456"), &u32, 10)); + CX_TEST_ASSERT(0 == cx_strtou32("123,456", &u32, 10)); CX_TEST_ASSERT(u32 == 123456); errno = 0; - CX_TEST_ASSERT(0 != cx_strtou16_lc(cx_str("ab,cd"), &u16, 16, "'")); + CX_TEST_ASSERT(0 != cx_strtou16_lc("ab,cd", &u16, 16, "'")); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 == cx_strtou16_lc(cx_str("ab'cd"), &u16, 16, "'")); + CX_TEST_ASSERT(0 == cx_strtou16_lc("ab'cd", &u16, 16, "'")); CX_TEST_ASSERT(errno == 0); CX_TEST_ASSERT(u16 == 0xabcd); // binary errno = 0; - CX_TEST_ASSERT(0 != cx_strtou8_lc(cx_str("1 1010 1011"), &u8, 2, " ")); + CX_TEST_ASSERT(0 != cx_strtou8_lc("1 1010 1011", &u8, 2, " ")); CX_TEST_ASSERT(errno == ERANGE); errno = 0; - CX_TEST_ASSERT(0 == cx_strtou8_lc(cx_str("1010 1011"), &u8, 2, " ")); + CX_TEST_ASSERT(0 == cx_strtou8_lc("1010 1011", &u8, 2, " ")); CX_TEST_ASSERT(errno == 0); CX_TEST_ASSERT(u8 == 0xAB); // edge case: empty and NULL string errno = 0; - CX_TEST_ASSERT(0 != cx_strtoull(cx_str(""), &ull, 16)); + CX_TEST_ASSERT(0 != cx_strtoull("", &ull, 16)); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoull(cx_str(NULL), &ull, 16)); + CX_TEST_ASSERT(0 != cx_strtoull(CX_NULLSTR, &ull, 16)); CX_TEST_ASSERT(errno == EINVAL); // edge case: unsupported base errno = 0; - CX_TEST_ASSERT(0 != cx_strtoull(cx_str("7"), &ull, 12)); + CX_TEST_ASSERT(0 != cx_strtoull("7", &ull, 12)); CX_TEST_ASSERT(errno == EINVAL); // edge case: prefix only errno = 0; - CX_TEST_ASSERT(0 != cx_strtoull(cx_str("0b"), &ull, 2)); + CX_TEST_ASSERT(0 != cx_strtoull("0b", &ull, 2)); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoull(cx_str("b"), &ull, 2)); + CX_TEST_ASSERT(0 != cx_strtoull("b", &ull, 2)); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoull(cx_str("0x"), &ull, 16)); + CX_TEST_ASSERT(0 != cx_strtoull("0x", &ull, 16)); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoull(cx_str("x"), &ull, 16)); + CX_TEST_ASSERT(0 != cx_strtoull("x", &ull, 16)); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 != cx_strtoull(cx_str("#"), &ull, 16)); + CX_TEST_ASSERT(0 != cx_strtoull("#", &ull, 16)); CX_TEST_ASSERT(errno == EINVAL); } } @@ -1501,47 +1503,47 @@ CX_TEST(test_string_to_float) { float f; CX_TEST_DO { - CX_TEST_ASSERT(0 == cx_strtof(cx_str("11.3"), &f)); + CX_TEST_ASSERT(0 == cx_strtof("11.3", &f)); CX_TEST_ASSERT(0 == cx_vcmp_float(11.3f, f)); - CX_TEST_ASSERT(0 == cx_strtof(cx_str("-4.711e+1"), &f)); + CX_TEST_ASSERT(0 == cx_strtof("-4.711e+1", &f)); CX_TEST_ASSERT(0 == cx_vcmp_float(-47.11f, f)); - CX_TEST_ASSERT(0 == cx_strtof(cx_str("1.67262192595e-27"), &f)); + CX_TEST_ASSERT(0 == cx_strtof("1.67262192595e-27", &f)); CX_TEST_ASSERT(0 == cx_vcmp_float(1.67262192595e-27f, f)); - CX_TEST_ASSERT(0 == cx_strtof_lc(cx_str("138,339.4"), &f, '.', ",")); + CX_TEST_ASSERT(0 == cx_strtof_lc("138,339.4", &f, '.', ",")); CX_TEST_ASSERT(0 == cx_vcmp_float(138339.4f, f)); - CX_TEST_ASSERT(0 == cx_strtof_lc(cx_str("138,339.4"), &f, ',', ".")); + CX_TEST_ASSERT(0 == cx_strtof_lc("138,339.4", &f, ',', ".")); CX_TEST_ASSERT(0 == cx_vcmp_float(138.3394f, f)); errno = 0; - CX_TEST_ASSERT(0 != cx_strtof(cx_str("15e"), &f)); + CX_TEST_ASSERT(0 != cx_strtof("15e", &f)); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 != cx_strtof(cx_str("15e+"), &f)); + CX_TEST_ASSERT(0 != cx_strtof("15e+", &f)); CX_TEST_ASSERT(errno == EINVAL); errno = 0; - CX_TEST_ASSERT(0 != cx_strtof(cx_str("15e-"), &f)); + CX_TEST_ASSERT(0 != cx_strtof("15e-", &f)); CX_TEST_ASSERT(errno == EINVAL); - CX_TEST_ASSERT(0 == cx_strtof(cx_str("15e-0"), &f)); + CX_TEST_ASSERT(0 == cx_strtof("15e-0", &f)); CX_TEST_ASSERT(0 == cx_vcmp_float(15.f, f)); - CX_TEST_ASSERT(0 == cx_strtof(cx_str("3e38"), &f)); + CX_TEST_ASSERT(0 == cx_strtof("3e38", &f)); CX_TEST_ASSERT(0 == cx_vcmp_float(3e38f, f)); errno = 0; - CX_TEST_ASSERT(0 != cx_strtof(cx_str("3e39"), &f)); + CX_TEST_ASSERT(0 != cx_strtof("3e39", &f)); CX_TEST_ASSERT(errno == ERANGE); - CX_TEST_ASSERT(0 == cx_strtof(cx_str("-3e38"), &f)); + CX_TEST_ASSERT(0 == cx_strtof("-3e38", &f)); CX_TEST_ASSERT(0 == cx_vcmp_float(-3e38f, f)); errno = 0; - CX_TEST_ASSERT(0 != cx_strtof(cx_str("-3e39"), &f)); + CX_TEST_ASSERT(0 != cx_strtof("-3e39", &f)); CX_TEST_ASSERT(errno == ERANGE); - CX_TEST_ASSERT(0 == cx_strtof(cx_str("1.18e-38"), &f)); + CX_TEST_ASSERT(0 == cx_strtof("1.18e-38", &f)); CX_TEST_ASSERT(0 == cx_vcmp_float(1.18e-38f, f)); errno = 0; - CX_TEST_ASSERT(0 != cx_strtof(cx_str("1.17e-38"), &f)); + CX_TEST_ASSERT(0 != cx_strtof("1.17e-38", &f)); CX_TEST_ASSERT(errno == ERANGE); } } @@ -1549,74 +1551,74 @@ CX_TEST(test_string_to_double) { double d; CX_TEST_DO { - CX_TEST_ASSERT(0 == cx_strtod(cx_str("11.3"), &d)); + CX_TEST_ASSERT(0 == cx_strtod("11.3", &d)); CX_TEST_ASSERT(0 == cx_vcmp_double(11.3, d)); - CX_TEST_ASSERT(0 == cx_strtod(cx_str("13."), &d)); + CX_TEST_ASSERT(0 == cx_strtod("13.", &d)); CX_TEST_ASSERT(0 == cx_vcmp_double(13.0, d)); - CX_TEST_ASSERT(0 == cx_strtod(cx_str("47"), &d)); + CX_TEST_ASSERT(0 == cx_strtod("47", &d)); CX_TEST_ASSERT(0 == cx_vcmp_double(47.0, d)); - CX_TEST_ASSERT(0 == cx_strtod(cx_str("-13.37"), &d)); + CX_TEST_ASSERT(0 == cx_strtod("-13.37", &d)); CX_TEST_ASSERT(0 == cx_vcmp_double(-13.37, d)); - CX_TEST_ASSERT(0 == cx_strtod(cx_str("-4.711e+1"), &d)); + CX_TEST_ASSERT(0 == cx_strtod("-4.711e+1", &d)); CX_TEST_ASSERT(0 == cx_vcmp_double(-47.11, d)); - CX_TEST_ASSERT(0 == cx_strtod(cx_str("1.67262192595e-27"), &d)); + CX_TEST_ASSERT(0 == cx_strtod("1.67262192595e-27", &d)); CX_TEST_ASSERT(0 == cx_vcmp_double(1.67262192595e-27, d)); - CX_TEST_ASSERT(0 == cx_strtod_lc(cx_str("138,339.4"), &d, '.', ",")); + CX_TEST_ASSERT(0 == cx_strtod_lc("138,339.4", &d, '.', ",")); CX_TEST_ASSERT(0 == cx_vcmp_double(138339.4, d)); - CX_TEST_ASSERT(0 == cx_strtod_lc(cx_str("138,339.4"), &d, ',', ".")); + CX_TEST_ASSERT(0 == cx_strtod_lc("138,339.4", &d, ',', ".")); CX_TEST_ASSERT(0 == cx_vcmp_double(138.3394, d)); - CX_TEST_ASSERT(0 == cx_strtod_lc(cx_str("13.37e04.7"), &d, ',', ".")); + CX_TEST_ASSERT(0 == cx_strtod_lc("13.37e04.7", &d, ',', ".")); CX_TEST_ASSERT(0 == cx_vcmp_double(1337e47, d)); d = 47.11; errno = 0; - CX_TEST_ASSERT(0 != cx_strtod(cx_str(""), &d)); + CX_TEST_ASSERT(0 != cx_strtod("", &d)); CX_TEST_ASSERT(errno == EINVAL); CX_TEST_ASSERT(d == 47.11); errno = 0; - CX_TEST_ASSERT(0 != cx_strtod(cx_str(NULL), &d)); + CX_TEST_ASSERT(0 != cx_strtod(CX_NULLSTR, &d)); CX_TEST_ASSERT(errno == EINVAL); CX_TEST_ASSERT(d == 47.11); errno = 0; - CX_TEST_ASSERT(0 != cx_strtod(cx_str("+"), &d)); + CX_TEST_ASSERT(0 != cx_strtod("+", &d)); CX_TEST_ASSERT(errno == EINVAL); CX_TEST_ASSERT(d == 47.11); errno = 0; - CX_TEST_ASSERT(0 != cx_strtod(cx_str("-"), &d)); + CX_TEST_ASSERT(0 != cx_strtod("-", &d)); CX_TEST_ASSERT(errno == EINVAL); CX_TEST_ASSERT(d == 47.11); errno = 0; - CX_TEST_ASSERT(0 != cx_strtod(cx_str("+-5"), &d)); + CX_TEST_ASSERT(0 != cx_strtod("+-5", &d)); CX_TEST_ASSERT(errno == EINVAL); CX_TEST_ASSERT(d == 47.11); errno = 0; - CX_TEST_ASSERT(0 != cx_strtod(cx_str("-+5"), &d)); + CX_TEST_ASSERT(0 != cx_strtod("-+5", &d)); CX_TEST_ASSERT(errno == EINVAL); CX_TEST_ASSERT(d == 47.11); errno = 0; - CX_TEST_ASSERT(0 != cx_strtod(cx_str("++5"), &d)); + CX_TEST_ASSERT(0 != cx_strtod("++5", &d)); CX_TEST_ASSERT(errno == EINVAL); CX_TEST_ASSERT(d == 47.11); errno = 0; - CX_TEST_ASSERT(0 != cx_strtod(cx_str("--5"), &d)); + CX_TEST_ASSERT(0 != cx_strtod("--5", &d)); CX_TEST_ASSERT(errno == EINVAL); CX_TEST_ASSERT(d == 47.11); errno = 0; - CX_TEST_ASSERT(0 != cx_strtod_lc(cx_str("."), &d, '.', "'")); + CX_TEST_ASSERT(0 != cx_strtod_lc(".", &d, '.', "'")); CX_TEST_ASSERT(errno == EINVAL); CX_TEST_ASSERT(d == 47.11); errno = 0; - CX_TEST_ASSERT(0 != cx_strtod(cx_str("19e0x5"), &d)); + CX_TEST_ASSERT(0 != cx_strtod("19e0x5", &d)); CX_TEST_ASSERT(errno == EINVAL); CX_TEST_ASSERT(d == 47.11); @@ -1630,24 +1632,24 @@ float f; double d; CX_TEST_DO { - CX_TEST_ASSERT(0 != cx_strtoll(cx_str("-42 "), &i, 10)); - CX_TEST_ASSERT(0 != cx_strtoll(cx_str(" -42"), &i, 10)); - CX_TEST_ASSERT(0 == cx_strtoll(cx_str("-42"), &i, 10)); + CX_TEST_ASSERT(0 != cx_strtoll("-42 ", &i, 10)); + CX_TEST_ASSERT(0 != cx_strtoll(" -42", &i, 10)); + CX_TEST_ASSERT(0 == cx_strtoll("-42", &i, 10)); CX_TEST_ASSERT(i == -42); - CX_TEST_ASSERT(0 != cx_strtoull(cx_str("42 "), &u, 10)); - CX_TEST_ASSERT(0 != cx_strtoull(cx_str(" 42"), &u, 10)); - CX_TEST_ASSERT(0 == cx_strtoull(cx_str("42"), &u, 10)); + CX_TEST_ASSERT(0 != cx_strtoull("42 ", &u, 10)); + CX_TEST_ASSERT(0 != cx_strtoull(" 42", &u, 10)); + CX_TEST_ASSERT(0 == cx_strtoull("42", &u, 10)); CX_TEST_ASSERT(u == 42); - CX_TEST_ASSERT(0 != cx_strtof(cx_str("13.37 "), &f)); - CX_TEST_ASSERT(0 != cx_strtof(cx_str(" 13.37"), &f)); - CX_TEST_ASSERT(0 == cx_strtof(cx_str("13.37"), &f)); + CX_TEST_ASSERT(0 != cx_strtof("13.37 ", &f)); + CX_TEST_ASSERT(0 != cx_strtof(" 13.37", &f)); + CX_TEST_ASSERT(0 == cx_strtof("13.37", &f)); CX_TEST_ASSERT(0 == cx_vcmp_float(f, 13.37f)); - CX_TEST_ASSERT(0 != cx_strtod(cx_str("13.37 "), &d)); - CX_TEST_ASSERT(0 != cx_strtod(cx_str(" 13.37"), &d)); - CX_TEST_ASSERT(0 == cx_strtod(cx_str("13.37"), &d)); + CX_TEST_ASSERT(0 != cx_strtod("13.37 ", &d)); + CX_TEST_ASSERT(0 != cx_strtod(" 13.37", &d)); + CX_TEST_ASSERT(0 == cx_strtod("13.37", &d)); CX_TEST_ASSERT(0 == cx_vcmp_double(d, 13.37)); } }