X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2FT610-message-property.sh;h=b87742305f506627421c5a577bfff0fe5ab13e36;hp=0abef82433d7742cc84577c9836ff7b528d7599d;hb=92149485cb5cd4af3d2c6c4856a2423da92dc727;hpb=f3f4297c7fb1ab57c1479e1c383ca5b35aae0700 diff --git a/test/T610-message-property.sh b/test/T610-message-property.sh index 0abef824..b8774230 100755 --- a/test/T610-message-property.sh +++ b/test/T610-message-property.sh @@ -100,6 +100,41 @@ cat <<'EOF' >EXPECTED EOF test_expect_equal_file EXPECTED OUTPUT +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])); + EXPECT0(notmuch_message_get_property (message, keys[i], &val)); + printf("%s = %s\n", keys[i], val == NULL ? "NULL" : val); + } +} +EOF +cat < EXPECTED +== stdout == +a = a +b = b +c = c +d = d +e = e +a = NULL +b = NULL +c = NULL +d = NULL +e = NULL +== stderr == +EOF +test_expect_equal_file EXPECTED OUTPUT + test_begin_subtest "notmuch_message_get_properties: empty list" cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} { @@ -151,6 +186,18 @@ EXPECT0(notmuch_message_add_property (message, "testkey3", "testvalue3")); EXPECT0(notmuch_message_add_property (message, "testkey3", "alice3")); print_properties (message, "testkey", FALSE); EOF +# expected: 4 values for testkey1, 3 values for testkey3 +# they are not guaranteed to be sorted, so sort them, leaving the first +# line '== stdout ==' and the end ('== stderr ==' and whatever error +# may have been printed) alone +mv OUTPUT unsorted_OUTPUT +awk ' NR == 1 { print; next } \ + NR < 6 { print | "sort"; next } \ + NR == 6 { close("sort") } \ + NR < 9 { print | "sort"; next } \ + NR == 9 { close("sort") } \ + { print }' unsorted_OUTPUT > OUTPUT +rm unsorted_OUTPUT cat <<'EOF' >EXPECTED == stdout == alice