diff --git a/src/tests.asm b/src/tests.asm index c80bda5..e0b0c9b 100644 --- a/src/tests.asm +++ b/src/tests.asm @@ -40,6 +40,19 @@ nop %endmacro +%define assert_eq(val) assert val, je, testMsg_assertIEqual +%define assert_neq(val) assert val, jne, testMsg_assertINequal +%define assert_less(val) assert val, jl, testMsg_assertILess +%define assert_less_eq(val) assert val, jle, testMsg_assertILessE +%define assert_more(val) assert val, jg, testMsg_assertIMore +%define assert_more_eq(val) assert val, jge, testMsg_assertIMoreE +%define assert_u_eq(val) assert val, je, testMsg_assertUEqual +%define assert_u_neq(val) assert val, jne, testMsg_assertUNequal +%define assert_u_less(val) assert val, jb, testMsg_assertULess +%define assert_u_less_eq(val) assert val, jbe, testMsg_assertULessE +%define assert_u_more(val) assert val, ja, testMsg_assertUMore +%define assert_u_more_eq(val) assert val, jae, testMsg_assertUMoreE + ;core.asm extern exit extern islower @@ -203,74 +216,38 @@ _start: printTest(islower_d) mov rdi, 'd' call islower - assert 1, je, testMsg_assertIEqual + assert_eq(1) ; TEST 2: islower('D') printTest(islower_D) mov rdi, 'D' call islower - assert 0, je, testMsg_assertIEqual + assert_eq(0) ; TEST 3: islower('!') printTest(islower_em) mov rdi, '!' call islower - assert 0, je, testMsg_assertIEqual + assert_eq(0) %endif ;--- 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) mov rdi, 'd' call isupper - assert 0, je, testMsg_assertIEqual + assert_eq(0) ; TEST 2: isupper('D') printTest(isupper_D) mov rdi, 'D' call isupper - assert 1, je, testMsg_assertIEqual + assert_eq(1) ; TEST 3: isupper('!') printTest(isupper_em) mov rdi, '!' call isupper - assert 0, je, testMsg_assertIEqual + assert_eq(0) %endif ;--- tolower() @@ -281,22 +258,22 @@ _start: printTest(tolower_d) mov rdi, 'd' call tolower - assert 'd', je, testMsg_assertIEqual + assert_eq('d') ; TEST 2: tolower('D') printTest(tolower_D) mov rdi, 'D' call tolower - assert 'd', je, testMsg_assertIEqual + assert_eq('d') ; TEST 3: tolower('!') printTest(tolower_em) mov rdi, '!' call tolower - assert '!', je, testMsg_assertIEqual + assert_eq('!') ; TEST 4: tolower('}') printTest(tolower_cb) mov rdi, '}' call tolower - assert '}', je, testMsg_assertIEqual + assert_eq('}') %endif ;--- toupper() @@ -307,22 +284,22 @@ _start: printTest(toupper_d) mov rdi, 'd' call toupper - assert 'D', je, testMsg_assertIEqual + assert_eq('D') ; TEST 2: toupper('D') printTest(toupper_D) mov rdi, 'D' call toupper - assert 'D', je, testMsg_assertIEqual + assert_eq('D') ; TEST 3: toupper('!') printTest(toupper_em) mov rdi, '!' call toupper - assert '!', je, testMsg_assertIEqual + assert_eq('!') ; TEST 4: toupper('}') printTest(toupper_cb) mov rdi, '}' call toupper - assert '}', je, testMsg_assertIEqual + assert_eq('}') %endif ;--- min() @@ -334,31 +311,31 @@ _start: mov rdi, -1337 mov rsi, 1337 call min - assert -1337, je, testMsg_assertIEqual + assert_eq(-1337) ; TEST 2: min(MIN_INT64, MAX_INT64) printTest(min2) mov rdi, MIN_INT64 mov rsi, MAX_INT64 call min - assert MIN_INT64, je, testMsg_assertIEqual + assert_eq(MIN_INT64) ; TEST 3: min(MIN_UINT64, MAX_UINT64) printTest(min3) mov rdi, MIN_UINT64 mov rsi, MAX_UINT64 call min - assert MAX_UINT64, je, testMsg_assertIEqual + assert_eq(MAX_UINT64) ; TEST 4: min(-1, 0) printTest(min4) mov rdi, -1 xor rsi, rsi call min - assert -1, je, testMsg_assertIEqual + assert_eq(-1) ; TEST 5: min(MIN_UINT64, MIN_INT8) printTest(min5) mov rdi, MIN_UINT64 mov rsi, MIN_INT8 call min - assert MIN_INT8, je, testMsg_assertIEqual + assert_eq(MIN_INT8) %endif ;--- minu() @@ -370,31 +347,31 @@ _start: mov rdi, -1337 mov rsi, 1337 call minu - assert 1337, je, testMsg_assertUEqual + assert_u_eq(1337) ; TEST 2: minu(MIN_INT64, MAX_INT64) printTest(minu2) mov rdi, MIN_INT64 mov rsi, MAX_INT64 call minu - assert MAX_INT64, je, testMsg_assertUEqual + assert_u_eq(MAX_INT64) ; TEST 3: minu(MIN_UINT64, MAX_UINT64) printTest(minu3) mov rdi, MIN_UINT64 mov rsi, MAX_UINT64 call minu - assert MIN_UINT64, je, testMsg_assertUEqual + assert_u_eq(MIN_UINT64) ; TEST 4: minu(-1, 0) printTest(minu4) mov rdi, -1 xor rsi, rsi call minu - assert 0, je, testMsg_assertUEqual + assert_u_eq(0) ; TEST 5: minu(MIN_UINT64, MIN_INT8) printTest(minu5) mov rdi, MIN_UINT64 mov rsi, MIN_INT8 call minu - assert MIN_UINT64, je, testMsg_assertUEqual + assert_u_eq(MIN_UINT64) %endif ;--- max() @@ -406,31 +383,31 @@ _start: mov rdi, -1337 mov rsi, 1337 call max - assert 1337, je, testMsg_assertIEqual + assert_eq(1337) ; 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 + assert_eq(MAX_INT64) ; 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 + assert_eq(MIN_UINT64) ; TEST 4: max(-1, 0) printTest(max4) mov rdi, -1 xor rsi, rsi call max - assert 0, je, testMsg_assertIEqual + assert_eq(0) ; 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 + assert_eq(MIN_UINT64) %endif ;--- maxu() @@ -442,31 +419,31 @@ _start: mov rdi, -1337 mov rsi, 1337 call maxu - assert -1337, je, testMsg_assertUEqual + assert_u_eq(-1337) ; TEST 2: maxu(MIN_INT64, MAX_INT64) printTest(maxu2) mov rdi, MIN_INT64 mov rsi, MAX_INT64 call maxu - assert MIN_INT64, je, testMsg_assertUEqual + assert_u_eq(MIN_INT64) ; TEST 3: maxu(MIN_UINT64, MAX_UINT64) printTest(maxu3) mov rdi, MIN_UINT64 mov rsi, MAX_UINT64 call maxu - assert MAX_UINT64, je, testMsg_assertUEqual + assert_u_eq(MAX_UINT64) ; TEST 4: maxu(-1, 0) printTest(maxu4) mov rdi, -1 xor rsi, rsi call maxu - assert -1, je, testMsg_assertUEqual + assert_u_eq(-1) ; TEST 5: maxu(MIN_UINT64, MIN_INT8) printTest(maxu5) mov rdi, MIN_UINT64 mov rsi, MIN_INT8 call maxu - assert MIN_INT8, je, testMsg_assertUEqual + assert_u_eq(MIN_INT8) %endif ;--- clamp() @@ -479,35 +456,35 @@ _start: mov rsi, -1000 mov rdx, 1000 call clamp - assert 50, je, testMsg_assertIEqual + assert_eq(50) ; TEST 2: clamp(-1337, -1000, 1000) printTest(clamp2) mov rdi, -1337 mov rsi, -1000 mov rdx, 1000 call clamp - assert -1000, je, testMsg_assertIEqual + assert_eq(-1000) ; TEST 3: clamp(1337, -1000, 1000) printTest(clamp3) mov rdi, 1337 mov rsi, -1000 mov rdx, 1000 call clamp - assert 1000, je, testMsg_assertIEqual + assert_eq(1000) ; 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 + assert_eq(10) ; 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 + assert_eq(MIN_UINT32) %endif ;--- clampu() @@ -520,28 +497,28 @@ _start: mov rsi, 1 mov rdx, 1000 call clampu - assert 50, je, testMsg_assertUEqual + assert_u_eq(50) ; TEST 2: clampu(0, 1, 1000) printTest(clampu2) xor rdi, rdi mov rsi, 1 mov rdx, 1000 call clampu - assert 1, je, testMsg_assertUEqual + assert_u_eq(1) ; TEST 3: clampu(1337, 1, 1000) printTest(clampu3) mov rdi, 1337 mov rsi, 1 mov rdx, 1000 call clampu - assert 1000, je, testMsg_assertUEqual + assert_u_eq(1000) ; 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 + assert_u_eq(MAX_UINT32) %endif ;;;