aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-03-22 23:25:33 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-03-22 23:25:33 +0100
commit8585ddd1dd0123dea622c0d11851a7f8d06f0a49 (patch)
tree33c343a556b9ba2e8009ae290dbb3907d2eb03da
parentFix error when setting attr before ever accessing it. (diff)
downloadcalp-8585ddd1dd0123dea622c0d11851a7f8d06f0a49.tar.gz
calp-8585ddd1dd0123dea622c0d11851a7f8d06f0a49.tar.xz
Add tests to C main.
-rw-r--r--src/main.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 791bc5d3..f086f6f9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -22,14 +22,43 @@ int arg_shift (arg* a) {
}
+#define GETSET(C, KEY) \
+ vcomponent_push_val((C), (KEY), "DUMMY VALUE"); \
+ INFO_F("cline = %p", get_property((C), (KEY)));
+
+/*
+ * Tests defined here instead of in own header to ensure that all the
+ * correct modules are loaded.
+ */
+int run_tests() {
+ NEW(vcomponent, c);
+ INFO(All the following should print a valid pointer ≠ 0x0);
+ GETSET(c, "FILENAME");
+ GETSET(c, "X-HNH-FILENAME");
+ GETSET(c, "DATA");
+ GETSET(c, "DAT");
+ GETSET(c, "DA");
+ GETSET(c, "D");
+ GETSET(c, "A");
+ GETSET(c, "F");
+ FFREE(vcomponent, c);
+ return 0;
+}
+
int main (int argc, char** argv) {
arg args = { .argc = argc, .argv = argv };
+
if (arg_shift(&args) == 0) {
- ERR("Please give vdir or a vcalendar file as first argument");
+ ERR("Please give something to parse, or some other flags");
exit (1);
}
+ if (strcmp(args.argv[0], "--run-tests") == 0) {
+ run_tests();
+ return 0;
+ }
+
char* rootpath = args.argv[0];
SNEW(vcomponent, root, "ROOT", rootpath);
read_vcalendar(&root, rootpath);