add code for checking the return value is actually set and is correct
This commit is contained in:
31
src/main.c
31
src/main.c
@@ -1,13 +1,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "command.h "
|
#include "command.h "
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// this is the underlying function
|
// this is the underlying function
|
||||||
int printButton(const char* string) {
|
int printButton(const char* string) {
|
||||||
|
// printf actually returns the number of chars printed to the screen
|
||||||
return printf(string);
|
return printf(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,22 +17,23 @@ void commandWrapper(void* args, void* ret) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static Inputs_e current_input = BUTTON_DOWN;
|
||||||
Inputs_e getinput() {
|
Inputs_e getinput() {
|
||||||
return BUTTON_DOWN;
|
return current_input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// this is the only part i dont like
|
// 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
|
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
|
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
|
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
|
int button_down_cmd_return_val = 0; // dont leave thing uninstalised
|
||||||
|
|
||||||
static Input_t input_device = (Input_t){
|
static Input_t input_device = (Input_t){
|
||||||
@@ -64,8 +65,22 @@ static Input_t input_device = (Input_t){
|
|||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
// we have our input now we will handle it
|
// 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);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user