Add unit test program

This commit is contained in:
Rikard Nordgren committed 2025-02-16 20:18:46 +01:00
1 parent fc0340ac70
commit bac93e6117
3 files changed
+156 -1

No files matched your search

+108
View File
@@ -0,0 +1,108 @@
# Unit tests for basic math functions
log on
logname "build/output"
print "TEST: float const 10.0"
fill $1001 $1005 84 20 00 00 00
print "COMPARE"
compare $BAF9 $BAFD $1001
print "END"
print "TEST: float const 1.0"
fill $1001 $1005 81 00 00 00 00
print "COMPARE"
compare $B9BC $B9C0 $1001
print "END"
print "TEST: float const 0.5"
fill $1001 $1005 80 00 00 00 00
print "COMPARE"
compare $BF11 $BF15 $1001
print "END"
print "TEST: float const -0.5"
fill $1001 $1005 80 80 00 00 00
print "COMPARE"
compare $B9E0 $B9E4 $1001
print "END"
print "TEST: float const 0.25"
fill $1001 $1005 7F 00 00 00 00
print "COMPARE"
compare $E2EA $E2EE $1001
print "END"
print "TEST: convert_A_to_FAC1 A=0"
r A=0
r PC=$BC3C
ret
fill $1001 $1001 00
print "COMPARE"
compare $61 $61 $1001
print "END"
print "TEST: convert_A_to_FAC1 A=1"
r A=1
r PC=$BC3C
ret
fill $1001 $1007 81 80 00 00 00 00 00
print "COMPARE"
compare $61 $67 $1001
print "END"
print "TEST: convert_A_to_FAC1 A=127"
r A=$7F
r PC=$BC3C
ret
fill $1001 $1007 87 FE 00 00 00 00 00
print "COMPARE"
compare $61 $67 $1001
print "END"
print "TEST: convert_A_to_FAC1 A=-128"
r A=$80
r PC=$BC3C
ret
fill $1001 $1007 88 80 00 00 00 FF 00
print "COMPARE"
compare $61 $67 $1001
print "END"
print "TEST: convert_Y_to_FAC1 Y=1"
r Y=1
r PC=$B3A2
ret
fill $1001 $1007 81 80 00 00 00 00 00
print "COMPARE"
compare $61 $67 $1001
print "END"
print "TEST: convert_Y_to_FAC1 Y=0"
r Y=0
r PC=$B3A2
ret
fill $1001 $1001 00
print "COMPARE"
compare $61 $61 $1001
print "END"
print "TEST: convert_Y_to_FAC1 Y=127"
r Y=$7F
r PC=$B3A2
ret
fill $1001 $1007 87 FE 00 00 00 00 00
print "COMPARE"
compare $61 $67 $1001
print "END"
print "TEST: convert_Y_to_FAC1 Y=255"
r Y=$FF
r PC=$B3A2
ret
fill $1001 $1007 88 FF 00 00 00 00 00
print "COMPARE"
compare $61 $67 $1001
print "END"
q
+39
View File
@@ -0,0 +1,39 @@
#include <fstream>
#include <iostream>
// Program to parse output of vice monitor script tests
// Outputs a list of tests and information from failing tests
int main()
{
std::ifstream file("output");
std::string line;
bool in_compare = false;
bool failed = false;
while (getline(file, line)) {
if (line.starts_with("ERROR -- Wrong syntax:")) {
getline(file, line);
if (line.starts_with(" print \"TEST: ")) {
std::cout << line.substr(9, line.size() - 10) << std::endl;
} else if (line.starts_with(" print \"COMPARE")) {
getline(file, line);
in_compare = true;
} else if (line.starts_with(" print \"END")) {
in_compare = false;
}
} else if (in_compare) {
std::cout << "\033[31mFAIL:\033[0m " << line << std::endl;
failed = true;
}
}
if (failed) {
std::cout << "Some tests \033[31mFAIL\033[0m " << std::endl;
return 1;
} else {
std::cout << "All tests \033[32mPASS\033[0m " << std::endl;
return 0;
}
}