mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-21 08:36:20 +00:00
Added cmd_statuses validation tests
This commit is contained in:
72
tests/test_cmd_statuses.c
Normal file
72
tests/test_cmd_statuses.c
Normal file
@@ -0,0 +1,72 @@
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "ui/ui.h"
|
||||
#include "ui/mock_ui.h"
|
||||
|
||||
#include "command/commands.h"
|
||||
|
||||
void cmd_statuses_shows_usage_when_bad_subcmd(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "badcmd", NULL };
|
||||
|
||||
expect_cons_show("Usage: some usage");
|
||||
|
||||
gboolean result = cmd_statuses(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_statuses_shows_usage_when_bad_console_setting(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "console", "badsetting", NULL };
|
||||
|
||||
expect_cons_show("Usage: some usage");
|
||||
|
||||
gboolean result = cmd_statuses(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_statuses_shows_usage_when_bad_chat_setting(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "chat", "badsetting", NULL };
|
||||
|
||||
expect_cons_show("Usage: some usage");
|
||||
|
||||
gboolean result = cmd_statuses(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
|
||||
void cmd_statuses_shows_usage_when_bad_muc_setting(void **state)
|
||||
{
|
||||
mock_cons_show();
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
help->usage = "some usage";
|
||||
gchar *args[] = { "muc", "badsetting", NULL };
|
||||
|
||||
expect_cons_show("Usage: some usage");
|
||||
|
||||
gboolean result = cmd_statuses(args, *help);
|
||||
assert_true(result);
|
||||
|
||||
free(help);
|
||||
}
|
||||
4
tests/test_cmd_statuses.h
Normal file
4
tests/test_cmd_statuses.h
Normal file
@@ -0,0 +1,4 @@
|
||||
void cmd_statuses_shows_usage_when_bad_subcmd(void **state);
|
||||
void cmd_statuses_shows_usage_when_bad_console_setting(void **state);
|
||||
void cmd_statuses_shows_usage_when_bad_chat_setting(void **state);
|
||||
void cmd_statuses_shows_usage_when_bad_muc_setting(void **state);
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "test_cmd_account.h"
|
||||
#include "test_cmd_rooms.h"
|
||||
#include "test_cmd_sub.h"
|
||||
#include "test_cmd_statuses.h"
|
||||
#include "test_history.h"
|
||||
#include "test_jid.h"
|
||||
#include "test_parser.h"
|
||||
@@ -295,6 +296,11 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(contact_available_when_highest_priority_online),
|
||||
unit_test(contact_available_when_highest_priority_chat),
|
||||
|
||||
unit_test(cmd_statuses_shows_usage_when_bad_subcmd),
|
||||
unit_test(cmd_statuses_shows_usage_when_bad_console_setting),
|
||||
unit_test(cmd_statuses_shows_usage_when_bad_chat_setting),
|
||||
unit_test(cmd_statuses_shows_usage_when_bad_muc_setting),
|
||||
|
||||
};
|
||||
return run_tests(tests);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user