TEST minu(), improved test outputs, default to only showing full output on failure
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
var db NL,"TEST ",func,"()",NL,EOS
|
||||
;addTest(var, msg)
|
||||
%define addTest(var, msg) \
|
||||
var db TAB,msg,":",NL,EOS
|
||||
var db TAB,msg,NL,EOS
|
||||
;printTestHeader var
|
||||
%macro printTestHeader 1
|
||||
lea rdi, [rel %1]
|
||||
@@ -14,7 +14,7 @@
|
||||
;printTest var
|
||||
%macro printTest 1
|
||||
lea rdi, [rel %1]
|
||||
call printf
|
||||
call print
|
||||
%endmacro
|
||||
;assert value, jmp instruction, testMsg_X
|
||||
%macro assert 3
|
||||
@@ -71,7 +71,7 @@ section .rodata
|
||||
;;;
|
||||
;;; enable/disable tests
|
||||
;;;
|
||||
TESTS_PRINT_ALL_OUTPUTS equ 1 ;If set to 0, only print expected/got and FAIL if failed. Otherwise always print outputs.
|
||||
TESTS_PRINT_ALL_OUTPUTS equ 0 ;If set to 0, only print expected/got and FAIL if failed. Otherwise always print outputs.
|
||||
;Note: when set to 0, tests are silent (ie it prints the current test and does not print any output, not even OK)
|
||||
;core.asm
|
||||
TEST_islower equ 1
|
||||
@@ -150,6 +150,13 @@ section .rodata
|
||||
addTest(min3, "min(MIN_UINT64, MAX_UINT64)")
|
||||
addTest(min4, "min(-1, 0)")
|
||||
addTest(min5, "min(MIN_UINT64, MIN_INT8)")
|
||||
;minu()
|
||||
addTestHeader(_minu, "minu")
|
||||
addTest(minu1, "minu(-1337, 1337)")
|
||||
addTest(minu2, "minu(MIN_INT64, MAX_INT64)")
|
||||
addTest(minu3, "minu(MIN_UINT64, MAX_UINT64)")
|
||||
addTest(minu4, "minu(-1, 0)")
|
||||
addTest(minu5, "minu(MIN_UINT64, MIN_INT8)")
|
||||
|
||||
section .data
|
||||
|
||||
@@ -291,6 +298,42 @@ _start:
|
||||
assert MIN_INT8, je, testMsg_assertIEqual
|
||||
%endif
|
||||
|
||||
;--- minu()
|
||||
%if TEST_minu
|
||||
printTestHeader(_minu)
|
||||
|
||||
; TEST 1: minu(-1337, 1337)
|
||||
printTest(minu1)
|
||||
mov rdi, -1337
|
||||
mov rsi, 1337
|
||||
call minu
|
||||
assert 1337, je, testMsg_assertIEqual
|
||||
; TEST 2: minu(MIN_INT64, MAX_INT64)
|
||||
printTest(minu2)
|
||||
mov rdi, MIN_INT64
|
||||
mov rsi, MAX_INT64
|
||||
call minu
|
||||
assert MAX_INT64, je, testMsg_assertIEqual
|
||||
; TEST 3: minu(MIN_UINT64, MAX_UINT64)
|
||||
printTest(minu3)
|
||||
mov rdi, MIN_UINT64
|
||||
mov rsi, MAX_UINT64
|
||||
call minu
|
||||
assert MIN_UINT64, je, testMsg_assertIEqual
|
||||
; TEST 4: minu(-1, 0)
|
||||
printTest(minu4)
|
||||
mov rdi, -1
|
||||
xor rsi, rsi
|
||||
call minu
|
||||
assert 0, je, testMsg_assertIEqual
|
||||
; TEST 5: minu(MIN_UINT64, MIN_INT8)
|
||||
printTest(minu5)
|
||||
mov rdi, MIN_UINT64
|
||||
mov rsi, MIN_INT8
|
||||
call minu
|
||||
assert MIN_UINT64, je, testMsg_assertIEqual
|
||||
%endif
|
||||
|
||||
;;;
|
||||
;;; TEST RESULTS
|
||||
;;;
|
||||
|
Reference in New Issue
Block a user