Skip to content

Commit

Permalink
Added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
visrealm committed Sep 4, 2023
1 parent 0c90c6c commit 58d8316
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/)
file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

include(CTest)
add_subdirectory(src)

add_subdirectory(src)
if (PROJECT_IS_TOP_LEVEL)
include(CTest)
add_subdirectory(testing)
endif()
28 changes: 28 additions & 0 deletions testing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.22)

enable_testing()

set(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/)
set(TEST_RUNNER ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}acme)

# Test macro expressions
add_test(macro_math1 ${TEST_RUNNER} ${TESTS_DIR}math1.a)
add_test(macro_numberflags ${TEST_RUNNER} ${TESTS_DIR}numberflags.a)

# Test input files which should generate an error
set(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/errors/)
file(GLOB ERROR_TESTS ${TESTS_DIR}/*.a)
foreach (testsourcefile ${ERROR_TESTS})
get_filename_component(testname ${testsourcefile} NAME_WLE)
add_test(${testname} ${TEST_RUNNER} ${TESTS_DIR}${testsourcefile})
set_tests_properties(${testname} PROPERTIES WILL_FAIL TRUE)
endforeach (testsourcefile ${ERROR_TESTS})

# Comparison tests for each CPU type. Compare output
set(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cpus/)
set(CPUS 6502 65c02 r65c02 w65c02 nmos6502 c64dtv2 65ce02 4502 m65 65816)
foreach (cpu ${CPUS})
add_test(test-${cpu} ${TEST_RUNNER} -v0 -I ${TESTS_DIR} ${TESTS_DIR}test-${cpu}.a)
add_test(cmp-test-${cpu} ${CMAKE_COMMAND} -E compare_files out-${cpu}.o ${TESTS_DIR}expected-${cpu}.o
)
endforeach (cpu ${CPUS})

0 comments on commit 58d8316

Please sign in to comment.