From aef96c5e9687afa31a90b98e4f729c0b4477c87e Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 23 Dec 2019 16:02:26 -0500 Subject: [PATCH] Add missing common.asm test harness file --- tools/tests/unit/common.asm | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tools/tests/unit/common.asm diff --git a/tools/tests/unit/common.asm b/tools/tests/unit/common.asm new file mode 100644 index 0000000..4377619 --- /dev/null +++ b/tools/tests/unit/common.asm @@ -0,0 +1,62 @@ +; *** requirements *** +; ascii.h +; core +; stdio +; lib/ari +; lib/fmt + +testNum: .db 1 + +STDIO_PUTC: + out (0), a + cp a + ret + +STDIO_GETC: + jp unsetZ + +assertZ: + ret z + ld hl, .msg + call printstr + jp fail +.msg: + .db "Z not set", CR, LF, 0 + +assertNZ: + ret nz + ld hl, .msg + call printstr + jp fail +.msg: + .db "Z set", CR, LF, 0 + +; Assert that HL == DE +assertEQW: + ld a, h + cp d + jr nz, .fail + ld a, l + cp e + ret z +.fail: + call printHexPair + call printcrlf + ex de, hl + call printHexPair + call printcrlf + ld hl, .msg + call printstr + jp fail +.msg: + .db "HL != DE", CR, LF, 0 + +nexttest: + ld a, (testNum) + inc a + ld (testNum), a + ret + +fail: + ld a, (testNum) + halt