Replace functions which called once with their bodies
[pidgin-git.git] / libpurple / protocols / jabber / tests / test_jabber_digest_md5.c
blobbb2e05a10fa2cfa500884e0b99f7319f03fa96cb
1 #include <glib.h>
3 #include "util.h"
4 #include "protocols/jabber/auth_digest_md5.h"
5 #include "protocols/jabber/jutil.h"
7 static void
8 test_jabber_digest_md5_parsing(void) {
9 GHashTable *table;
10 const gchar *value = NULL;
12 #define check_value(name, expected) G_STMT_START {\
13 value = g_hash_table_lookup(table, (name)); \
14 g_assert_nonnull(value); \
15 g_assert_cmpstr((expected), ==, value); \
16 } G_STMT_END
18 table = jabber_auth_digest_md5_parse("r=\"realm\",token= \" asdf\"");
19 check_value("r", "realm");
20 check_value("token", "asdf");
21 g_hash_table_destroy(table);
23 table = jabber_auth_digest_md5_parse("r=\"a\", token= \" asdf\"");
24 check_value("r", "a");
25 check_value("token", "asdf");
26 g_hash_table_destroy(table);
28 table = jabber_auth_digest_md5_parse("r=\"\", token= \" asdf\"");
29 check_value("r", "");
30 check_value("token", "asdf");
31 g_hash_table_destroy(table);
33 table = jabber_auth_digest_md5_parse("realm=\"somerealm\",nonce=\"OA6MG9tEQGm2hh\",qop=\"auth\",charset=utf-8,algorithm=md5-sess");
34 check_value("realm", "somerealm");
35 check_value("nonce", "OA6MG9tEQGm2hh");
36 check_value("qop", "auth");
37 check_value("charset", "utf-8");
38 check_value("algorithm", "md5-sess");
39 g_hash_table_destroy(table);
42 gint
43 main(gint argc, gchar **argv) {
44 g_test_init(&argc, &argv, NULL);
46 g_test_add_func("/jabber/digest/md5/parsing",
47 test_jabber_digest_md5_parsing);
49 return g_test_run();