[PATCH] lib/string_map: fix return type of string_cmp
Matt Armstrong
marmstrong at google.com
Tue Mar 5 16:45:29 PST 2019
David Bremner <david at tethera.net> writes:
> Matt Armstrong <marmstrong at google.com> writes:
>
>> Perhaps some unit tests for _notmuch_string_map would be worthwhile?
>>
>
> Thanks for the feedback. At first I thought this would be too hard/intrusive,
> since the string_map functions are not exported, but I realized
> n_message_property_get is a thin wrapper on _notmuch_string_map_get, so
> I added the following test. Most of the searches fail before the patch.
>
> test_begin_subtest "testing string map binary search (via message properties)"
> cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
> {
> char *keys[] = {"a", "b", "c", "d", "e", NULL};
> for (int i=0; keys[i]; i++)
> EXPECT0(notmuch_message_add_property (message, keys[i], keys[i]));
>
> for (int i=0; keys[i]; i++) {
> EXPECT0(notmuch_message_get_property (message, keys[i], &val));
> printf("%s = %s\n", keys[i], val);
> }
>
> for (int i=0; keys[i]; i++)
> EXPECT0(notmuch_message_remove_property (message, keys[i], keys[i]));
> }
Nice. The test could even go further and verify that get_property fails
after the properties are removed.
More information about the notmuch
mailing list