Files
c_state_pattern/src/main.c
2025-09-01 23:20:13 +12:00

38 lines
1.0 KiB
C

#include "states/state.h"
#include "device.h"
#include <string.h>
int main() {
Device_t device;
initDevice(&device);
// sets the device to off on start up
setDeviceStateToOff(&device);
if (strcmp(device.state.state_name, "off_state.c") != 0) return 0;
// turn on the device
pressPwrButton(&device);
if (strcmp(device.state.state_name, "lock_state.c") != 0) return 0;
// send the current string
pressStrInputButton(&device);
if (strcmp(device.state.state_name, "lock_state.c") != 0) return 0;
// send in the right string
device.entered_string = "pwd";
pressStrInputButton(&device);
if (strcmp(device.state.state_name, "unlock_state.c") != 0) return 0;
// try to enter debug mode
device.entered_string = "dbg";
pressStrInputButton(&device);
if (strcmp(device.state.state_name, "debug_state.c") != 0) return 0;
// try to power down
pressPwrButton(&device);
if (strcmp(device.state.state_name, "off_state.c") != 0) return 0;
return 0;
}