Removed comments describing changes. Fixed warnings reported by gcc in the test suite
This commit is contained in:
@@ -4,10 +4,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static int int_eq(void* x, void* y) { return (*(int*)x == *(int*)y); }
|
||||
static void int_print(void* x) { printf("'%i'", *((int*)x)); }
|
||||
static int string_eq(void* x, void* y) { return (strcmp(x, y) == 0); }
|
||||
static void string_print(void* x) { printf("'%s'", (char*)x); }
|
||||
static int int_eq(const void* x, const void* y) { return (*(int*)x == *(int*)y); }
|
||||
static void int_print(const void* x) { printf("'%i'", *((int*)x)); }
|
||||
static int string_eq(const void* x, const void* y) { return (strcmp(x, y) == 0); }
|
||||
static void string_print(const void* x) { printf("'%s'", (char*)x); }
|
||||
|
||||
void test_ident(void) {
|
||||
|
||||
|
@@ -43,11 +43,11 @@ void test_grammar(void) {
|
||||
mpc_ast_new("char", "+"),
|
||||
mpc_ast_new("product|value|regex", "5"));
|
||||
|
||||
PT_ASSERT(mpc_test_pass(Maths, " 24 ", t0, (int(*)(void*,void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(void*))mpc_ast_print));
|
||||
PT_ASSERT(mpc_test_pass(Maths, "(5)", t1, (int(*)(void*,void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(void*))mpc_ast_print));
|
||||
PT_ASSERT(mpc_test_pass(Maths, "(4 * 2 * 11 + 2) + 5", t2, (int(*)(void*,void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(void*))mpc_ast_print));
|
||||
PT_ASSERT(mpc_test_fail(Maths, "a", t0, (int(*)(void*,void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(void*))mpc_ast_print));
|
||||
PT_ASSERT(mpc_test_fail(Maths, "2b+4", t0, (int(*)(void*,void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(void*))mpc_ast_print));
|
||||
PT_ASSERT(mpc_test_pass(Maths, " 24 ", t0, (int(*)(const void*,const void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(const void*))mpc_ast_print));
|
||||
PT_ASSERT(mpc_test_pass(Maths, "(5)", t1, (int(*)(const void*,const void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(const void*))mpc_ast_print));
|
||||
PT_ASSERT(mpc_test_pass(Maths, "(4 * 2 * 11 + 2) + 5", t2, (int(*)(const void*,const void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(const void*))mpc_ast_print));
|
||||
PT_ASSERT(mpc_test_fail(Maths, "a", t0, (int(*)(const void*,const void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(const void*))mpc_ast_print));
|
||||
PT_ASSERT(mpc_test_fail(Maths, "2b+4", t0, (int(*)(const void*,const void*))mpc_ast_eq, (mpc_dtor_t)mpc_ast_delete, (void(*)(const void*))mpc_ast_print));
|
||||
|
||||
mpc_ast_delete(t0);
|
||||
mpc_ast_delete(t1);
|
||||
|
@@ -94,6 +94,7 @@ static int assert_err_num = 0;
|
||||
|
||||
void pt_assert_run(int result, const char* expr, const char* func, const char* file, int line) {
|
||||
|
||||
(void) func;
|
||||
num_asserts++;
|
||||
test_passing = test_passing && result;
|
||||
|
||||
@@ -116,6 +117,7 @@ static void ptest_signal(int sig) {
|
||||
case SIGFPE: sprintf(assert_err_buff, " %i. Division by Zero\n", assert_err_num+1); break;
|
||||
case SIGILL: sprintf(assert_err_buff, " %i. Illegal Instruction\n", assert_err_num+1); break;
|
||||
case SIGSEGV: sprintf(assert_err_buff, " %i. Segmentation Fault\n", assert_err_num+1); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
assert_err_num++;
|
||||
@@ -134,7 +136,7 @@ static void ptest_signal(int sig) {
|
||||
static void pt_title_case(char* output, const char* input) {
|
||||
|
||||
int space = 1;
|
||||
unsigned int i;
|
||||
size_t i;
|
||||
|
||||
strcpy(output, input);
|
||||
|
||||
@@ -213,7 +215,7 @@ static char current_suite[MAX_NAME];
|
||||
|
||||
int pt_run(void) {
|
||||
|
||||
unsigned int i;
|
||||
int i;
|
||||
double total;
|
||||
|
||||
printf(" \n");
|
||||
|
@@ -4,14 +4,14 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static int string_eq(void* x, void* y) { return (strcmp(x, y) == 0); }
|
||||
static void string_print(void* x) { printf("'%s'", (char*)x); }
|
||||
static int string_eq(const void* x, const void* y) { return (strcmp(x, y) == 0); }
|
||||
static void string_print(const void* x) { printf("'%s'", (char*)x); }
|
||||
|
||||
int regex_test_pass(mpc_parser_t *p, char* value, char* match) {
|
||||
int regex_test_pass(mpc_parser_t *p, const char* value, const char* match) {
|
||||
return mpc_test_pass(p, value, match, string_eq, free, string_print);
|
||||
}
|
||||
|
||||
int regex_test_fail(mpc_parser_t *p, char* value, char* match) {
|
||||
int regex_test_fail(mpc_parser_t *p, const char* value, const char* match) {
|
||||
return mpc_test_fail(p, value, match, string_eq, free, string_print);
|
||||
}
|
||||
|
||||
|
@@ -5,6 +5,7 @@ void suite_regex(void);
|
||||
void suite_grammar(void);
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
(void) argc; (void) argv;
|
||||
pt_add_suite(suite_core);
|
||||
pt_add_suite(suite_regex);
|
||||
pt_add_suite(suite_grammar);
|
||||
|
Reference in New Issue
Block a user