From 0110b585b4cfbfb694a1ffceeac05f27e3e91804 Mon Sep 17 00:00:00 2001 From: sirlilpanda <33928689+sirlilpanda@users.noreply.github.com> Date: Sun, 24 Aug 2025 14:52:45 +1200 Subject: [PATCH] add code for checking the return value is actually set and is correct --- src/main.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index 9272dfd..54bc497 100644 --- a/src/main.c +++ b/src/main.c @@ -1,13 +1,13 @@ #include +#include + #include "command.h " #include "command.h" #include "input.h" - - - // this is the underlying function int printButton(const char* string) { + // printf actually returns the number of chars printed to the screen return printf(string); } @@ -17,22 +17,23 @@ void commandWrapper(void* args, void* ret) { } +static Inputs_e current_input = BUTTON_DOWN; Inputs_e getinput() { - return BUTTON_DOWN; + return current_input; } // this is the only part i dont like -const char* button_up_cmd_args = "up button pressed"; +const char* button_up_cmd_args = "up button pressed\n"; int button_up_cmd_return_val = 0; // dont leave thing uninstalised -const char* button_left_cmd_args = "left button pressed"; +const char* button_left_cmd_args = "left button pressed\n"; int button_left_cmd_return_val = 0; // dont leave thing uninstalised -const char* button_right_cmd_args = "right button pressed"; +const char* button_right_cmd_args = "right button pressed\n"; int button_right_cmd_return_val = 0; // dont leave thing uninstalised -const char* button_down_cmd_args = "down button pressed"; +const char* button_down_cmd_args = "down button pressed\n"; int button_down_cmd_return_val = 0; // dont leave thing uninstalised static Input_t input_device = (Input_t){ @@ -64,8 +65,22 @@ static Input_t input_device = (Input_t){ int main() { // we have our input now we will handle it + + // arange + // set that current input is being pressed + current_input = BUTTON_UP; + + // act + // poll the input a handleInput(input_device); + // assert + if ((int)(strlen(button_up_cmd_args)) == button_up_cmd_return_val) { + printf("return value correct"); + } else { + printf("return value incorrect"); + } + return 0; }