about summary refs log tree commit diff stats
path: root/tests/unittests
diff options
context:
space:
mode:
authorSteffen Jaeckel <jaeckel-floss@eyet-services.de>2022-12-27 22:52:12 +0100
committerSteffen Jaeckel <jaeckel-floss@eyet-services.de>2023-01-18 20:02:46 +0100
commit302d0dd576eb72498cba1d17f2e011b56270723e (patch)
tree92b8cdddae3fabc9419cc7cca5d568321d20c304 /tests/unittests
parenta0aa26b6fa65ba625f4a6d3495a345c7120ff16d (diff)
downloadprofani-tty-302d0dd576eb72498cba1d17f2e011b56270723e.tar.gz
let `account_new()` take ownership of passed values
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_cmd_account.c14
-rw-r--r--tests/unittests/test_cmd_connect.c10
-rw-r--r--tests/unittests/test_cmd_join.c32
-rw-r--r--tests/unittests/test_cmd_otr.c4
-rw-r--r--tests/unittests/test_cmd_rooms.c8
5 files changed, 34 insertions, 34 deletions
diff --git a/tests/unittests/test_cmd_account.c b/tests/unittests/test_cmd_account.c
index 04215e88..57949470 100644
--- a/tests/unittests/test_cmd_account.c
+++ b/tests/unittests/test_cmd_account.c
@@ -33,7 +33,7 @@ cmd_account_shows_usage_when_not_connected_and_no_args(void** state)
 void
 cmd_account_shows_account_when_connected_and_no_args(void** state)
 {
-    ProfAccount* account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
+    ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), NULL, NULL,
                                        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
     gchar* args[] = { NULL };
 
@@ -97,7 +97,7 @@ void
 cmd_account_show_shows_account_when_exists(void** state)
 {
     gchar* args[] = { "show", "account_name", NULL };
-    ProfAccount* account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
+    ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), NULL, NULL,
                                        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     expect_any(accounts_get_account, name);
@@ -436,7 +436,7 @@ void
 cmd_account_set_password_sets_password(void** state)
 {
     gchar* args[] = { "set", "a_account", "password", "a_password", NULL };
-    ProfAccount* account = account_new("a_account", NULL, NULL, NULL,
+    ProfAccount* account = account_new(g_strdup("a_account"), NULL, NULL, NULL,
                                        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     expect_any(accounts_account_exists, account_name);
@@ -459,7 +459,7 @@ void
 cmd_account_set_eval_password_sets_eval_password(void** state)
 {
     gchar* args[] = { "set", "a_account", "eval_password", "a_password", NULL };
-    ProfAccount* account = account_new("a_account", NULL, NULL, NULL,
+    ProfAccount* account = account_new(g_strdup("a_account"), NULL, NULL, NULL,
                                        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     expect_any(accounts_account_exists, account_name);
@@ -482,7 +482,7 @@ void
 cmd_account_set_password_when_eval_password_set(void** state)
 {
     gchar* args[] = { "set", "a_account", "password", "a_password", NULL };
-    ProfAccount* account = account_new("a_account", NULL, NULL, "a_password",
+    ProfAccount* account = account_new(g_strdup("a_account"), NULL, NULL, g_strdup("a_password"),
                                        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     expect_any(accounts_account_exists, account_name);
@@ -501,7 +501,7 @@ void
 cmd_account_set_eval_password_when_password_set(void** state)
 {
     gchar* args[] = { "set", "a_account", "eval_password", "a_password", NULL };
-    ProfAccount* account = account_new("a_account", NULL, "a_password", NULL,
+    ProfAccount* account = account_new(g_strdup("a_account"), NULL, g_strdup("a_password"), NULL,
                                        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     expect_any(accounts_account_exists, account_name);
@@ -852,7 +852,7 @@ cmd_account_set_priority_updates_presence_when_account_connected_with_presence(v
     will_return(session_get_account_name, "a_account");
 
 #ifdef HAVE_LIBGPGME
-    ProfAccount* account = account_new("a_account", "a_jid", NULL, NULL, TRUE, NULL, 5222, "a_resource",
+    ProfAccount* account = account_new(g_strdup("a_account"), g_strdup("a_jid"), NULL, NULL, TRUE, NULL, 5222, g_strdup("a_resource"),
                                        NULL, NULL, 10, 10, 10, 10, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     will_return(session_get_account_name, "a_account");
diff --git a/tests/unittests/test_cmd_connect.c b/tests/unittests/test_cmd_connect.c
index d167a5e9..0f6480a0 100644
--- a/tests/unittests/test_cmd_connect.c
+++ b/tests/unittests/test_cmd_connect.c
@@ -123,7 +123,7 @@ void
 cmd_connect_lowercases_argument_with_account(void** state)
 {
     gchar* args[] = { "Jabber_org", NULL };
-    ProfAccount* account = account_new("Jabber_org", "me@jabber.org", "password", NULL,
+    ProfAccount* account = account_new(g_strdup("Jabber_org"), g_strdup("me@jabber.org"), g_strdup("password"), NULL,
                                        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     will_return(connection_get_status, JABBER_DISCONNECTED);
@@ -144,7 +144,7 @@ void
 cmd_connect_asks_password_when_not_in_account(void** state)
 {
     gchar* args[] = { "jabber_org", NULL };
-    ProfAccount* account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
+    ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), NULL, NULL,
                                        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     will_return(connection_get_status, JABBER_DISCONNECTED);
@@ -407,8 +407,8 @@ void
 cmd_connect_shows_message_when_connecting_with_account(void** state)
 {
     gchar* args[] = { "jabber_org", NULL };
-    ProfAccount* account = account_new("jabber_org", "user@jabber.org", "password", NULL,
-                                       TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+    ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("user@jabber.org"), g_strdup("password"), NULL,
+                                       TRUE, NULL, 0, g_strdup("laptop"), NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     will_return(connection_get_status, JABBER_DISCONNECTED);
 
@@ -428,7 +428,7 @@ void
 cmd_connect_connects_with_account(void** state)
 {
     gchar* args[] = { "jabber_org", NULL };
-    ProfAccount* account = account_new("jabber_org", "me@jabber.org", "password", NULL,
+    ProfAccount* account = account_new(g_strdup("jabber_org"), g_strdup("me@jabber.org"), g_strdup("password"), NULL,
                                        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     will_return(connection_get_status, JABBER_DISCONNECTED);
diff --git a/tests/unittests/test_cmd_join.c b/tests/unittests/test_cmd_join.c
index 92766cea..cd187b07 100644
--- a/tests/unittests/test_cmd_join.c
+++ b/tests/unittests/test_cmd_join.c
@@ -64,14 +64,14 @@ cmd_join_shows_error_message_when_invalid_room_jid(void** state)
 void
 cmd_join_uses_account_mucservice_when_no_service_specified(void** state)
 {
-    char* account_name = "an_account";
+    char* account_name = g_strdup("an_account");
     char* room = "room";
     char* nick = "bob";
-    char* account_service = "conference.server.org";
+    char* account_service = g_strdup("conference.server.org");
     char* expected_room = "room@conference.server.org";
     gchar* args[] = { room, "nick", nick, NULL };
-    ProfAccount* account = account_new(account_name, "user@server.org", NULL, NULL,
-                                       TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+    ProfAccount* account = account_new(account_name, g_strdup("user@server.org"), NULL, NULL,
+                                       TRUE, NULL, 0, g_strdup("laptop"), NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     muc_init();
 
@@ -94,12 +94,12 @@ cmd_join_uses_account_mucservice_when_no_service_specified(void** state)
 void
 cmd_join_uses_supplied_nick(void** state)
 {
-    char* account_name = "an_account";
+    char* account_name = g_strdup("an_account");
     char* room = "room@conf.server.org";
     char* nick = "bob";
     gchar* args[] = { room, "nick", nick, NULL };
-    ProfAccount* account = account_new(account_name, "user@server.org", NULL, NULL,
-                                       TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+    ProfAccount* account = account_new(account_name, g_strdup("user@server.org"), NULL, NULL,
+                                       TRUE, NULL, 0, g_strdup("laptop"), NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     muc_init();
 
@@ -122,12 +122,12 @@ cmd_join_uses_supplied_nick(void** state)
 void
 cmd_join_uses_account_nick_when_not_supplied(void** state)
 {
-    char* account_name = "an_account";
+    char* account_name = g_strdup("an_account");
     char* room = "room2@conf.server.org";
-    char* account_nick = "a_nick";
+    char* account_nick = g_strdup("a_nick");
     gchar* args[] = { room, NULL };
-    ProfAccount* account = account_new(account_name, "user@server.org", NULL, NULL,
-                                       TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+    ProfAccount* account = account_new(account_name, g_strdup("user@server.org"), NULL, NULL,
+                                       TRUE, NULL, 0, g_strdup("laptop"), NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     muc_init();
 
@@ -150,15 +150,15 @@ cmd_join_uses_account_nick_when_not_supplied(void** state)
 void
 cmd_join_uses_password_when_supplied(void** state)
 {
-    char* account_name = "an_account";
+    char* account_name = g_strdup("an_account");
     char* room = "room";
     char* password = "a_password";
-    char* account_nick = "a_nick";
-    char* account_service = "a_service";
+    char* account_nick = g_strdup("a_nick");
+    char* account_service = g_strdup("a_service");
     char* expected_room = "room@a_service";
     gchar* args[] = { room, "password", password, NULL };
-    ProfAccount* account = account_new(account_name, "user@server.org", NULL, NULL,
-                                       TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+    ProfAccount* account = account_new(account_name, g_strdup("user@server.org"), NULL, NULL,
+                                       TRUE, NULL, 0, g_strdup("laptop"), NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     muc_init();
 
diff --git a/tests/unittests/test_cmd_otr.c b/tests/unittests/test_cmd_otr.c
index 9fd822ae..ccd219de 100644
--- a/tests/unittests/test_cmd_otr.c
+++ b/tests/unittests/test_cmd_otr.c
@@ -194,8 +194,8 @@ void
 cmd_otr_gen_generates_key_for_connected_account(void** state)
 {
     gchar* args[] = { "gen", NULL };
-    char* account_name = "myaccount";
-    ProfAccount* account = account_new(account_name, "me@jabber.org", NULL, NULL,
+    char* account_name = g_strdup("myaccount");
+    ProfAccount* account = account_new(account_name, g_strdup("me@jabber.org"), NULL, NULL,
                                        TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     will_return(connection_get_status, JABBER_CONNECTED);
diff --git a/tests/unittests/test_cmd_rooms.c b/tests/unittests/test_cmd_rooms.c
index 22c16435..10e8bf2f 100644
--- a/tests/unittests/test_cmd_rooms.c
+++ b/tests/unittests/test_cmd_rooms.c
@@ -50,8 +50,8 @@ cmd_rooms_uses_account_default_when_no_arg(void** state)
 {
     gchar* args[] = { NULL };
 
-    ProfAccount* account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL,
-                                       0, 0, 0, 0, 0, "default_conf_server", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+    ProfAccount* account = account_new(g_strdup("testaccount"), NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL,
+                                       0, 0, 0, 0, 0, g_strdup("default_conf_server"), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     will_return(connection_get_status, JABBER_CONNECTED);
     will_return(session_get_account_name, "account_name");
@@ -90,8 +90,8 @@ cmd_rooms_filter_arg_used_when_passed(void** state)
 {
     gchar* args[] = { "filter", "text", NULL };
 
-    ProfAccount* account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL,
-                                       0, 0, 0, 0, 0, "default_conf_server", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+    ProfAccount* account = account_new(g_strdup("testaccount"), NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL,
+                                       0, 0, 0, 0, 0, g_strdup("default_conf_server"), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
     will_return(connection_get_status, JABBER_CONNECTED);
     will_return(session_get_account_name, "account_name");