add code for checking the return value is actually set and is correct

This commit is contained in:
sirlilpanda
2025-08-24 14:52:45 +12:00
parent cf627eac0d
commit 0110b585b4

View File

@@ -1,13 +1,13 @@
#include <stdio.h>
#include <string.h>
#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;
}