1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-02-02 15:08:15 -05:00
profanity/tests/unittests/test_cmd_sub.c

41 lines
846 B
C
Raw Normal View History

2013-12-27 17:25:30 +00:00
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "xmpp/xmpp.h"
#include "ui/ui.h"
2014-12-25 00:05:13 +00:00
#include "ui/stub_ui.h"
2013-12-27 17:25:30 +00:00
#include "command/commands.h"
2015-07-27 00:04:48 +01:00
#define CMD_SUB "/sub"
2013-12-27 17:25:30 +00:00
void cmd_sub_shows_message_when_not_connected(void **state)
{
gchar *args[] = { NULL };
2014-12-25 00:05:13 +00:00
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
2013-12-27 17:25:30 +00:00
expect_cons_show("You are currently not connected.");
2015-07-27 00:04:48 +01:00
gboolean result = cmd_sub(NULL, CMD_SUB, args);
2013-12-27 17:25:30 +00:00
assert_true(result);
}
2013-12-27 22:12:39 +00:00
void cmd_sub_shows_usage_when_no_arg(void **state)
{
gchar *args[] = { NULL };
2014-12-25 00:05:13 +00:00
will_return(jabber_get_connection_status, JABBER_CONNECTED);
2013-12-27 22:12:39 +00:00
2015-07-27 00:04:48 +01:00
expect_string(cons_bad_cmd_usage, cmd, CMD_SUB);
2013-12-27 22:12:39 +00:00
2015-07-27 00:04:48 +01:00
gboolean result = cmd_sub(NULL, CMD_SUB, args);
2013-12-27 22:12:39 +00:00
assert_true(result);
}