TEST clamp()
This commit is contained in:
@@ -171,6 +171,13 @@ section .rodata
|
||||
addTest(maxu3, "maxu(MIN_UINT64, MAX_UINT64)")
|
||||
addTest(maxu4, "maxu(-1, 0)")
|
||||
addTest(maxu5, "maxu(MIN_UINT64, MIN_INT8)")
|
||||
;clamp()
|
||||
addTestHeader(_clamp, "clamp")
|
||||
addTest(clamp1, "clamp(50, -1000, 1000)")
|
||||
addTest(clamp2, "clamp(-1337, -1000, 1000)")
|
||||
addTest(clamp3, "clamp(1337, -1000, 1000)")
|
||||
addTest(clamp4, "clamp(MAX_INT64, -10, 10)")
|
||||
addTest(clamp5, "clamp(-1, MIN_UINT32, MAX_UINT32)")
|
||||
|
||||
section .data
|
||||
|
||||
@@ -206,6 +213,42 @@ _start:
|
||||
;--- isupper()
|
||||
%if TEST_isupper
|
||||
printTestHeader(_isupper)
|
||||
;--- 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
|
||||
|
||||
|
||||
; TEST 1: isupper('d')
|
||||
printTest(isupper_d)
|
||||
@@ -420,6 +463,47 @@ _start:
|
||||
assert MIN_INT8, je, testMsg_assertIEqual
|
||||
%endif
|
||||
|
||||
;--- clamp()
|
||||
%if TEST_clamp
|
||||
printTestHeader(_clamp)
|
||||
|
||||
; TEST 1: clamp(50, -1000, 1000)
|
||||
printTest(clamp1)
|
||||
mov rdi, 50
|
||||
mov rsi, -1000
|
||||
mov rdx, 1000
|
||||
call clamp
|
||||
assert 50, je, testMsg_assertIEqual
|
||||
; TEST 2: clamp(-1337, -1000, 1000)
|
||||
printTest(clamp2)
|
||||
mov rdi, -1337
|
||||
mov rsi, -1000
|
||||
mov rdx, 1000
|
||||
call clamp
|
||||
assert -1000, je, testMsg_assertIEqual
|
||||
; TEST 3: clamp(1337, -1000, 1000)
|
||||
printTest(clamp3)
|
||||
mov rdi, 1337
|
||||
mov rsi, -1000
|
||||
mov rdx, 1000
|
||||
call clamp
|
||||
assert 1000, je, testMsg_assertIEqual
|
||||
; TEST 4: clamp(MAX_INT64, -10, 10)
|
||||
printTest(clamp4)
|
||||
mov rdi, MAX_INT64
|
||||
mov rsi, -10
|
||||
mov rdx, 10
|
||||
call clamp
|
||||
assert 10, je, testMsg_assertIEqual
|
||||
; TEST 5: clamp(-1, MIN_UINT32, MAX_UINT32)
|
||||
printTest(clamp5)
|
||||
mov rdi, -1
|
||||
mov rsi, MIN_UINT32
|
||||
mov rdx, MAX_UINT32
|
||||
call clamp
|
||||
assert MIN_UINT32, je, testMsg_assertIEqual
|
||||
%endif
|
||||
|
||||
;;;
|
||||
;;; TEST RESULTS
|
||||
;;;
|
||||
|
Reference in New Issue
Block a user