2 test_description="message property API"
4 . ./test-lib.sh || exit 1
12 #include <notmuch-test.h>
14 int main (int argc, char** argv)
16 notmuch_database_t *db;
17 notmuch_message_t *message = NULL;
19 notmuch_status_t stat;
21 EXPECT0(notmuch_database_open (argv[1], NOTMUCH_DATABASE_MODE_READ_WRITE, &db));
22 EXPECT0(notmuch_database_find_message(db, "4EFC743A.3060609@april.org", &message));
23 if (message == NULL) {
24 fprintf (stderr, "unable to find message");
30 EXPECT0(notmuch_database_destroy(db));
34 test_begin_subtest "notmuch_message_{add,get,remove}_property"
35 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
37 EXPECT0(notmuch_message_add_property (message, "testkey1", "testvalue1"));
38 EXPECT0(notmuch_message_get_property (message, "testkey1", &val));
39 printf("testkey1[1] = %s\n", val);
40 EXPECT0(notmuch_message_add_property (message, "testkey2", "this value has spaces and = sign"));
41 EXPECT0(notmuch_message_get_property (message, "testkey1", &val));
42 printf("testkey1[2] = %s\n", val);
43 EXPECT0(notmuch_message_get_property (message, "testkey1", &val));
45 EXPECT0(notmuch_message_get_property (message, "testkey2", &val));
46 printf("testkey2 = %s\n", val);
48 /* Add second value for key */
49 EXPECT0(notmuch_message_add_property (message, "testkey2", "zztestvalue3"));
50 EXPECT0(notmuch_message_get_property (message, "testkey2", &val));
51 printf("testkey2 = %s\n", val);
53 /* remove first value for key */
54 EXPECT0(notmuch_message_remove_property (message, "testkey2", "this value has spaces and = sign"));
55 EXPECT0(notmuch_message_get_property (message, "testkey2", &val));
56 printf("testkey2 = %s\n", val);
58 /* remove non-existant value for key */
59 EXPECT0(notmuch_message_remove_property (message, "testkey2", "this value has spaces and = sign"));
60 EXPECT0(notmuch_message_get_property (message, "testkey2", &val));
61 printf("testkey2 = %s\n", val);
63 /* remove only value for key */
64 EXPECT0(notmuch_message_remove_property (message, "testkey2", "zztestvalue3"));
65 EXPECT0(notmuch_message_get_property (message, "testkey2", &val));
66 printf("testkey2 = %s\n", val == NULL ? "NULL" : val);
71 testkey1[1] = testvalue1
72 testkey1[2] = testvalue1
73 testkey2 = this value has spaces and = sign
74 testkey2 = this value has spaces and = sign
75 testkey2 = zztestvalue3
76 testkey2 = zztestvalue3
80 test_expect_equal_file EXPECTED OUTPUT