diff options
author | James Booth <boothj5@gmail.com> | 2013-12-19 21:05:39 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2013-12-19 21:05:39 +0000 |
commit | d56f6dc39b002e16966354b0ad98cf7801260e0c (patch) | |
tree | 07480d1c9e14084dbfc5345a00fc002419ef50d9 /tests/ui | |
parent | b27c5d0f5baa7161231642b14106db2e96065f95 (diff) | |
download | profani-tty-d56f6dc39b002e16966354b0ad98cf7801260e0c.tar.gz |
Added mocks and stubs for cons_show
Diffstat (limited to 'tests/ui')
-rw-r--r-- | tests/ui/mock_ui.c | 51 | ||||
-rw-r--r-- | tests/ui/mock_ui.h | 14 |
2 files changed, 55 insertions, 10 deletions
diff --git a/tests/ui/mock_ui.c b/tests/ui/mock_ui.c index 6e3e190c..c70fbcf4 100644 --- a/tests/ui/mock_ui.c +++ b/tests/ui/mock_ui.c @@ -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) {} diff --git a/tests/ui/mock_ui.h b/tests/ui/mock_ui.h new file mode 100644 index 00000000..76d15614 --- /dev/null +++ b/tests/ui/mock_ui.h @@ -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 |