Added mocks and stubs for cons_show
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* mock_ui.h
|
||||
* mock_ui.c
|
||||
*
|
||||
* Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com>
|
||||
*
|
||||
@@ -28,6 +28,46 @@
|
||||
|
||||
char output[256];
|
||||
|
||||
static
|
||||
void _mock_cons_show(const char * const msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
vsnprintf(output, sizeof(output), msg, args);
|
||||
check_expected(output);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static
|
||||
void _stub_cons_show(const char * const msg, ...)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
mock_cons_show(void)
|
||||
{
|
||||
cons_show = _mock_cons_show;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
stub_cons_show(void)
|
||||
{
|
||||
cons_show = _stub_cons_show;
|
||||
}
|
||||
|
||||
void
|
||||
expect_cons_show(char *output)
|
||||
{
|
||||
expect_string(_mock_cons_show, output, output);
|
||||
}
|
||||
|
||||
void
|
||||
expect_cons_show_calls(int n)
|
||||
{
|
||||
expect_any_count(_mock_cons_show, output, n);
|
||||
}
|
||||
|
||||
// ui startup and control
|
||||
void ui_init(void) {}
|
||||
void ui_load_colours(void) {}
|
||||
@@ -196,15 +236,6 @@ void title_bar_set_typing(gboolean is_typing) {}
|
||||
void title_bar_draw(void) {}
|
||||
|
||||
// console window actions
|
||||
void cons_show(const char * const msg, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
vsnprintf(output, sizeof(output), msg, args);
|
||||
check_expected(output);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void cons_about(void) {}
|
||||
void cons_help(void) {}
|
||||
void cons_basic_help(void) {}
|
||||
|
||||
14
tests/ui/mock_ui.h
Normal file
14
tests/ui/mock_ui.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef MOCK_UI_H
|
||||
#define MICK_UI_H
|
||||
|
||||
#include <glib.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
|
||||
void stub_cons_show(void);
|
||||
|
||||
void mock_cons_show(void);
|
||||
void expect_cons_show(char *output);
|
||||
void expect_cons_show_calls(int n);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user