about summary refs log tree commit diff stats
path: root/tests/unittests/test_cmd_sub.c
blob: d03f6b5c8f415081af15045c408ad303bfcb8d6c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#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"
#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);
}