feat: add client tests, status FIFO, and evaluation docs
This commit is contained in:
committed by
Loic Coenen (aider)
parent
998406616a
commit
791744beeb
88
client/tests/test_status_parse.c
Normal file
88
client/tests/test_status_parse.c
Normal file
@@ -0,0 +1,88 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum { STATE_IDLE, STATE_RECORD, STATE_LOOPING, STATE_PAUSED } ChannelState;
|
||||
|
||||
bool parse_status_line(const char *line, int *ch, int *scene, ChannelState *state);
|
||||
|
||||
static int test_parse_idle(void) {
|
||||
printf("Test parse_status_line: IDLE\n");
|
||||
int ch, sc; ChannelState st;
|
||||
if (!parse_status_line("CH=0 SC=0 STATE=IDLE\n", &ch, &sc, &st)) {
|
||||
fprintf(stderr, " FAIL: parse returned false\n");
|
||||
return 1;
|
||||
}
|
||||
if (ch != 0 || sc != 0 || st != STATE_IDLE) {
|
||||
fprintf(stderr, " FAIL: expected (0,0,IDLE), got (%d,%d,%d)\n", ch, sc, st);
|
||||
return 1;
|
||||
}
|
||||
printf(" PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_parse_recording(void) {
|
||||
printf("Test parse_status_line: RECORD\n");
|
||||
int ch, sc; ChannelState st;
|
||||
if (!parse_status_line("CH=0 SC=0 STATE=RECORD\n", &ch, &sc, &st)) {
|
||||
fprintf(stderr, " FAIL: parse returned false\n");
|
||||
return 1;
|
||||
}
|
||||
if (ch != 0 || sc != 0 || st != STATE_RECORD) {
|
||||
fprintf(stderr, " FAIL: expected (0,0,RECORD), got (%d,%d,%d)\n", ch, sc, st);
|
||||
return 1;
|
||||
}
|
||||
printf(" PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_parse_looping(void) {
|
||||
printf("Test parse_status_line: LOOPING\n");
|
||||
int ch, sc; ChannelState st;
|
||||
if (!parse_status_line("CH=0 SC=0 STATE=LOOPING\n", &ch, &sc, &st)) {
|
||||
fprintf(stderr, " FAIL: parse returned false\n");
|
||||
return 1;
|
||||
}
|
||||
if (ch != 0 || sc != 0 || st != STATE_LOOPING) {
|
||||
fprintf(stderr, " FAIL: expected (0,0,LOOPING), got (%d,%d,%d)\n", ch, sc, st);
|
||||
return 1;
|
||||
}
|
||||
printf(" PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_parse_paused(void) {
|
||||
printf("Test parse_status_line: PAUSED\n");
|
||||
int ch, sc; ChannelState st;
|
||||
if (!parse_status_line("CH=0 SC=0 STATE=PAUSED\n", &ch, &sc, &st)) {
|
||||
fprintf(stderr, " FAIL: parse returned false\n");
|
||||
return 1;
|
||||
}
|
||||
if (ch != 0 || sc != 0 || st != STATE_PAUSED) {
|
||||
fprintf(stderr, " FAIL: expected (0,0,PAUSED), got (%d,%d,%d)\n", ch, sc, st);
|
||||
return 1;
|
||||
}
|
||||
printf(" PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_parse_malformed(void) {
|
||||
printf("Test parse_status_line: malformed\n");
|
||||
int ch, sc; ChannelState st;
|
||||
if (parse_status_line("garbage\n", &ch, &sc, &st)) {
|
||||
fprintf(stderr, " FAIL: parse should return false for garbage\n");
|
||||
return 1;
|
||||
}
|
||||
printf(" PASS\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int fail = 0;
|
||||
fail += test_parse_idle();
|
||||
fail += test_parse_recording();
|
||||
fail += test_parse_looping();
|
||||
fail += test_parse_paused();
|
||||
fail += test_parse_malformed();
|
||||
return fail;
|
||||
}
|
||||
Reference in New Issue
Block a user