From deae28c3b0d92579a193517970e59fa78d9cde9c Mon Sep 17 00:00:00 2001 From: Eugen Kadienko Date: Mon, 14 Aug 2023 20:14:01 +0700 Subject: [PATCH 1/3] Use armadillo-based test only if there is the armadillo in the system --- tests/CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 91bd88d..7ec5415 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,7 +7,9 @@ target_link_libraries(gh-issue-2 ${PROJECT_NAME}) add_test(NAME gh-issue-2 COMMAND gh-issue-2) find_package(Armadillo) -include_directories(${ARMADILLO_INCLUDE_DIRS}) -add_executable(testWigner testWigner.cpp) -target_link_libraries(testWigner ${PROJECT_NAME} ${ARMADILLO_LIBRARIES}) -add_test(NAME testWigner COMMAND testWigner 10) +if (ARMADILLO_FOUND) + include_directories(${ARMADILLO_INCLUDE_DIRS}) + add_executable(testWigner testWigner.cpp) + target_link_libraries(testWigner ${PROJECT_NAME} ${ARMADILLO_LIBRARIES}) + add_test(NAME testWigner COMMAND testWigner 10) +endif() From ee884a90825e788160fd9837f1fba2f4f844b738 Mon Sep 17 00:00:00 2001 From: Eugen Kadienko Date: Thu, 18 Apr 2024 17:36:53 +0700 Subject: [PATCH 2/3] Fix selection error. --- src/wignerSymbols-cpp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wignerSymbols-cpp.cpp b/src/wignerSymbols-cpp.cpp index 3292cf2..f5dd18e 100644 --- a/src/wignerSymbols-cpp.cpp +++ b/src/wignerSymbols-cpp.cpp @@ -429,7 +429,7 @@ double wigner6j(double l1, double l2, double l3, bool select(true); // Triangle relations for the four tryads - select = ( + select &= ( std::fabs(l1-l2) <= l3 && l3 <= l1+l2 && std::fabs(l1-l5) <= l6 && l6 <= l1+l5 && std::fabs(l4-l2) <= l6 && l6 <= l4+l2 @@ -437,7 +437,7 @@ double wigner6j(double l1, double l2, double l3, ); // Sum rule of the tryads - select = ( + select &= ( std::floor(l1+l2+l3)==(l1+l2+l3) && std::floor(l1+l5+l6)==(l1+l5+l6) && std::floor(l4+l2+l6)==(l4+l2+l6) From 4eb8d95e34614c3af4f21216e3a60f50ffa2d40e Mon Sep 17 00:00:00 2001 From: Eugen Kadienko Date: Tue, 23 Apr 2024 15:36:09 +0700 Subject: [PATCH 3/3] Add subdirectory tests if BUILD_TESTING is ON --- CMakeLists.txt | 4 +++- tests/CMakeLists.txt | 10 ++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd36bb1..0863be2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,9 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} VERSION ${wignerSymbols_VERSION_MAJOR}.${wignerSymbols_VERSION_MINOR}.${wignerSymbols_VERSION_RELEASE} SOVERSION ${wignerSymbols_VERSION_MAJOR}.${wignerSymbols_VERSION_MINOR}.${wignerSymbols_VERSION_RELEASE}) -add_subdirectory(tests) +if(BUILD_TESTING) + add_subdirectory(tests) +endif() # Install directories install(TARGETS ${PROJECT_NAME} DESTINATION lib) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7ec5415..91bd88d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,9 +7,7 @@ target_link_libraries(gh-issue-2 ${PROJECT_NAME}) add_test(NAME gh-issue-2 COMMAND gh-issue-2) find_package(Armadillo) -if (ARMADILLO_FOUND) - include_directories(${ARMADILLO_INCLUDE_DIRS}) - add_executable(testWigner testWigner.cpp) - target_link_libraries(testWigner ${PROJECT_NAME} ${ARMADILLO_LIBRARIES}) - add_test(NAME testWigner COMMAND testWigner 10) -endif() +include_directories(${ARMADILLO_INCLUDE_DIRS}) +add_executable(testWigner testWigner.cpp) +target_link_libraries(testWigner ${PROJECT_NAME} ${ARMADILLO_LIBRARIES}) +add_test(NAME testWigner COMMAND testWigner 10)