]> git.notmuchmail.org Git - notmuch/blobdiff - test/symbol-test.cc
test: check argc in symbol-test
[notmuch] / test / symbol-test.cc
index 3e96c034e13e94412285bcde6dd2d74e870993d2..7454838bfd3125e2de08ad9f5fd9977363900e87 100644 (file)
@@ -1,18 +1,30 @@
 #include <stdio.h>
+#include <stdlib.h>
 #include <xapian.h>
 #include <notmuch.h>
 
+int main (int argc, char** argv)
+{
+    notmuch_database_t *notmuch;
+    char *message = NULL;
 
-int main() {
-  notmuch_database_t *notmuch;
-  notmuch_database_open("fakedb", NOTMUCH_DATABASE_MODE_READ_ONLY, &notmuch);
+    if (argc != 3)
+       return 1;
 
-  try {
-    (void) new Xapian::WritableDatabase("./nonexistant", Xapian::DB_OPEN);
-  } catch (const Xapian::Error &error) {
-    printf("caught %s\n", error.get_msg().c_str());
-    return 0;
-  }
+    if (notmuch_database_open_verbose (argv[1], NOTMUCH_DATABASE_MODE_READ_ONLY,
+                                      &notmuch, &message)) {
+       if (message) {
+           fputs (message, stderr);
+           free (message);
+       }
+    }
 
-  return 1;
+    try {
+       (void) new Xapian::WritableDatabase (argv[2], Xapian::DB_OPEN);
+    } catch (const Xapian::Error &error) {
+       printf("caught %s\n", error.get_msg().c_str());
+       return 0;
+    }
+
+    return 1;
 }