Skip to content
Snippets Groups Projects
Commit c4620be9 authored by Andrii Zymohliad's avatar Andrii Zymohliad
Browse files

Prettify strpbrk and strstr tests

parent 1e969afd
No related branches found
No related tags found
1 merge request!75Implement strstr() and strpbrk() from string.h
...@@ -2,20 +2,19 @@ ...@@ -2,20 +2,19 @@
#include <stdio.h> #include <stdio.h>
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
char* str = "The quick drawn fix jumps over the lazy bug"; char* source = "The quick drawn fix jumps over the lazy bug";
// should be "The quick drawn fix jumps over the lazy bug" // should be "The quick drawn fix jumps over the lazy bug"
char* str1 = strpbrk(str, "From The Very Beginning"); char* res1 = strpbrk(source, "From The Very Beginning");
printf("%s\n", (str1) ? str1 : "NULL"); printf("%s\n", (res1) ? res1 : "NULL");
// should be "lazy bug" // should be "lazy bug"
char* str2 = strpbrk(str, "lzbg"); char* res2 = strpbrk(source, "lzbg");
printf("%s\n", (str2) ? str2 : "NULL"); printf("%s\n", (res2) ? res2 : "NULL");
// should be "NULL" // should be "NULL"
char* str3 = strpbrk(str, "404"); char* res3 = strpbrk(source, "404");
printf("%s\n", (str3) ? str3 : "NULL"); printf("%s\n", (res3) ? res3 : "NULL");
return 0; return 0;
} }
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
// should be "rust" // should be "rust"
char* str1 = strstr("In relibc we trust", "rust"); char* res1 = strstr("In relibc we trust", "rust");
printf("%s\n", (str1) ? str1 : "NULL"); printf("%s\n", (res1) ? res1 : "NULL");
// should be "libc we trust" // should be "libc we trust"
char* str2 = strstr("In relibc we trust", "libc"); char* res2 = strstr("In relibc we trust", "libc");
printf("%s\n", (str2) ? str2 : "NULL"); printf("%s\n", (res2) ? res2 : "NULL");
// should be "NULL" // should be "NULL"
char* str3 = strstr("In relibc we trust", "bugs"); char* res3 = strstr("In relibc we trust", "bugs");
printf("%s\n", (str3) ? str3 : "NULL"); printf("%s\n", (res3) ? res3 : "NULL");
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment