Back to home page

Enduro/X

 
 

    


0001 #include <cgreen/string_comparison.h>
0002 #ifndef __cplusplus
0003 #include <stdbool.h>
0004 #endif
0005 #include <stddef.h>
0006 #include <string.h>
0007 
0008 #ifdef __cplusplus
0009 namespace cgreen {
0010 #endif
0011 
0012 bool strings_are_equal(const char* actual, const char* expected) {
0013     /* TODO: if expected is null, warn user to use appropriate non-string assert instead */
0014     if ((actual == NULL) && (expected == NULL)) {
0015         return true;
0016     }
0017 
0018     if ((actual == NULL) || (expected == NULL)) {
0019         return false;
0020     }
0021 
0022     return (strcmp(actual, expected) == 0);
0023 }
0024 
0025 bool string_contains(const char* actual, const char* expected) {
0026     /* TODO: if expected is null, warn user */
0027     if ((actual == NULL) || (expected == NULL)) {
0028         return false;
0029     }
0030 
0031     return (strstr(actual, expected) != NULL);
0032 }
0033 
0034 
0035 #ifdef __cplusplus
0036 }
0037 #endif