From b2d01a67f28b562bc1981cd8efc9b0217b81f20d Mon Sep 17 00:00:00 2001 From: Tom Almeida Date: Wed, 14 Mar 2018 10:55:01 +0800 Subject: [PATCH] Actual working tests on strspn and strcspn --- tests/string/strcspn.c | 5 +++-- tests/string/strspn.c | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/string/strcspn.c b/tests/string/strcspn.c index fa433d7e4f..859d880435 100644 --- a/tests/string/strcspn.c +++ b/tests/string/strcspn.c @@ -2,8 +2,9 @@ #include int main(int argc, char* argv[]) { - printf("%ld\n", strcspn("hello", "world")); // should be 2 - printf("%ld\n", strcspn("banana", "world")); // should be 6 + char *world = "world"; + printf("%ld\n", strcspn("hello", world)); // should be 2 + printf("%ld\n", strcspn("banana", world)); // should be 6 return 0; } diff --git a/tests/string/strspn.c b/tests/string/strspn.c index 9e4fc70c5b..52431a70ff 100644 --- a/tests/string/strspn.c +++ b/tests/string/strspn.c @@ -2,9 +2,12 @@ #include int main(int argc, char* argv[]) { - printf("%lu\n", strspn("hello", "hello")); // should be 5 - printf("%lu\n", strspn("world", "wendy")); // should be 1 - printf("%lu\n", strspn("banana", "apple")); // should be 0 + char *hello = "hello"; + char *world = "world"; + char *banana = "banana"; + printf("%lu\n", strspn(hello, "hello")); // should be 5 + printf("%lu\n", strspn(world, "wendy")); // should be 1 + printf("%lu\n", strspn(banana, "apple")); // should be 0 return 0; }