about summary refs log tree commit diff stats
path: root/tests/test_cmd_win.c
blob: bc19ebf31c3b8c106e75e87b6d304ef80fb1b071 (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
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <glib.h>

#include "ui/ui.h"
#include "ui/stub_ui.h"

#include "command/commands.h"

void cmd_win_shows_message_when_win_doesnt_exist(void **state)
{
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "3", NULL };

    expect_value(ui_switch_win, i, 3);
    will_return(ui_switch_win, FALSE);

    expect_cons_show("Window 3 does not exist.");

    gboolean result = cmd_win(args, *help);
    assert_true(result);

    free(help);
}

void cmd_win_switches_to_given_win_when_exists(void **state)
{
    CommandHelp *help = malloc(sizeof(CommandHelp));
    gchar *args[] = { "12", NULL };

    expect_value(ui_switch_win, i, 12);
    will_return(ui_switch_win, TRUE);

    gboolean result = cmd_win(args, *help);
    assert_true(result);

    free(help);
}