diff options
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-x | tests/runner.py | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index 78a83b3e..9d6b1a4e 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -6494,6 +6494,90 @@ PORT: 3979 expected = open(path_from_root('tests', 'ctype', 'output.txt'), 'r').read() self.do_run(src, expected) + def test_strcasecmp(self): + src = r''' + #include <stdio.h> + #include <strings.h> + int sign(int x) { + if (x < 0) return -1; + if (x > 0) return 1; + return 0; + } + int main() { + printf("*\n"); + + printf("%d\n", sign(strcasecmp("hello", "hello"))); + printf("%d\n", sign(strcasecmp("hello1", "hello"))); + printf("%d\n", sign(strcasecmp("hello", "hello1"))); + printf("%d\n", sign(strcasecmp("hello1", "hello1"))); + printf("%d\n", sign(strcasecmp("iello", "hello"))); + printf("%d\n", sign(strcasecmp("hello", "iello"))); + printf("%d\n", sign(strcasecmp("A", "hello"))); + printf("%d\n", sign(strcasecmp("Z", "hello"))); + printf("%d\n", sign(strcasecmp("a", "hello"))); + printf("%d\n", sign(strcasecmp("z", "hello"))); + printf("%d\n", sign(strcasecmp("hello", "a"))); + printf("%d\n", sign(strcasecmp("hello", "z"))); + + printf("%d\n", sign(strcasecmp("Hello", "hello"))); + printf("%d\n", sign(strcasecmp("Hello1", "hello"))); + printf("%d\n", sign(strcasecmp("Hello", "hello1"))); + printf("%d\n", sign(strcasecmp("Hello1", "hello1"))); + printf("%d\n", sign(strcasecmp("Iello", "hello"))); + printf("%d\n", sign(strcasecmp("Hello", "iello"))); + printf("%d\n", sign(strcasecmp("A", "hello"))); + printf("%d\n", sign(strcasecmp("Z", "hello"))); + printf("%d\n", sign(strcasecmp("a", "hello"))); + printf("%d\n", sign(strcasecmp("z", "hello"))); + printf("%d\n", sign(strcasecmp("Hello", "a"))); + printf("%d\n", sign(strcasecmp("Hello", "z"))); + + printf("%d\n", sign(strcasecmp("hello", "Hello"))); + printf("%d\n", sign(strcasecmp("hello1", "Hello"))); + printf("%d\n", sign(strcasecmp("hello", "Hello1"))); + printf("%d\n", sign(strcasecmp("hello1", "Hello1"))); + printf("%d\n", sign(strcasecmp("iello", "Hello"))); + printf("%d\n", sign(strcasecmp("hello", "Iello"))); + printf("%d\n", sign(strcasecmp("A", "Hello"))); + printf("%d\n", sign(strcasecmp("Z", "Hello"))); + printf("%d\n", sign(strcasecmp("a", "Hello"))); + printf("%d\n", sign(strcasecmp("z", "Hello"))); + printf("%d\n", sign(strcasecmp("hello", "a"))); + printf("%d\n", sign(strcasecmp("hello", "z"))); + + printf("%d\n", sign(strcasecmp("Hello", "Hello"))); + printf("%d\n", sign(strcasecmp("Hello1", "Hello"))); + printf("%d\n", sign(strcasecmp("Hello", "Hello1"))); + printf("%d\n", sign(strcasecmp("Hello1", "Hello1"))); + printf("%d\n", sign(strcasecmp("Iello", "Hello"))); + printf("%d\n", sign(strcasecmp("Hello", "Iello"))); + printf("%d\n", sign(strcasecmp("A", "Hello"))); + printf("%d\n", sign(strcasecmp("Z", "Hello"))); + printf("%d\n", sign(strcasecmp("a", "Hello"))); + printf("%d\n", sign(strcasecmp("z", "Hello"))); + printf("%d\n", sign(strcasecmp("Hello", "a"))); + printf("%d\n", sign(strcasecmp("Hello", "z"))); + + printf("%d\n", sign(strncasecmp("hello", "hello", 3))); + printf("%d\n", sign(strncasecmp("hello1", "hello", 3))); + printf("%d\n", sign(strncasecmp("hello", "hello1", 3))); + printf("%d\n", sign(strncasecmp("hello1", "hello1", 3))); + printf("%d\n", sign(strncasecmp("iello", "hello", 3))); + printf("%d\n", sign(strncasecmp("hello", "iello", 3))); + printf("%d\n", sign(strncasecmp("A", "hello", 3))); + printf("%d\n", sign(strncasecmp("Z", "hello", 3))); + printf("%d\n", sign(strncasecmp("a", "hello", 3))); + printf("%d\n", sign(strncasecmp("z", "hello", 3))); + printf("%d\n", sign(strncasecmp("hello", "a", 3))); + printf("%d\n", sign(strncasecmp("hello", "z", 3))); + + printf("*\n"); + + return 0; + } + ''' + self.do_run(src, '''*\n0\n1\n-1\n0\n1\n-1\n-1\n1\n-1\n1\n1\n-1\n0\n1\n-1\n0\n1\n-1\n-1\n1\n-1\n1\n1\n-1\n0\n1\n-1\n0\n1\n-1\n-1\n1\n-1\n1\n1\n-1\n0\n1\n-1\n0\n1\n-1\n-1\n1\n-1\n1\n1\n-1\n0\n0\n0\n0\n1\n-1\n-1\n1\n-1\n1\n1\n-1\n*\n''') + def test_atomic(self): src = ''' #include <stdio.h> |