Files
cproof/tests/unittests/test_cmd_sub.c
Steffen Jaeckel 988d3663d1 Introduce tests/prof_cmocka.h
As 9f2abc75 accidentally got the ordering of some of the includes wrong,
I decided to propose my initial solution again.

Additional to that, I've opened a MR against CMocka to solve this on
their side, since I believe that the current way this is done is not
sustainable [0].

[0] https://gitlab.com/cmocka/cmocka/-/merge_requests/91

Fixes: 9f2abc75 ("Fix tests with gcc15 (uintptr_t)")
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>

CProof note: our new tests need to also be updated.
2025-09-10 14:11:03 +02:00

53 lines
1.1 KiB
C

#include "prof_cmocka.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "xmpp/xmpp.h"
#include "ui/ui.h"
#include "ui/stub_ui.h"
#include "command/cmd_funcs.h"
#define CMD_SUB "/sub"
void
cmd_sub_shows_message_when_not_connected(void** state)
{
gchar* args[] = { NULL };
will_return(connection_get_status, JABBER_DISCONNECTED);
expect_cons_show("You are currently not connected.");
gboolean result = cmd_sub(NULL, CMD_SUB, args);
assert_true(result);
}
void
cmd_sub_shows_usage_when_no_arg(void** state)
{
gchar* args[] = { NULL };
will_return(connection_get_status, JABBER_CONNECTED);
expect_string(cons_bad_cmd_usage, cmd, CMD_SUB);
gboolean result = cmd_sub(NULL, CMD_SUB, args);
assert_true(result);
}
void
test_cmd_sub_malformed_jid(void** state)
{
ProfWin win;
win.type = WIN_CONSOLE;
gchar* args[] = { "request", "@example.com" };
will_return(connection_get_status, JABBER_CONNECTED);
expect_cons_show("Malformed JID: @example.com");
gboolean result = cmd_sub((ProfWin*)&win, CMD_SUB, args);
assert_true(result);
}