diff --git a/tests/test-mstring.c b/tests/test-mstring.c index 5178e7d2..fd02b3e5 100644 --- a/tests/test-mstring.c +++ b/tests/test-mstring.c @@ -745,10 +745,68 @@ static void test_M_LET(void) #endif } } + +static void test_parse_standard_c_type(void) +{ + M_LET(s, string_t) { +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + char c = 'C'; + M_GET_STRING_ARG(s, c, false); + assert (string_equal_str_p(s, "C")); + + short S = -2; + M_GET_STRING_ARG(s, S, false); + assert (string_equal_str_p(s, "-2")); + + int i = 2; + M_GET_STRING_ARG(s, i, false); + assert (string_equal_str_p(s, "2")); + + long l = 1742; + M_GET_STRING_ARG(s, l, false); + assert (string_equal_str_p(s, "1742")); + + long long ll = -1742548676843540; + M_GET_STRING_ARG(s, ll, false); + assert (string_equal_str_p(s, "-1742548676843540")); + + unsigned short us = 3; + M_GET_STRING_ARG(s, us, false); + assert (string_equal_str_p(s, "3")); + + unsigned int ui = 2; + M_GET_STRING_ARG(s, ui, false); + assert (string_equal_str_p(s, "2")); + + unsigned long ul = 1756; + M_GET_STRING_ARG(s, ul, false); + assert (string_equal_str_p(s, "1756")); + + unsigned long long ull = 1742548676843540; + M_GET_STRING_ARG(s, ull, false); + assert (string_equal_str_p(s, "1742548676843540")); + + float f = -0.5; + M_GET_STRING_ARG(s, f, false); + assert (string_start_with_str_p(s, "-0.5")); + + double d = 2.5; + M_GET_STRING_ARG(s, d, false); + assert (string_start_with_str_p(s, "2.5")); + + long double ld = 27.5; + M_GET_STRING_ARG(s, ld, false); + assert (string_start_with_str_p(s, "27.5")); + +#endif + } +} + int main(void) { test0(); test_M_LET(); + test_parse_standard_c_type(); test_utf8_basic(); test_utf8_it(); test_bounded1();