c-multihash/tests/c/test_errors_string.c
Jakub Sztandera 171bddef0a change how hashes are defined from enum to define
this way the mapping between hashcodes and hash definitions isn't needed
also it simplfies handling, testing  and allows to return error with
the hash code
2016-07-31 15:43:43 +01:00

23 lines
488 B
C

#include <string.h>
#include "minunit.h"
#include "mh/errors.h"
char error_buf[256];
static char *test_error_messages_exist(void) {
int i = -1;
for (; i > MH_E_LAST; i--) {
sprintf(error_buf, "error code %d has no message", i);
mu_assert(error_buf, strlen(mh_error_string(i)) > 0);
mu_assert(error_buf,
strcmp(mh_error_string(-10000), mh_error_string(i)) != 0);
}
return NULL;
}
static char *mu_all_tests(void) {
mu_run_test(test_error_messages_exist);
return NULL;
}