From d167dfdcdff474cbdd50a8e4678d1bde1546dda3 Mon Sep 17 00:00:00 2001 From: Kwarde Date: Mon, 21 Jul 2025 16:40:45 +0200 Subject: [PATCH] Add TEST clampu, better test result overview --- src/tests.asm | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/src/tests.asm b/src/tests.asm index 5ab1e9c..c80bda5 100644 --- a/src/tests.asm +++ b/src/tests.asm @@ -115,8 +115,8 @@ section .rodata testMsg_assertUMore db "\t\tassert(output > %u):\n\t\t\tExpected:\t%u\n\t\t\tGot:\t\t%u\n\t\t\t%s",NL,EOS testMsg_assertUMoreE db "\t\tassert(output >= %u):\n\t\t\tExpected:\t%u\n\t\t\tGot:\t\t%u\n\t\t\t%s",NL,EOS testMsg_False db " FAIL",EOS - testMsg_True db "< > OK",EOS - testMsg_Results db "\n*** Test Results ***\n* Total tests:\t\t%d\n* Succeeded tests:\t%d\n* Failed tests:\t\t%d\n",EOS + testMsg_True db "< > PASS",EOS + testMsg_Results db "\n*** Test Results ***\n* Total tests:\t%d\n* Passed tests:\t%d\n* Failed tests:\t%d\n",EOS ;;; ;;; Specific test data @@ -178,6 +178,12 @@ section .rodata addTest(clamp3, "clamp(1337, -1000, 1000)") addTest(clamp4, "clamp(MAX_INT64, -10, 10)") addTest(clamp5, "clamp(-1, MIN_UINT32, MAX_UINT32)") + ;clampu() + addTestHeader(_clampu, "clampu") + addTest(clampu1, "clampu(50, 1, 1000)") + addTest(clampu2, "clampu(0, 1, 1000)") + addTest(clampu3, "clampu(1337, 1, 1000)") + addTest(clampu4, "clampu(MAX_UINT64, 0, MAX_UINT32)") section .data @@ -504,6 +510,40 @@ _start: assert MIN_UINT32, je, testMsg_assertIEqual %endif +;--- clampu() +%if TEST_clampu + printTestHeader(_clampu) + + ; TEST 1: clampu(50, 1, 1000) + printTest(clampu1) + mov rdi, 50 + mov rsi, 1 + mov rdx, 1000 + call clampu + assert 50, je, testMsg_assertUEqual + ; TEST 2: clampu(0, 1, 1000) + printTest(clampu2) + xor rdi, rdi + mov rsi, 1 + mov rdx, 1000 + call clampu + assert 1, je, testMsg_assertUEqual + ; TEST 3: clampu(1337, 1, 1000) + printTest(clampu3) + mov rdi, 1337 + mov rsi, 1 + mov rdx, 1000 + call clampu + assert 1000, je, testMsg_assertUEqual + ; TEST 4: clampu(MAX_UINT64, 0, MAX_UINT32) + printTest(clampu4) + mov rdi, MAX_UINT64 + xor rsi, rsi + mov rdx, MAX_UINT32 + call clampu + assert MAX_UINT32, je, testMsg_assertUEqual +%endif + ;;; ;;; TEST RESULTS ;;;