1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Fix test_jid unittest memleak

Regards https://github.com/profanity-im/profanity/issues/1019
This commit is contained in:
Michael Vetter 2019-10-06 17:07:00 +02:00
parent fd18230cd4
commit ae9ef75bab

View File

@ -22,90 +22,105 @@ void create_jid_from_full_returns_full(void **state)
{ {
Jid *result = jid_create("myuser@mydomain/laptop"); Jid *result = jid_create("myuser@mydomain/laptop");
assert_string_equal("myuser@mydomain/laptop", result->fulljid); assert_string_equal("myuser@mydomain/laptop", result->fulljid);
jid_destroy(result);
} }
void create_jid_from_full_returns_bare(void **state) void create_jid_from_full_returns_bare(void **state)
{ {
Jid *result = jid_create("myuser@mydomain/laptop"); Jid *result = jid_create("myuser@mydomain/laptop");
assert_string_equal("myuser@mydomain", result->barejid); assert_string_equal("myuser@mydomain", result->barejid);
jid_destroy(result);
} }
void create_jid_from_full_returns_resourcepart(void **state) void create_jid_from_full_returns_resourcepart(void **state)
{ {
Jid *result = jid_create("myuser@mydomain/laptop"); Jid *result = jid_create("myuser@mydomain/laptop");
assert_string_equal("laptop", result->resourcepart); assert_string_equal("laptop", result->resourcepart);
jid_destroy(result);
} }
void create_jid_from_full_returns_localpart(void **state) void create_jid_from_full_returns_localpart(void **state)
{ {
Jid *result = jid_create("myuser@mydomain/laptop"); Jid *result = jid_create("myuser@mydomain/laptop");
assert_string_equal("myuser", result->localpart); assert_string_equal("myuser", result->localpart);
jid_destroy(result);
} }
void create_jid_from_full_returns_domainpart(void **state) void create_jid_from_full_returns_domainpart(void **state)
{ {
Jid *result = jid_create("myuser@mydomain/laptop"); Jid *result = jid_create("myuser@mydomain/laptop");
assert_string_equal("mydomain", result->domainpart); assert_string_equal("mydomain", result->domainpart);
jid_destroy(result);
} }
void create_jid_from_full_nolocal_returns_full(void **state) void create_jid_from_full_nolocal_returns_full(void **state)
{ {
Jid *result = jid_create("mydomain/laptop"); Jid *result = jid_create("mydomain/laptop");
assert_string_equal("mydomain/laptop", result->fulljid); assert_string_equal("mydomain/laptop", result->fulljid);
jid_destroy(result);
} }
void create_jid_from_full_nolocal_returns_bare(void **state) void create_jid_from_full_nolocal_returns_bare(void **state)
{ {
Jid *result = jid_create("mydomain/laptop"); Jid *result = jid_create("mydomain/laptop");
assert_string_equal("mydomain", result->barejid); assert_string_equal("mydomain", result->barejid);
jid_destroy(result);
} }
void create_jid_from_full_nolocal_returns_resourcepart(void **state) void create_jid_from_full_nolocal_returns_resourcepart(void **state)
{ {
Jid *result = jid_create("mydomain/laptop"); Jid *result = jid_create("mydomain/laptop");
assert_string_equal("laptop", result->resourcepart); assert_string_equal("laptop", result->resourcepart);
jid_destroy(result);
} }
void create_jid_from_full_nolocal_returns_domainpart(void **state) void create_jid_from_full_nolocal_returns_domainpart(void **state)
{ {
Jid *result = jid_create("mydomain/laptop"); Jid *result = jid_create("mydomain/laptop");
assert_string_equal("mydomain", result->domainpart); assert_string_equal("mydomain", result->domainpart);
jid_destroy(result);
} }
void create_jid_from_full_nolocal_returns_null_localpart(void **state) void create_jid_from_full_nolocal_returns_null_localpart(void **state)
{ {
Jid *result = jid_create("mydomain/laptop"); Jid *result = jid_create("mydomain/laptop");
assert_null(result->localpart); assert_null(result->localpart);
jid_destroy(result);
} }
void create_jid_from_bare_returns_null_full(void **state) void create_jid_from_bare_returns_null_full(void **state)
{ {
Jid *result = jid_create("myuser@mydomain"); Jid *result = jid_create("myuser@mydomain");
assert_null(result->fulljid); assert_null(result->fulljid);
jid_destroy(result);
} }
void create_jid_from_bare_returns_null_resource(void **state) void create_jid_from_bare_returns_null_resource(void **state)
{ {
Jid *result = jid_create("myuser@mydomain"); Jid *result = jid_create("myuser@mydomain");
assert_null(result->resourcepart); assert_null(result->resourcepart);
jid_destroy(result);
} }
void create_jid_from_bare_returns_bare(void **state) void create_jid_from_bare_returns_bare(void **state)
{ {
Jid *result = jid_create("myuser@mydomain"); Jid *result = jid_create("myuser@mydomain");
assert_string_equal("myuser@mydomain", result->barejid); assert_string_equal("myuser@mydomain", result->barejid);
jid_destroy(result);
} }
void create_jid_from_bare_returns_localpart(void **state) void create_jid_from_bare_returns_localpart(void **state)
{ {
Jid *result = jid_create("myuser@mydomain"); Jid *result = jid_create("myuser@mydomain");
assert_string_equal("myuser", result->localpart); assert_string_equal("myuser", result->localpart);
jid_destroy(result);
} }
void create_jid_from_bare_returns_domainpart(void **state) void create_jid_from_bare_returns_domainpart(void **state)
{ {
Jid *result = jid_create("myuser@mydomain"); Jid *result = jid_create("myuser@mydomain");
assert_string_equal("mydomain", result->domainpart); assert_string_equal("mydomain", result->domainpart);
jid_destroy(result);
} }
void create_room_jid_returns_room(void **state) void create_room_jid_returns_room(void **state)
@ -113,6 +128,7 @@ void create_room_jid_returns_room(void **state)
Jid *result = jid_create_from_bare_and_resource("room@conference.domain.org", "myname"); Jid *result = jid_create_from_bare_and_resource("room@conference.domain.org", "myname");
assert_string_equal("room@conference.domain.org", result->barejid); assert_string_equal("room@conference.domain.org", result->barejid);
jid_destroy(result);
} }
void create_room_jid_returns_nick(void **state) void create_room_jid_returns_nick(void **state)
@ -120,6 +136,7 @@ void create_room_jid_returns_nick(void **state)
Jid *result = jid_create_from_bare_and_resource("room@conference.domain.org", "myname"); Jid *result = jid_create_from_bare_and_resource("room@conference.domain.org", "myname");
assert_string_equal("myname", result->resourcepart); assert_string_equal("myname", result->resourcepart);
jid_destroy(result);
} }
void create_with_slash_in_resource(void **state) void create_with_slash_in_resource(void **state)
@ -131,6 +148,8 @@ void create_with_slash_in_resource(void **state)
assert_string_equal("my/nick", result->resourcepart); assert_string_equal("my/nick", result->resourcepart);
assert_string_equal("room@conference.domain.org", result->barejid); assert_string_equal("room@conference.domain.org", result->barejid);
assert_string_equal("room@conference.domain.org/my/nick", result->fulljid); assert_string_equal("room@conference.domain.org/my/nick", result->fulljid);
jid_destroy(result);
} }
void create_with_at_in_resource(void **state) void create_with_at_in_resource(void **state)
@ -142,6 +161,8 @@ void create_with_at_in_resource(void **state)
assert_string_equal("my@nick", result->resourcepart); assert_string_equal("my@nick", result->resourcepart);
assert_string_equal("room@conference.domain.org", result->barejid); assert_string_equal("room@conference.domain.org", result->barejid);
assert_string_equal("room@conference.domain.org/my@nick", result->fulljid); assert_string_equal("room@conference.domain.org/my@nick", result->fulljid);
jid_destroy(result);
} }
void create_with_at_and_slash_in_resource(void **state) void create_with_at_and_slash_in_resource(void **state)
@ -153,6 +174,8 @@ void create_with_at_and_slash_in_resource(void **state)
assert_string_equal("my@nick/something", result->resourcepart); assert_string_equal("my@nick/something", result->resourcepart);
assert_string_equal("room@conference.domain.org", result->barejid); assert_string_equal("room@conference.domain.org", result->barejid);
assert_string_equal("room@conference.domain.org/my@nick/something", result->fulljid); assert_string_equal("room@conference.domain.org/my@nick/something", result->fulljid);
jid_destroy(result);
} }
void create_full_with_trailing_slash(void **state) void create_full_with_trailing_slash(void **state)
@ -164,6 +187,8 @@ void create_full_with_trailing_slash(void **state)
assert_string_equal("nick/", result->resourcepart); assert_string_equal("nick/", result->resourcepart);
assert_string_equal("room@conference.domain.org", result->barejid); assert_string_equal("room@conference.domain.org", result->barejid);
assert_string_equal("room@conference.domain.org/nick/", result->fulljid); assert_string_equal("room@conference.domain.org/nick/", result->fulljid);
jid_destroy(result);
} }
void returns_fulljid_when_exists(void **state) void returns_fulljid_when_exists(void **state)
@ -173,6 +198,8 @@ void returns_fulljid_when_exists(void **state)
char *result = jid_fulljid_or_barejid(jid); char *result = jid_fulljid_or_barejid(jid);
assert_string_equal("localpart@domainpart/resourcepart", result); assert_string_equal("localpart@domainpart/resourcepart", result);
jid_destroy(jid);
} }
void returns_barejid_when_fulljid_not_exists(void **state) void returns_barejid_when_fulljid_not_exists(void **state)
@ -182,4 +209,6 @@ void returns_barejid_when_fulljid_not_exists(void **state)
char *result = jid_fulljid_or_barejid(jid); char *result = jid_fulljid_or_barejid(jid);
assert_string_equal("localpart@domainpart", result); assert_string_equal("localpart@domainpart", result);
jid_destroy(jid);
} }