summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrian Lopez <seniorlopez@gmail.com>2018-01-16 13:40:26 -0800
committerBrian Lopez <seniorlopez@gmail.com>2018-01-16 19:33:04 -0800
commitd43974fb5cbfda6ec28fc92b83d03db0af73748b (patch)
treee4463bcef64fa25df880a89003268a956a21af7e /tests
parent5734768b9edaecedaa7b13fed2ce59cb588df7e8 (diff)
downloadlibgit2-d43974fb5cbfda6ec28fc92b83d03db0af73748b.tar.gz
Change trailer API to return a simple array
Diffstat (limited to 'tests')
-rw-r--r--tests/message/trailer.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/tests/message/trailer.c b/tests/message/trailer.c
index 83fc77808..77ad71034 100644
--- a/tests/message/trailer.c
+++ b/tests/message/trailer.c
@@ -6,32 +6,22 @@ struct trailer {
const char *value;
};
-struct cb_state {
- struct trailer *trailer;
-};
-
-static int trailer_cb(const char *key, const char *value, void *st_)
-{
- struct cb_state *st = st_;
-
- cl_assert_equal_s(st->trailer->key, key);
- cl_assert_equal_s(st->trailer->value, value);
-
- st->trailer++;
-
- return 0;
-}
-
static void assert_trailers(const char *message, struct trailer *trailers)
{
- struct cb_state st = { trailers };
+ git_message_trailer_array arr;
- int rc = git_message_trailers(message, trailer_cb, &st);
+ int rc = git_message_trailers(&arr, message);
- cl_assert_equal_s(NULL, st.trailer->key);
- cl_assert_equal_s(NULL, st.trailer->value);
+ cl_assert_equal_i(0, rc);
+
+ for(size_t i=0; i<arr.count; i++) {
+ cl_assert_equal_s(arr.trailers[i].key, trailers[i].key);
+ cl_assert_equal_s(arr.trailers[i].value, trailers[i].value);
+ }
cl_assert_equal_i(0, rc);
+
+ git_message_trailer_array_free(&arr);
}
void test_message_trailer__simple(void)