diff options
author | Philip Chimento <philip@endlessm.com> | 2019-11-18 15:45:51 -0800 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2020-11-21 09:13:02 -0800 |
commit | c5fc923e77575f70f4e7a350a867b7b1990b17f3 (patch) | |
tree | 7ef7928fa9fa3022070965a7fcd495852916ac9c /tests/test-utils.h | |
parent | 176328f698cd28a609de764761b0f84d04c84b0d (diff) | |
download | libsoup-c5fc923e77575f70f4e7a350a867b7b1990b17f3.tar.gz |
tests: Add convenient soup_test_assert_handled_by()
This code is repeated a few times, so move it into a macro similar to
soup_test_assert_message_status(). This macro will be used a few more
times in a subsequent commit.
Diffstat (limited to 'tests/test-utils.h')
-rw-r--r-- | tests/test-utils.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test-utils.h b/tests/test-utils.h index 38241cb8..22e5e150 100644 --- a/tests/test-utils.h +++ b/tests/test-utils.h @@ -126,6 +126,24 @@ G_STMT_START { \ } \ } G_STMT_END +#define soup_test_assert_handled_by(msg, string) \ +G_STMT_START { \ + SoupMessage *_msg = (msg); \ + const char *_handled_by; \ + const char *_expected = (char *) (string); \ + char *_message; \ + _handled_by = soup_message_headers_get_one (soup_message_get_response_headers (_msg), \ + "X-Handled-By"); \ + if (G_UNLIKELY (g_strcmp0 (_handled_by, _expected) != 0)) { \ + _message = g_strdup_printf ("Request was handled by %s (expected %s)", \ + _handled_by, _expected); \ + g_assertion_message (G_LOG_DOMAIN, \ + __FILE__, __LINE__, G_STRFUNC, \ + _message); \ + g_free (_message); \ + } \ +} G_STMT_END + #define soup_assert_cmpmem(s1, l1, s2, l2) \ G_STMT_START { \ int __l1 = l1, __l2 = l2; \ |