diff options
author | Aleksander Guryanov <caiiiycuk@gmail.com> | 2012-05-29 20:07:28 +0700 |
---|---|---|
committer | Aleksander Guryanov <caiiiycuk@gmail.com> | 2012-05-29 20:07:28 +0700 |
commit | edb0920e82300069f8b0ccdc405463f2e44079d8 (patch) | |
tree | e89f44bb4e0b9f1f09772304750866bb6e8ba269 /tests/runner.py | |
parent | b4bfabda973af6a14ebee6de1191a476feeed125 (diff) |
Fix behavior strndup whern size <= 0, in this case strndup returns empty string
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-x | tests/runner.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/runner.py b/tests/runner.py index 4064af15..cc3811a2 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -1406,26 +1406,34 @@ m_divisor is 1091269979 int main(int argc, char **argv) { const char* source = "strndup - duplicate a specific number of bytes from a string"; - char* strdup_val = strndup(source, 7); - printf("%s\\n", strdup_val); + char* strdup_val = strndup(source, 0); + printf("1:%s\\n", strdup_val); + free(strdup_val); + + strdup_val = strndup(source, 7); + printf("2:%s\\n", strdup_val); free(strdup_val); strdup_val = strndup(source, 1000); - printf("%s\\n", strdup_val); + printf("3:%s\\n", strdup_val); free(strdup_val); strdup_val = strndup(source, 60); - printf("%s\\n", strdup_val); + printf("4:%s\\n", strdup_val); free(strdup_val); strdup_val = strndup(source, 19); - printf("%s\\n", strdup_val); + printf("5:%s\\n", strdup_val); + free(strdup_val); + + strdup_val = strndup(source, -1); + printf("6:%s\\n", strdup_val); free(strdup_val); return 0; } ''' - self.do_run(src, 'strndup\nstrndup - duplicate a specific number of bytes from a string\nstrndup - duplicate a specific number of bytes from a string\nstrndup - duplicate\n') + self.do_run(src, '1:\n2:strndup\n3:strndup - duplicate a specific number of bytes from a string\n4:strndup - duplicate a specific number of bytes from a string\n5:strndup - duplicate\n6:\n') def test_errar(self): src = r''' |