From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 4DFB16DE0C45 for ; Tue, 5 Mar 2019 11:29:47 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.011 X-Spam-Level: X-Spam-Status: No, score=-0.011 tagged_above=-999 required=5 tests=[AWL=-0.010, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0DB_X9FDZD-9 for ; Tue, 5 Mar 2019 11:29:46 -0800 (PST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 41BF36DE0C3B for ; Tue, 5 Mar 2019 11:29:46 -0800 (PST) Received: from remotemail by fethera.tethera.net with local (Exim 4.89) (envelope-from ) id 1h1Fl0-0001Zh-NI; Tue, 05 Mar 2019 14:29:42 -0500 Received: (nullmailer pid 20956 invoked by uid 1000); Tue, 05 Mar 2019 19:29:41 -0000 From: David Bremner To: Matt Armstrong , notmuch@notmuchmail.org Subject: Re: [PATCH] lib/string_map: fix return type of string_cmp In-Reply-To: References: <20190302183412.6822-1-david@tethera.net> Date: Tue, 05 Mar 2019 15:29:41 -0400 Message-ID: <87o96pglwa.fsf@tethera.net> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Mar 2019 19:29:47 -0000 Matt Armstrong 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 < EXPECTED == stdout == a = a b = b c = c d = d e = e == stderr == EOF test_expect_equal_file EXPECTED OUTPUT