Debian Codegraph @

src/string_comparison.c

raw symbols SCIP
1 #include <cgreen/string_comparison.h>
2 #ifndef __cplusplus
3 #include <stdbool.h>
4 #endif
5 #include <stddef.h>
6 #include <string.h>
7
8
9 bool strings_are_equal(const char* actual, const char* expected) {
10 /* TODO: if expected is null, warn user to use appropriate non-string assert instead */
11 if ((actual == NULL) && (expected == NULL)) {
12 return true;
13 }
14
15 if ((actual == NULL) || (expected == NULL)) {
16 return false;
17 }
18
19 return (strcmp(actual, expected) == 0);
20 }
21
22 bool string_contains(const char* actual, const char* expected) {
23 /* TODO: if expected is null, warn user */
24 if ((actual == NULL) || (expected == NULL)) {
25 return false;
26 }
27
28 return (strstr(actual, expected) != NULL);
29 }