Browse Source

zasm: clarify strlen's API

pull/10/head
Virgil Dupras 4 years ago
parent
commit
02c7eb0161
3 changed files with 21 additions and 4 deletions
  1. +1
    -0
      apps/zasm/util.asm
  2. +13
    -4
      tools/tests/unit/runtests.sh
  3. +7
    -0
      tools/tests/unit/test_util_z.asm

+ 1
- 0
apps/zasm/util.asm View File

@@ -25,6 +25,7 @@ subDEFromHL:
ret

; Returns length of string at (HL) in A.
; Doesn't include null termination.
strlen:
push bc
push hl


+ 13
- 4
tools/tests/unit/runtests.sh View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -e

@@ -9,12 +9,21 @@ RUNBIN="${TOOLS}/emul/runbin/runbin"
KERNEL="${BASE}/kernel"
APPS="${BASE}/apps"

for fn in *.asm; do
echo "Running test ${fn}"
if ! ${ZASM} "${KERNEL}" "${APPS}" < ${fn} | ${RUNBIN}; then
chk() {
echo "Running test $1"
if ! ${ZASM} "${KERNEL}" "${APPS}" < $1 | ${RUNBIN}; then
echo "failed with code ${PIPESTATUS[1]}"
exit 1
fi
}

if [[ ! -z $1 ]]; then
chk $1
exit 0
fi

for fn in *.asm; do
chk "${fn}"
done

echo "All tests passed!"

+ 7
- 0
tools/tests/unit/test_util_z.asm View File

@@ -5,6 +5,7 @@ jp test
#include "zasm/util.asm"

testNum: .db 1
sFoo: .db "foo", 0

test:
ld hl, 0xffff
@@ -18,6 +19,12 @@ test:
jp nz, fail
call nexttest

ld hl, sFoo
call strlen
cp 3
jp nz, fail
call nexttest

; success
xor a
halt


Loading…
Cancel
Save