1
0
mirror of https://github.com/meekrosoft/fff synced 2026-01-23 00:15:59 +01:00

Update the examples to use the new fff header

This commit is contained in:
Mike Long
2012-04-26 16:54:56 +01:00
parent 887be4dc5a
commit 1fe87ba155

View File

@@ -1,5 +1,5 @@
#include "UI.h" #include "UI.h"
#include "../fff.h" #include "../fff3.h"
#include "SYSTEM.h" #include "SYSTEM.h"
#include "DISPLAY.h" #include "DISPLAY.h"
@@ -40,22 +40,22 @@ void setup()
RESET_HISTORY(); RESET_HISTORY();
DISPLAY_get_line_capacity_return_val = 2; DISPLAY_get_line_capacity_fake.return_val = 2;
} }
/* Tests go here */ /* Tests go here */
TEST_F(UITests, init_will_initialise_display) TEST_F(UITests, init_will_initialise_display)
{ {
UI_init(); UI_init();
assert(DISPLAY_init_call_count == 1); assert(DISPLAY_init_fake.call_count == 1);
} }
TEST_F(UITests, init_will_register_interrupt_gpio2) TEST_F(UITests, init_will_register_interrupt_gpio2)
{ {
UI_init(); UI_init();
assert(SYSTEM_register_irq_call_count == 1); assert(SYSTEM_register_irq_fake.call_count == 1);
assert(SYSTEM_register_irq_arg0_val == UI_button_irq_handler); assert(SYSTEM_register_irq_fake.arg0_val == UI_button_irq_handler);
assert(SYSTEM_register_irq_arg1_val == IRQ_GPIO_2); assert(SYSTEM_register_irq_fake.arg1_val == IRQ_GPIO_2);
} }
TEST_F(UITests, when_no_irq_then_missed_irq_counter_zero) TEST_F(UITests, when_no_irq_then_missed_irq_counter_zero)
@@ -81,26 +81,26 @@ TEST_F(UITests, when_one_irq_and_valid_callback_then_callback_called)
{ {
UI_register_button_cbk(button_press_cbk); UI_register_button_cbk(button_press_cbk);
UI_button_irq_handler(); UI_button_irq_handler();
assert(button_press_cbk_call_count == 1); assert(button_press_cbk_fake.call_count == 1);
} }
TEST_F(UITests, write_line_outputs_lines_to_display) TEST_F(UITests, write_line_outputs_lines_to_display)
{ {
char msg[] = "helloworld"; char msg[] = "helloworld";
UI_write_line(msg); UI_write_line(msg);
assert(DISPLAY_output_call_count == 1); assert(DISPLAY_output_fake.call_count == 1);
assert(strncmp(DISPLAY_output_arg0_val, msg, 26) == 0); assert(strncmp(DISPLAY_output_fake.arg0_val, msg, 26) == 0);
} }
TEST_F(UITests, when_no_empty_lines_write_line_clears_screen_and_outputs_lines_to_display) TEST_F(UITests, when_no_empty_lines_write_line_clears_screen_and_outputs_lines_to_display)
{ {
DISPLAY_get_line_insert_index_return_val = 2; DISPLAY_get_line_insert_index_fake.return_val = 2;
char msg[] = "helloworld"; char msg[] = "helloworld";
UI_write_line(msg); UI_write_line(msg);
assert(DISPLAY_clear_call_count == 1); assert(DISPLAY_clear_fake.call_count == 1);
assert(DISPLAY_output_call_count == 1); assert(DISPLAY_output_fake.call_count == 1);
// Check the order of the calls: Don't care about the first two: // Check the order of the calls: Don't care about the first two:
// DISPLAY_get_line_capacity and DISPLAY_get_line_insert_index // DISPLAY_get_line_capacity and DISPLAY_get_line_insert_index
assert(call_history_idx == 4); assert(call_history_idx == 4);
@@ -111,12 +111,12 @@ TEST_F(UITests, when_no_empty_lines_write_line_clears_screen_and_outputs_lines_t
TEST_F(UITests, when_empty_lines_write_line_doesnt_clear_screen) TEST_F(UITests, when_empty_lines_write_line_doesnt_clear_screen)
{ {
// given // given
DISPLAY_get_line_insert_index_return_val = 1; DISPLAY_get_line_insert_index_fake.return_val = 1;
char msg[] = "helloworld"; char msg[] = "helloworld";
// when // when
UI_write_line(msg); UI_write_line(msg);
// then // then
assert(DISPLAY_clear_call_count == 0); assert(DISPLAY_clear_fake.call_count == 0);
} }
TEST_F(UITests, when_string_longer_than_26_then_truncated_string_output) TEST_F(UITests, when_string_longer_than_26_then_truncated_string_output)
@@ -127,31 +127,31 @@ TEST_F(UITests, when_string_longer_than_26_then_truncated_string_output)
// when // when
UI_write_line(input); UI_write_line(input);
// then // then
assert(strncmp(expected, DISPLAY_output_arg0_val, 37) == 0); assert(strncmp(expected, DISPLAY_output_fake.arg0_val, 37) == 0);
} }
//TEST_F(UITests, when_outputting_to_full_display_then_previous_inserted) TEST_F(UITests, when_outputting_to_full_display_then_previous_inserted)
//{ {
// // given // given
// DISPLAY_get_line_insert_index_return_val = 1; DISPLAY_get_line_insert_index_fake.return_val = 1;
// char oldest[] = "oldest"; char oldest[] = "oldest";
// char newest[] = "newest"; char newest[] = "newest";
// // when // when
// UI_write_line(oldest); UI_write_line(oldest);
// UI_write_line(newest); UI_write_line(newest);
// // then // then
//
// assert(DISPLAY_output_call_count == 2); assert(DISPLAY_output_fake.call_count == 2);
//
// // fills last line // fills last line
// assert(strncmp(oldest, DISPLAY_output_arg0_val_history[0], 37) == 0); assert(strncmp(oldest, DISPLAY_output_fake.arg0_history[0], 37) == 0);
// //clears //clears
// assert(DISPLAY_clear_call_count == 1); assert(DISPLAY_clear_fake.call_count == 1);
// // inserts old line at first // inserts old line at first
// assert(strncmp(oldest, DISPLAY_output_arg0_val_history[1], 37) == 0); assert(strncmp(oldest, DISPLAY_output_fake.arg0_history[1], 37) == 0);
// // then inserts new line // then inserts new line
// assert(strncmp(newest, DISPLAY_output_arg0_val_history[2], 37) == 0); assert(strncmp(newest, DISPLAY_output_fake.arg0_history[2], 37) == 0);
//} }
int main() int main()
{ {