2020-07-07 03:43:28 -04:00
|
|
|
#include <cmocka.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <setjmp.h>
|
2013-12-27 12:25:30 -05:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "xmpp/xmpp.h"
|
|
|
|
|
2014-12-24 19:05:13 -05:00
|
|
|
#include "ui/stub_ui.h"
|
2020-07-07 03:43:28 -04:00
|
|
|
#include "ui/ui.h"
|
2013-12-27 12:25:30 -05:00
|
|
|
|
2016-05-22 18:59:52 -04:00
|
|
|
#include "command/cmd_funcs.h"
|
2013-12-27 12:25:30 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
#define CMD_SUB "/sub"
|
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_sub_shows_message_when_not_connected(void** state)
|
2013-12-27 12:25:30 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { NULL };
|
2013-12-27 12:25:30 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_DISCONNECTED);
|
2013-12-27 12:25:30 -05:00
|
|
|
|
|
|
|
expect_cons_show("You are currently not connected.");
|
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_sub(NULL, CMD_SUB, args);
|
2013-12-27 12:25:30 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|
2013-12-27 17:12:39 -05:00
|
|
|
|
2020-07-07 03:43:28 -04:00
|
|
|
void
|
|
|
|
cmd_sub_shows_usage_when_no_arg(void** state)
|
2013-12-27 17:12:39 -05:00
|
|
|
{
|
2020-07-07 03:43:28 -04:00
|
|
|
gchar* args[] = { NULL };
|
2013-12-27 17:12:39 -05:00
|
|
|
|
2016-05-05 18:51:49 -04:00
|
|
|
will_return(connection_get_status, JABBER_CONNECTED);
|
2013-12-27 17:12:39 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
expect_string(cons_bad_cmd_usage, cmd, CMD_SUB);
|
2013-12-27 17:12:39 -05:00
|
|
|
|
2015-07-26 19:04:48 -04:00
|
|
|
gboolean result = cmd_sub(NULL, CMD_SUB, args);
|
2013-12-27 17:12:39 -05:00
|
|
|
assert_true(result);
|
|
|
|
}
|