Skip to content

Instantly share code, notes, and snippets.

@novns
Last active January 19, 2022 12:01
Show Gist options
  • Save novns/c84d6e1efd6304b3076811fef34096fd to your computer and use it in GitHub Desktop.
Save novns/c84d6e1efd6304b3076811fef34096fd to your computer and use it in GitHub Desktop.
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define RESULT_PASS "PASS"
#define RESULT_FAIL "FAIL"
void test_assert(bool result)
{
printf("Assert: %s\n", result ? RESULT_PASS : RESULT_FAIL);
if (!result)
exit(EXIT_FAILURE);
}
void test_strcmp(const char *value_1, const char *value_2)
{
test_assert(value_1 != NULL);
test_assert(value_2 != NULL);
bool result = !strcmp(value_1, value_2);
printf("Test equal: %s\n", result ? RESULT_PASS : RESULT_FAIL);
}
int main()
{
test_strcmp(NULL, "value 1");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment