#include "../calc.h"

#define BUF_SIZE 80

#define make_str(s) { sizeof(s), (const u8 *)s }
#define make_test(name) { make_str(#name), name }

extern bool streq(const u8 *, uint, const u8 *, uint);
extern int read(u8 *, uint); // read from stdin

// Tests
extern void count_digits(void);
extern void fmt_decimal(void);

typedef struct {
  u8 len;
  const u8 *data;
} str;

typedef void (*testfn)(void);

typedef struct {
  str name;
  testfn fn;
} test;

static str tests[2] = {make_test(count_digits), make_test(fmt_decimal)};

void _start(void) {
        u8 buf[BUF_SIZE];
        int nread0 = read(buf, BUF_SIZE);
        if (nread0 < 0) {
                for(;;); // TODO: add abort function
        }
        uint nread = (uint)nread0;

        for(uint i = 0; i < sizeof(tests); i++) {
                const str s = tests[i];
                if (streq(buf, nread, s.data, s.len)) {
                    
                }
        }
}