diff options
Diffstat (limited to 'tests/test_common.c')
-rw-r--r-- | tests/test_common.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_common.c b/tests/test_common.c index 3804245e..233c9f5b 100644 --- a/tests/test_common.c +++ b/tests/test_common.c @@ -93,6 +93,26 @@ int TEST_STR_EQ(const char* result, const char* expected_result, } +int TEST_STR_NEQ(const char* result, const char* not_expected, + const char* testname) { + + if (!result || !not_expected) { + fprintf(stderr, "%s Test " COL_RED "FAILED\n" COL_STOP, testname); + fprintf(stderr, " String compare with NULL\n"); + gTestSuccess = 0; + return 0; + } else if (strcmp(result, not_expected)) { + fprintf(stderr, "%s Test " COL_GREEN "PASSED\n" COL_STOP, testname); + return 1; + } else { + fprintf(stderr, "%s Test " COL_RED "FAILED\n" COL_STOP, testname); + fprintf(stderr, " Didn't expect: \"%s\", but got it\n", not_expected); + gTestSuccess = 0; + return 0; + } + +} + int TEST_SUCC(int result, const char* testname) { if (result == 0) { fprintf(stderr, "%s Test " COL_GREEN "PASSED\n" COL_STOP, testname); |