#include "test.h" #include #include #include void test_errors(const char *test_dir) { char *errors_dir = malloc(strlen(test_dir) + 30); sprintf(errors_dir, "%s/errors", test_dir); DIR *dir = opendir(errors_dir); if (!dir) { test_fail("Couldn't open test directory %s", errors_dir); return; } struct dirent *ent; while ((ent = readdir(dir))) { const char *name = ent->d_name; if (strlen(name) >= strlen("x.pom") && strcmp(name + strlen(name) - strlen(".pom"), ".pom") == 0) { printf("Testing %s...\n",name); char *conf_path = malloc(strlen(errors_dir) + strlen(name) + 30); sprintf(conf_path, "%s/errors/%s", test_dir, name); pom_error *error; pom_conf *conf = pom_load_path(conf_path, &error); if (error) { free(error); free(conf_path); continue; } test_fail("Parsing %s didn't produce an error but it should have.", conf_path); pom_conf_free(conf); free(conf_path); } } free(errors_dir); // pom_conf *conf = pom_load_path("../tests"); }