unit1398: add msnprintf tests with negative precision
No binary (build failed)
—
(log yok)
| @@ -40,6 +40,31 @@ static CURLcode test_unit1398(const char *arg) | |
| /* #define curl_msnprintf snprintf */ | |
| + | /* negative precision is treated as if omitted */ |
| + | rc = curl_msnprintf(output, sizeof(output), "%.*s", -1, str); |
| + | fail_unless(rc == 3, "return code should be 3"); |
| + | fail_unless(!strcmp(output, "bug"), "wrong output"); |
| + | |
| + | rc = curl_msnprintf(output, sizeof(output), "%.*s", -1, "0123456789"); |
| + | fail_unless(rc == 10, "return code should be 10"); |
| + | fail_unless(!strcmp(output, "0123456789"), "wrong output"); |
| + | |
| + | rc = curl_msnprintf(output, sizeof(output), "%.*s", 0, "0123456789"); |
| + | fail_unless(rc == 0, "return code should be 0"); |
| + | fail_unless(!strcmp(output, ""), "wrong output"); |
| + | |
| + | rc = curl_msnprintf(output, sizeof(output), "%.*s", -2, str); |
| + | fail_unless(rc == 3, "return code should be 3"); |
| + | fail_unless(!strcmp(output, "bug"), "wrong output"); |
| + | |
| + | rc = curl_msnprintf(output, sizeof(output), "%.*d", -3, 10000); |
| + | fail_unless(rc == 5, "return code should be 5"); |
| + | fail_unless(!strcmp(output, "10000"), "wrong output"); |
| + | |
| + | rc = curl_msnprintf(output, sizeof(output), "%.*d", 0, 1234567); |
| + | fail_unless(rc == 7, "return code should be 0"); |
| + | fail_unless(!strcmp(output, "1234567"), "wrong output"); |
| + | |
| /* without a trailing zero */ | |
| rc = curl_msnprintf(output, 4, "%.*s", width, buf); | |
| fail_unless(rc == 3, "return code should be 3"); | |