TESTEND("asminstr");
}
+#define ULAS_FULLEN 0xFFFF
+
+#define ASSERT_FULL(expect_len, expect_rc, in_path, ...) \
+ { \
+ ulaslstout = stdout; \
+ struct ulas_config cfg = ulas_cfg_from_env(); \
+ char dstbuf[ULAS_FULLEN]; \
+ char expect[] = {__VA_ARGS__}; \
+ memset(dstbuf, 0, ULAS_FULLEN); \
+ ulasout = fmemopen(dstbuf, ULAS_FULLEN, "we"); \
+ ulasin = fopen(in_path, "re"); \
+ assert(ulas_main(cfg) == expect_rc); \
+ fclose(ulasout); \
+ for (int i = 0; i < expect_len; i++) { \
+ assert(dstbuf[i] == expect[i]); \
+ } \
+ for (int i = expect_len; i < ULAS_FULLEN; i++) { \
+ assert(dstbuf[i] == 0); \
+ } \
+ ulasin = stdin; \
+ ulasout = stdout; \
+ }
+
// tests the entire stack
void test_full(void) {
TESTBEGIN("testfull");
+ ASSERT_FULL(2, 0, "tests/t0.s", 0, 0x76);
+
TESTEND("testfull");
}
test_totok();
test_intexpr();
test_asminstr();
- test_full();
ulas_free();
+ // this will re-init everything on its own,
+ // so call after free
+ test_full();
+
return 0;
}
{NULL}};
-// assembles an instruction, writes bytes into dst
-// returns bytes written or -1 on error
int ulas_asminstr(char *dst, unsigned long max, const char **line,
unsigned long n) {
const char *start = *line;