summaryrefslogtreecommitdiff
path: root/tests/errors.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/errors.c')
-rw-r--r--tests/errors.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/errors.c b/tests/errors.c
new file mode 100644
index 0000000..8a255ab
--- /dev/null
+++ b/tests/errors.c
@@ -0,0 +1,38 @@
+#include "test.h"
+
+#include <dirent.h>
+#include <stdlib.h>
+#include <string.h>
+
+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");
+}