diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-01-01 09:47:15 -0500 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-01-01 09:47:15 -0500 |
commit | 7f8a105b263cbdccf14be5f5f6bf306fbe217564 (patch) | |
tree | a72cee129177e0e8545dfa41a7d276c0b91a406a | |
parent | 30494889831c3ab4544fb82f5cfbe7a096d931fd (diff) |
add string test
-rw-r--r-- | test.c | 15 | ||||
-rw-r--r-- | test.h | 4 |
2 files changed, 19 insertions, 0 deletions
@@ -66,3 +66,18 @@ void test_bool_imp(const char *expression, int result, int expected) int success = (result && expected) || (!result && !expected); print_result(success, "%s%s", expected ? "" : "!", expression); } + +void test_string_imp(const char *expression, const char *totest, const char *tocompare) +{ + int success = 1; + int i; + for (i = 0; totest[i] != '\0'; i++) { + if (totest[i] != tocompare[i]) { + success = 0; + } + } + if (tocompare[i] != '\0') { + success = 0; + } + print_result(success, "%s == \"%s\"", expression, tocompare); +} @@ -11,5 +11,9 @@ void test_bool_imp(const char *, int, int); #define test_false(expression) test_bool_imp(#expression, expression, 0) #define test_true(expression) test_bool_imp(#expression, expression, 1) +void test_string_imp(const char*, const char*, const char*); +#define test_string(expression, string) test_string_imp(#expression, expression, string) + void test_assert(void); void test_ctype(void); +void test_locale(void); |