about summary refs log blame commit diff stats
path: root/tests/test_cmd_win.c
blob: 0ff109bca5249b99db3fdb7253eefbfe46d52efb (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; ba
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <glib.h>

#include "ui/ui.h"
#include "ui/mock_ui.h"

#include "command/commands.h"

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

    ui_switch_win_expect_and_return(3, 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 };

    ui_switch_win_expect_and_return(12, TRUE);

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

    free(help);
}