TEST max,maxu (shameless copy,paste,replace)

This commit is contained in:
2025-07-21 16:23:40 +02:00
parent 621de1c3db
commit 9641ed1480

View File

@@ -157,6 +157,20 @@ section .rodata
addTest(minu3, "minu(MIN_UINT64, MAX_UINT64)")
addTest(minu4, "minu(-1, 0)")
addTest(minu5, "minu(MIN_UINT64, MIN_INT8)")
;max()
addTestHeader(_max, "max")
addTest(max1, "max(-1337, 1337)")
addTest(max2, "max(MIN_INT64, MAX_INT64)")
addTest(max3, "max(MIN_UINT64, MAX_UINT64)")
addTest(max4, "max(-1, 0)")
addTest(max5, "max(MIN_UINT64, MIN_INT8)")
;maxu()
addTestHeader(_maxu, "maxu")
addTest(maxu1, "maxu(-1337, 1337)")
addTest(maxu2, "maxu(MIN_INT64, MAX_INT64)")
addTest(maxu3, "maxu(MIN_UINT64, MAX_UINT64)")
addTest(maxu4, "maxu(-1, 0)")
addTest(maxu5, "maxu(MIN_UINT64, MIN_INT8)")
section .data
@@ -334,6 +348,78 @@ _start:
assert MIN_UINT64, je, testMsg_assertIEqual
%endif
;--- max()
%if TEST_max
printTestHeader(_max)
; TEST 1: max(-1337, 1337)
printTest(max1)
mov rdi, -1337
mov rsi, 1337
call max
assert 1337, je, testMsg_assertIEqual
; TEST 2: max(MIN_INT64, MAX_INT64)
printTest(max2)
mov rdi, MIN_INT64
mov rsi, MAX_INT64
call max
assert MAX_INT64, je, testMsg_assertIEqual
; TEST 3: max(MIN_UINT64, MAX_UINT64)
printTest(max3)
mov rdi, MIN_UINT64
mov rsi, MAX_UINT64
call max
assert MIN_UINT64, je, testMsg_assertIEqual
; TEST 4: max(-1, 0)
printTest(max4)
mov rdi, -1
xor rsi, rsi
call max
assert 0, je, testMsg_assertIEqual
; TEST 5: max(MIN_UINT64, MIN_INT8)
printTest(max5)
mov rdi, MIN_UINT64
mov rsi, MIN_INT8
call max
assert MIN_UINT64, je, testMsg_assertIEqual
%endif
;--- maxu()
%if TEST_maxu
printTestHeader(_maxu)
; TEST 1: maxu(-1337, 1337)
printTest(maxu1)
mov rdi, -1337
mov rsi, 1337
call maxu
assert -1337, je, testMsg_assertIEqual
; TEST 2: maxu(MIN_INT64, MAX_INT64)
printTest(maxu2)
mov rdi, MIN_INT64
mov rsi, MAX_INT64
call maxu
assert MIN_INT64, je, testMsg_assertIEqual
; TEST 3: maxu(MIN_UINT64, MAX_UINT64)
printTest(maxu3)
mov rdi, MIN_UINT64
mov rsi, MAX_UINT64
call maxu
assert MAX_UINT64, je, testMsg_assertIEqual
; TEST 4: maxu(-1, 0)
printTest(maxu4)
mov rdi, -1
xor rsi, rsi
call maxu
assert -1, je, testMsg_assertIEqual
; TEST 5: maxu(MIN_UINT64, MIN_INT8)
printTest(maxu5)
mov rdi, MIN_UINT64
mov rsi, MIN_INT8
call maxu
assert MIN_INT8, je, testMsg_assertIEqual
%endif
;;;
;;; TEST RESULTS
;;;