Re: [PATCH] lib/string_map: fix return type of string_cmp

Subject: Re: [PATCH] lib/string_map: fix return type of string_cmp

Date: Tue, 05 Mar 2019 15:29:41 -0400

To: Matt Armstrong, notmuch@notmuchmail.org

Cc:

From: David Bremner


Matt Armstrong <marmstrong@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]));
}
EOF
cat <<EOF > EXPECTED
== stdout ==
a = a
b = b
c = c
d = d
e = e
== stderr ==
EOF
test_expect_equal_file EXPECTED OUTPUT
_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Thread: