diff options
author | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-06 23:19:24 +0200 |
---|---|---|
committer | Vasilis Kalintiris <ehostunreach@gmail.com> | 2013-12-07 19:35:52 +0200 |
commit | b369cf755546f62ec1c0f4aa9216459b85bee8e7 (patch) | |
tree | 07b48dc3ca1d37b6a81945a3391fd60c3fd5040b /tests | |
parent | f70f993a856b0ddbef73cefc24f3dafc4cc4e292 (diff) |
Use do_run_from_file() for test_strndup
Diffstat (limited to 'tests')
-rw-r--r-- | tests/core/test_strndup.in | 39 | ||||
-rw-r--r-- | tests/core/test_strndup.out | 6 | ||||
-rw-r--r-- | tests/test_core.py | 42 |
3 files changed, 48 insertions, 39 deletions
diff --git a/tests/core/test_strndup.in b/tests/core/test_strndup.in new file mode 100644 index 00000000..938452a1 --- /dev/null +++ b/tests/core/test_strndup.in @@ -0,0 +1,39 @@ + + //--------------- + //- http://pubs.opengroup.org/onlinepubs/9699919799/functions/strndup.html + //--------------- + + #include <stdio.h> + #include <stdlib.h> + #include <string.h> + + int main(int argc, char **argv) { + const char* source = "strndup - duplicate a specific number of bytes from a string"; + + 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("3:%s\n", strdup_val); + free(strdup_val); + + strdup_val = strndup(source, 60); + printf("4:%s\n", strdup_val); + free(strdup_val); + + strdup_val = strndup(source, 19); + 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; + } +
\ No newline at end of file diff --git a/tests/core/test_strndup.out b/tests/core/test_strndup.out new file mode 100644 index 00000000..681f00cc --- /dev/null +++ b/tests/core/test_strndup.out @@ -0,0 +1,6 @@ +1: +2:strndup +3:strndup - duplicate a specific number of bytes from a string +4:strndup - duplicate a specific number of bytes from a string +5:strndup - duplicate +6: diff --git a/tests/test_core.py b/tests/test_core.py index a1a41b9a..7928adee 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -940,46 +940,10 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co self.do_run_from_file(src, output) def test_strndup(self): - src = ''' - //--------------- - //- http://pubs.opengroup.org/onlinepubs/9699919799/functions/strndup.html - //--------------- - - #include <stdio.h> - #include <stdlib.h> - #include <string.h> - - int main(int argc, char **argv) { - const char* source = "strndup - duplicate a specific number of bytes from a string"; - - 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("3:%s\\n", strdup_val); - free(strdup_val); - - strdup_val = strndup(source, 60); - printf("4:%s\\n", strdup_val); - free(strdup_val); - - strdup_val = strndup(source, 19); - printf("5:%s\\n", strdup_val); - free(strdup_val); - - strdup_val = strndup(source, -1); - printf("6:%s\\n", strdup_val); - free(strdup_val); + test_path = path_from_root('tests', 'core', 'test_strndup') + src, output = (test_path + s for s in ('.in', '.out')) - return 0; - } - ''' - 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') + self.do_run_from_file(src, output) def test_errar(self): src = r''' |