From 7f8a105b263cbdccf14be5f5f6bf306fbe217564 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 1 Jan 2019 09:47:15 -0500 Subject: add string test --- test.c | 15 +++++++++++++++ test.h | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/test.c b/test.c index 43e9bf7..2d25648 100644 --- a/test.c +++ b/test.c @@ -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); +} diff --git a/test.h b/test.h index 6eedc6f..7fa1efe 100644 --- a/test.h +++ b/test.h @@ -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); -- cgit v1.2.1