<commit_before>#
# Based on https://github.com/modern-cpp-examples/match3/blob/master/test/CMakeLists.txt
#
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -include common/test.hpp")

include_directories(
  ${APP_INCLUDE_DIRS}
  ${PROJECT_SOURCE_DIR}/src
  ${CMAKE_CURRENT_LIST_DIR}
  ${CMAKE_CURRENT_BINARY_DIR})
link_libraries(${APP_LIBRARIES})

function(unit_test file)
  string(REPLACE "/" "_" testname ${file})
  add_executable(unit_test.${testname} ${CMAKE_CURRENT_LIST_DIR}/unit_tests/${file}.cpp ${SOURCE_DEPS})
  add_test(unit_test.${testname} unit_test.${testname})
endfunction()

unit_test("utils/color")
unit_test("utils/math")
unit_test("utils/memory")
unit_test("utils/string")
unit_test("components/command_line")
unit_test("components/di")
unit_test("x11/color")
unit_test("x11/connection")
unit_test("x11/winspec")<commit_msg>fix: Disable tests requiring X connection<commit_after>#
# Based on https://github.com/modern-cpp-examples/match3/blob/master/test/CMakeLists.txt
#
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -include common/test.hpp")

include_directories(
  ${APP_INCLUDE_DIRS}
  ${PROJECT_SOURCE_DIR}/src
  ${CMAKE_CURRENT_LIST_DIR}
  ${CMAKE_CURRENT_BINARY_DIR})
link_libraries(${APP_LIBRARIES})

function(unit_test file)
  string(REPLACE "/" "_" testname ${file})
  add_executable(unit_test.${testname} ${CMAKE_CURRENT_LIST_DIR}/unit_tests/${file}.cpp ${SOURCE_DEPS})
  add_test(unit_test.${testname} unit_test.${testname})
endfunction()

unit_test("utils/color")
unit_test("utils/math")
unit_test("utils/memory")
unit_test("utils/string")
unit_test("components/command_line")
unit_test("components/di")
unit_test("x11/color")

# XXX: Requires mocked xcb connection
#unit_test("x11/connection")
#unit_test("x11/winspec")
{'fraction_non_alphanumeric': 0.15988538681948425, 'fraction_numerical': 0.008022922636103151, 'mean_word_length': 8.238095238095237, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6052368', 'n_tokens_mistral': 678, 'n_tokens_neox': 647, 'n_words': 79}