2013-12-27 12:25:30 -05: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-24 19:05:13 -05:00
|
|
|
#include "ui/stub_ui.h"
|
2013-12-27 12:25:30 -05:00
|
|
|
|
|
|
|
#include "command/commands.h"
|
|
|
|
|
|
|
|
void cmd_sub_shows_message_when_not_connected(void **state)
|
|
|
|
{
|
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
|
|
gchar *args[] = { NULL };
|
|
|
|
|
2014-12-24 19:05:13 -05:00
|
|
|
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
|
2013-12-27 12:25:30 -05:00
|
|
|
|
|
|
|
expect_cons_show("You are currently not connected.");
|
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_sub(NULL, args, *help);
|
2013-12-27 12:25:30 -05:00
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|
2013-12-27 17:12:39 -05:00
|
|
|
|
|
|
|
void cmd_sub_shows_usage_when_no_arg(void **state)
|
|
|
|
{
|
|
|
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
|
|
|
help->usage = "Some usage";
|
|
|
|
gchar *args[] = { NULL };
|
|
|
|
|
2014-12-24 19:05:13 -05:00
|
|
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
2013-12-27 17:12:39 -05:00
|
|
|
|
|
|
|
expect_cons_show("Usage: Some usage");
|
|
|
|
|
2015-06-16 19:15:28 -04:00
|
|
|
gboolean result = cmd_sub(NULL, args, *help);
|
2013-12-27 17:12:39 -05:00
|
|
|
assert_true(result);
|
|
|
|
|
|
|
|
free(help);
|
|
|
|
}
|