]> git.notmuchmail.org Git - notmuch/blobdiff - test/notmuch-test.h
test: factor out some boilerplate from C tests
[notmuch] / test / notmuch-test.h
diff --git a/test/notmuch-test.h b/test/notmuch-test.h
new file mode 100644 (file)
index 0000000..d39febb
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef _NOTMUCH_TEST_H
+#define _NOTMUCH_TEST_H
+#include <stdio.h>
+#include <notmuch.h>
+
+inline static void
+expect0(int line, notmuch_status_t ret)
+{
+   if (ret) {
+       fprintf (stderr, "line %d: %s\n", line, ret);
+       exit (1);
+   }
+}
+
+#define EXPECT0(v)  expect0(__LINE__, v);
+#endif