From a06304f577b236321b09f3285c8f051554469b2c Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Fri, 19 Jun 2015 15:38:00 -0700 Subject: [PATCH] Add another test and docs --- src/string_compare_guy.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/string_compare_guy.c b/src/string_compare_guy.c index 1ad5d8f..fa6eb3c 100644 --- a/src/string_compare_guy.c +++ b/src/string_compare_guy.c @@ -2,6 +2,9 @@ #include #include +// string_compare_guy compares the contents of the left hand side, length with the contents of the +// right hand side, length and returns 1 if the right hand side (needle) is inside the left hand +// side (haystack). static int string_compare_guy(char* lhs, int llength, char* rhs, int rlength) { char* lnz = malloc(llength + 1); memcpy(lnz, lhs, llength); @@ -30,7 +33,7 @@ int main() { printf("passed\n"); } - printf("trying to find foo in foobar\n"); + printf("trying to find foobar in foo\n"); if(string_compare_guy("foo", 3, "foobar", 6)) { retcode++; printf("failure\n"); @@ -38,5 +41,13 @@ int main() { printf("passed\n"); } + printf("trying to find foo in foobar\n"); + if(string_compare_guy("foobar", 3, "foo", 6)) { + printf("passed\n"); + } else { + retcode++; + printf("failure\n"); + } + return retcode; }