#
# Unit tests for the TetraIF modules (CoPrtCnv, LogView, PrtCnv).
# One test executable per module, each registered with ctest.
#
# LogView: the module is classes are compiled into the LogView executable
#

if (NOT BUILD_TESTING)
  return()
endif()

# --- CoPrtCnv: telegram classes and helpers --------------------------------
if (TARGET CoPrtCnv)
  ADD_EXECUTABLE(coprtcnv_unit_test coprtcnv_unit_test.cpp)
  TARGET_LINK_LIBRARIES(coprtcnv_unit_test
    CoPrtCnv
    NGLLogger
    Qt6::Core
    Qt6::Test
  )
  ADD_TEST(NAME coprtcnv_unit_test COMMAND $<TARGET_FILE:coprtcnv_unit_test>)
endif()

# --- LogView: IntegerCalculator --------------------------------------------
ADD_EXECUTABLE(logview_unit_test
  logview_unit_test.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/../LogView/IntegerCalculator.cpp)
TARGET_LINK_LIBRARIES(logview_unit_test
  Qt6::Core
  Qt6::Test
)
ADD_TEST(NAME logview_unit_test COMMAND $<TARGET_FILE:logview_unit_test>)

# --- PrtCnv: PrtCnvMember (fragmented telegram handling) --------------------
if (TARGET CoPrtCnv)
  ADD_EXECUTABLE(prtcnv_unit_test
    prtcnv_unit_test.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/../PrtCnv/PrtCnvMember.cpp)
  TARGET_LINK_LIBRARIES(prtcnv_unit_test
    CoPrtCnv
    NGLLogger
    Qt6::Core
    Qt6::Test
  )
  ADD_TEST(NAME prtcnv_unit_test COMMAND $<TARGET_FILE:prtcnv_unit_test>)
endif()
