1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-28 02:38:05 +11:00
collapseos/tools/tests/unit/test_lib_fmt.asm

96 lines
1.0 KiB
NASM
Raw Normal View History

jp test
.inc "core.asm"
.inc "lib/util.asm"
.inc "lib/ari.asm"
.inc "lib/fmt.asm"
testNum: .db 1
test:
ld sp, 0xffff
call testFmtDecimal
2019-11-24 06:56:23 +11:00
call testFmtDecimalS
; success
xor a
halt
testFmtDecimal:
ld ix, .t1
call .test
ld ix, .t2
call .test
ld ix, .t3
call .test
ld ix, .t4
call .test
ld ix, .t5
call .test
ret
.test:
ld e, (ix)
ld d, (ix+1)
ld hl, sandbox
call fmtDecimal
ld hl, sandbox
push ix \ pop de
inc de \ inc de
call strcmp
jp nz, fail
jp nexttest
.t1:
.dw 1234
.db "1234", 0
.t2:
.dw 9999
.db "9999", 0
.t3:
.dw 0
.db "0", 0
.t4:
.dw 0x7fff
.db "32767", 0
.t5:
.dw 0xffff
.db "65535", 0
2019-11-24 06:56:23 +11:00
testFmtDecimalS:
ld ix, .t1
call .test
ld ix, .t2
call .test
ret
.test:
ld e, (ix)
ld d, (ix+1)
ld hl, sandbox
call fmtDecimalS
ld hl, sandbox
push ix \ pop de
inc de \ inc de
call strcmp
jp nz, fail
jp nexttest
.t1:
.dw 1234
.db "1234", 0
.t2:
.dw 0-1234
.db "-1234", 0
nexttest:
ld a, (testNum)
inc a
ld (testNum), a
ret
fail:
ld a, (testNum)
halt
; used as RAM
sandbox: