Commit f3c3966e by Maarten L. Hekkelman

Merge branch 'with-catch2' of s4.hekkelman.net:git-repo/libcifpp into with-catch2

parents 8a9f72c9 458e228b
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: multi platform test
on:
push:
branches: [ "trunk", "develop" ]
pull_request:
branches: [ "trunk" ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false
# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
steps:
- uses: actions/checkout@v3
- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Install dependencies Ubuntu
if: matrix.os == 'ubuntu-latest'
run: >
sudo apt-get update && sudo apt-get install mrc
- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCIFPP_DOWNLOAD_CCD=OFF
-S ${{ github.workspace }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
...@@ -45,8 +45,12 @@ set(CXX_EXTENSIONS OFF) ...@@ -45,8 +45,12 @@ set(CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set(CMAKE_CXX_VISIBILITY_PRESET hidden) # When building with ninja-multiconfig, build both debug and release by default
# set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) if(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config")
set(CMAKE_CROSS_CONFIGS "Debug;Release")
set(CMAKE_DEFAULT_CONFIGS "Debug;Release")
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
elseif(MSVC) elseif(MSVC)
...@@ -304,6 +308,10 @@ set(project_headers ...@@ -304,6 +308,10 @@ set(project_headers
add_library(cifpp ${project_sources} ${project_headers} ${PROJECT_SOURCE_DIR}/src/symop_table_data.hpp) add_library(cifpp ${project_sources} ${project_headers} ${PROJECT_SOURCE_DIR}/src/symop_table_data.hpp)
add_library(cifpp::cifpp ALIAS cifpp) add_library(cifpp::cifpp ALIAS cifpp)
set(CMAKE_DEBUG_POSTFIX d)
set_target_properties(cifpp PROPERTIES DEBUG_POSTFIX "d")
generate_export_header(cifpp EXPORT_FILE_NAME ${PROJECT_SOURCE_DIR}/include/cif++/exports.hpp) generate_export_header(cifpp EXPORT_FILE_NAME ${PROJECT_SOURCE_DIR}/include/cif++/exports.hpp)
if(BOOST_REGEX) if(BOOST_REGEX)
...@@ -372,7 +380,7 @@ endif() ...@@ -372,7 +380,7 @@ endif()
# Install rules # Install rules
install(TARGETS cifpp install(TARGETS cifpp
EXPORT cifppTargets EXPORT cifpp-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
...@@ -385,8 +393,18 @@ if(MSVC AND BUILD_SHARED_LIBS) ...@@ -385,8 +393,18 @@ if(MSVC AND BUILD_SHARED_LIBS)
OPTIONAL) OPTIONAL)
endif() endif()
install(EXPORT cifppTargets # Clean up old config files (with old names)
FILE "cifppTargets.cmake" file(GLOB OLD_CONFIG_FILES
${CMAKE_INSTALL_FULL_LIBDIR}/cmake/cifpp/cifppConfig*.cmake
${CMAKE_INSTALL_FULL_LIBDIR}/cmake/cifpp/cifppTargets*.cmake)
if (OLD_CONFIG_FILES)
message(STATUS "Installation will remove old config files: ${OLD_CONFIG_FILES}")
install(CODE "file(REMOVE ${OLD_CONFIG_FILES})")
endif()
install(EXPORT cifpp-targets
FILE "cifpp-targets.cmake"
NAMESPACE cifpp:: NAMESPACE cifpp::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cifpp DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cifpp
) )
...@@ -421,18 +439,18 @@ if(${CIFPP_CACHE_DIR}) ...@@ -421,18 +439,18 @@ if(${CIFPP_CACHE_DIR})
) )
endif() endif()
set(CONFIG_TEMPLATE_FILE ${PROJECT_SOURCE_DIR}/cmake/cifppConfig.cmake.in) set(CONFIG_TEMPLATE_FILE ${PROJECT_SOURCE_DIR}/cmake/cifpp-config.cmake.in)
configure_package_config_file( configure_package_config_file(
${CONFIG_TEMPLATE_FILE} ${CONFIG_TEMPLATE_FILE}
${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifppConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifpp-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cifpp INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cifpp
PATH_VARS CIFPP_DATA_DIR PATH_VARS CIFPP_DATA_DIR
) )
install(FILES install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifppConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifpp-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifppConfigVersion.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifpp-config-version.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cifpp DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cifpp
COMPONENT Devel COMPONENT Devel
) )
...@@ -447,7 +465,7 @@ set_property(TARGET cifpp APPEND PROPERTY ...@@ -447,7 +465,7 @@ set_property(TARGET cifpp APPEND PROPERTY
) )
write_basic_package_version_file( write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifppConfigVersion.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cifpp/cifpp-config-version.cmake"
VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion COMPATIBILITY AnyNewerVersion
) )
...@@ -497,7 +515,7 @@ if(BUILD_TESTING) ...@@ -497,7 +515,7 @@ if(BUILD_TESTING)
add_custom_command( add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Run${CIFPP_TEST}.touch OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Run${CIFPP_TEST}.touch
COMMAND $<TARGET_FILE:${CIFPP_TEST}> -- ${CMAKE_CURRENT_SOURCE_DIR}/test) COMMAND $<TARGET_FILE:${CIFPP_TEST}> --data-dir ${CMAKE_CURRENT_SOURCE_DIR}/test)
add_test(NAME ${CIFPP_TEST} add_test(NAME ${CIFPP_TEST}
COMMAND $<TARGET_FILE:${CIFPP_TEST}> --data-dir ${CMAKE_CURRENT_SOURCE_DIR}/test) COMMAND $<TARGET_FILE:${CIFPP_TEST}> --data-dir ${CMAKE_CURRENT_SOURCE_DIR}/test)
......
@PACKAGE_INIT@ @PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/cifppTargets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/cifpp-targets.cmake")
set_and_check(CIFPP_SHARE_DIR "@PACKAGE_CIFPP_DATA_DIR@") set_and_check(CIFPP_SHARE_DIR "@PACKAGE_CIFPP_DATA_DIR@")
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "test-main.hpp" #include "test-main.hpp"
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <stdexcept> #include <stdexcept>
...@@ -92,8 +93,7 @@ TEST_CASE("t1") ...@@ -92,8 +93,7 @@ TEST_CASE("t1")
const auto &&[angle, axis] = cif::quaternion_to_angle_axis(q2); const auto &&[angle, axis] = cif::quaternion_to_angle_axis(q2);
// REQUIRE(std::fmod(360 + angle, 360) == std::fmod(360 - angle0, 360)/*, tt::tolerance(0.01)*/); REQUIRE_THAT(std::fmod(360 + angle, 360), Catch::Matchers::WithinRel(std::fmod(360 - angle0, 360), 0.01));
REQUIRE(std::fmod(360 + angle, 360) == std::fmod(360 - angle0, 360));
for (auto &p : p1) for (auto &p : p1)
p.rotate(q2); p.rotate(q2);
...@@ -119,8 +119,7 @@ TEST_CASE("t2") ...@@ -119,8 +119,7 @@ TEST_CASE("t2")
auto &&[angle, axis] = cif::quaternion_to_angle_axis(q); auto &&[angle, axis] = cif::quaternion_to_angle_axis(q);
// REQUIRE(angle == 45/*, tt::tolerance(0.01)*/); REQUIRE_THAT(angle, Catch::Matchers::WithinRel(45.f, 0.01f));
REQUIRE(angle == 45);
} }
TEST_CASE("t3") TEST_CASE("t3")
...@@ -144,8 +143,7 @@ TEST_CASE("t3") ...@@ -144,8 +143,7 @@ TEST_CASE("t3")
double a = cif::angle(v, p[0], p[1]); double a = cif::angle(v, p[0], p[1]);
// REQUIRE(a == 45/*, tt::tolerance(0.01)*/); REQUIRE_THAT(a, Catch::Matchers::WithinRel(45.f, 0.01f));
REQUIRE(a == 45);
} }
TEST_CASE("dh_q_0") TEST_CASE("dh_q_0")
...@@ -162,29 +160,29 @@ TEST_CASE("dh_q_0") ...@@ -162,29 +160,29 @@ TEST_CASE("dh_q_0")
}; };
auto a = cif::dihedral_angle(t[0], t[1], t[2], p); auto a = cif::dihedral_angle(t[0], t[1], t[2], p);
REQUIRE(a == 0/*, tt::tolerance(0.01f)*/); REQUIRE_THAT(a, Catch::Matchers::WithinRel(0, 0.01f));
auto q = cif::construct_from_angle_axis(90, axis); auto q = cif::construct_from_angle_axis(90, axis);
p.rotate(q); p.rotate(q);
REQUIRE(p.m_x == 1/*, tt::tolerance(0.01f)*/); REQUIRE_THAT(p.m_x, Catch::Matchers::WithinRel(1, 0.01f));
REQUIRE(p.m_y == 0/*, tt::tolerance(0.01f)*/); REQUIRE_THAT(p.m_y, Catch::Matchers::WithinRel(0, 0.01f));
REQUIRE(p.m_z == 1/*, tt::tolerance(0.01f)*/); REQUIRE_THAT(p.m_z, Catch::Matchers::WithinRel(1, 0.01f));
a = cif::dihedral_angle(t[0], t[1], t[2], p); a = cif::dihedral_angle(t[0], t[1], t[2], p);
REQUIRE(a == 90/*, tt::tolerance(0.01f)*/); REQUIRE_THAT(a, Catch::Matchers::WithinRel(90, 0.01f));
q = cif::construct_from_angle_axis(-90, axis); q = cif::construct_from_angle_axis(-90, axis);
p.rotate(q); p.rotate(q);
REQUIRE(p.m_x == 1/*, tt::tolerance(0.01f)*/); REQUIRE_THAT(p.m_x, Catch::Matchers::WithinRel(1, 0.01f));
REQUIRE(p.m_y == 1/*, tt::tolerance(0.01f)*/); REQUIRE_THAT(p.m_y, Catch::Matchers::WithinRel(1, 0.01f));
REQUIRE(p.m_z == 0/*, tt::tolerance(0.01f)*/); REQUIRE_THAT(p.m_z, Catch::Matchers::WithinRel(0, 0.01f));
a = cif::dihedral_angle(t[0], t[1], t[2], p); a = cif::dihedral_angle(t[0], t[1], t[2], p);
REQUIRE(a == 0/*, tt::tolerance(0.01f)*/); REQUIRE_THAT(a, Catch::Matchers::WithinRel(0, 0.01f));
} }
...@@ -227,7 +225,7 @@ TEST_CASE("dh_q_1") ...@@ -227,7 +225,7 @@ TEST_CASE("dh_q_1")
pts[3].rotate(q, pts[2]); pts[3].rotate(q, pts[2]);
auto dh = cif::dihedral_angle(pts[0], pts[1], pts[2], pts[3]); auto dh = cif::dihedral_angle(pts[0], pts[1], pts[2], pts[3]);
REQUIRE(dh == angle/*, tt::tolerance(0.1f)*/); REQUIRE_THAT(dh, Catch::Matchers::WithinRel(angle, 0.1f));
} }
} }
...@@ -290,9 +288,9 @@ TEST_CASE("m2q_0, *utf::tolerance(0.001f)") ...@@ -290,9 +288,9 @@ TEST_CASE("m2q_0, *utf::tolerance(0.001f)")
cif::point p3 = rot * p1; cif::point p3 = rot * p1;
REQUIRE(p2.m_x == p3.m_x); REQUIRE_THAT(p2.m_x, Catch::Matchers::WithinRel(p3.m_x, 0.01f));
REQUIRE(p2.m_y == p3.m_y); REQUIRE_THAT(p2.m_y, Catch::Matchers::WithinRel(p3.m_y, 0.01f));
REQUIRE(p2.m_z == p3.m_z); REQUIRE_THAT(p2.m_z, Catch::Matchers::WithinRel(p3.m_z, 0.01f));
} }
} }
...@@ -365,15 +363,15 @@ TEST_CASE("symm_1") ...@@ -365,15 +363,15 @@ TEST_CASE("symm_1")
cif::point f = fractional(p, c); cif::point f = fractional(p, c);
REQUIRE(f.m_x == 0.1f/*, tt::tolerance(0.01)*/); REQUIRE_THAT(f.m_x, Catch::Matchers::WithinRel(0.1f, 0.01f));
REQUIRE(f.m_y == 0.1f/*, tt::tolerance(0.01)*/); REQUIRE_THAT(f.m_y, Catch::Matchers::WithinRel(0.1f, 0.01f));
REQUIRE(f.m_z == 0.1f/*, tt::tolerance(0.01)*/); REQUIRE_THAT(f.m_z, Catch::Matchers::WithinRel(0.1f, 0.01f));
cif::point o = orthogonal(f, c); cif::point o = orthogonal(f, c);
REQUIRE(o.m_x == 1.f/*, tt::tolerance(0.01)*/); REQUIRE_THAT(o.m_x, Catch::Matchers::WithinRel(1.f, 0.01f));
REQUIRE(o.m_y == 1.f/*, tt::tolerance(0.01)*/); REQUIRE_THAT(o.m_y, Catch::Matchers::WithinRel(1.f, 0.01f));
REQUIRE(o.m_z == 1.f/*, tt::tolerance(0.01)*/); REQUIRE_THAT(o.m_z, Catch::Matchers::WithinRel(1.f, 0.01f));
} }
TEST_CASE("symm_2") TEST_CASE("symm_2")
...@@ -407,16 +405,16 @@ TEST_CASE("symm_4, *utf::tolerance(0.1f)") ...@@ -407,16 +405,16 @@ TEST_CASE("symm_4, *utf::tolerance(0.1f)")
cif::point b{ -35.356, 33.693, -3.236 }; // CG2 THR D 400 cif::point b{ -35.356, 33.693, -3.236 }; // CG2 THR D 400
cif::point sb( -6.916, 79.34, 3.236); // 4_565 copy of b cif::point sb( -6.916, 79.34, 3.236); // 4_565 copy of b
REQUIRE(distance(a, sg(a, c, "1_455"_symop)) == static_cast<float>(c.get_a())); REQUIRE_THAT(distance(a, sg(a, c, "1_455"_symop)), Catch::Matchers::WithinRel(static_cast<float>(c.get_a()), 0.01f));
REQUIRE(distance(a, sg(a, c, "1_545"_symop)) == static_cast<float>(c.get_b())); REQUIRE_THAT(distance(a, sg(a, c, "1_545"_symop)), Catch::Matchers::WithinRel(static_cast<float>(c.get_b()), 0.01f));
REQUIRE(distance(a, sg(a, c, "1_554"_symop)) == static_cast<float>(c.get_c())); REQUIRE_THAT(distance(a, sg(a, c, "1_554"_symop)), Catch::Matchers::WithinRel(static_cast<float>(c.get_c()), 0.01f));
auto sb2 = sg(b, c, "4_565"_symop); auto sb2 = sg(b, c, "4_565"_symop);
REQUIRE(sb.m_x == sb2.m_x); REQUIRE_THAT(sb.m_x, Catch::Matchers::WithinRel(sb2.m_x, 0.01f));
REQUIRE(sb.m_y == sb2.m_y); REQUIRE_THAT(sb.m_y, Catch::Matchers::WithinRel(sb2.m_y, 0.01f));
REQUIRE(sb.m_z == sb2.m_z); REQUIRE_THAT(sb.m_z, Catch::Matchers::WithinRel(sb2.m_z, 0.01f));
REQUIRE(distance(a, sb2) == 7.42f); REQUIRE_THAT(distance(a, sb2), Catch::Matchers::WithinRel(7.42f, 0.01f));
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -436,17 +434,17 @@ TEST_CASE("symm_4wvp_1, *utf::tolerance(0.1f)") ...@@ -436,17 +434,17 @@ TEST_CASE("symm_4wvp_1, *utf::tolerance(0.1f)")
auto a = s.get_residue("A", 10, "").get_atom_by_atom_id("O"); auto a = s.get_residue("A", 10, "").get_atom_by_atom_id("O");
auto sp1 = c.symmetry_copy(a.get_location(), "2_565"_symop); auto sp1 = c.symmetry_copy(a.get_location(), "2_565"_symop);
REQUIRE(sp1.m_x == p.m_x); REQUIRE_THAT(sp1.m_x, Catch::Matchers::WithinAbs(p.m_x, 0.5f));
REQUIRE(sp1.m_y == p.m_y); REQUIRE_THAT(sp1.m_y, Catch::Matchers::WithinAbs(p.m_y, 0.5f));
REQUIRE(sp1.m_z == p.m_z); REQUIRE_THAT(sp1.m_z, Catch::Matchers::WithinAbs(p.m_z, 0.5f));
const auto &[d, sp2, so] = c.closest_symmetry_copy(p, a.get_location()); const auto &[d, sp2, so] = c.closest_symmetry_copy(p, a.get_location());
REQUIRE(d < 1); REQUIRE(d < 1);
REQUIRE(sp2.m_x == p.m_x); REQUIRE_THAT(sp2.m_x, Catch::Matchers::WithinAbs(p.m_x, 0.5f));
REQUIRE(sp2.m_y == p.m_y); REQUIRE_THAT(sp2.m_y, Catch::Matchers::WithinAbs(p.m_y, 0.5f));
REQUIRE(sp2.m_z == p.m_z); REQUIRE_THAT(sp2.m_z, Catch::Matchers::WithinAbs(p.m_z, 0.5f));
} }
...@@ -482,17 +480,17 @@ TEST_CASE("symm_2bi3_1, *utf::tolerance(0.1f)") ...@@ -482,17 +480,17 @@ TEST_CASE("symm_2bi3_1, *utf::tolerance(0.1f)")
auto sa1 = c.symmetry_copy(a1.get_location(), cif::sym_op(symm1)); auto sa1 = c.symmetry_copy(a1.get_location(), cif::sym_op(symm1));
auto sa2 = c.symmetry_copy(a2.get_location(), cif::sym_op(symm2)); auto sa2 = c.symmetry_copy(a2.get_location(), cif::sym_op(symm2));
REQUIRE(cif::distance(sa1, sa2) == dist); REQUIRE_THAT(cif::distance(sa1, sa2), Catch::Matchers::WithinAbs(dist, 0.5f));
auto pa1 = a1.get_location(); auto pa1 = a1.get_location();
const auto &[d, p, so] = c.closest_symmetry_copy(pa1, a2.get_location()); const auto &[d, p, so] = c.closest_symmetry_copy(pa1, a2.get_location());
REQUIRE(p.m_x == sa2.m_x); REQUIRE_THAT(p.m_x, Catch::Matchers::WithinAbs(sa2.m_x, 0.5f));
REQUIRE(p.m_y == sa2.m_y); REQUIRE_THAT(p.m_y, Catch::Matchers::WithinAbs(sa2.m_y, 0.5f));
REQUIRE(p.m_z == sa2.m_z); REQUIRE_THAT(p.m_z, Catch::Matchers::WithinAbs(sa2.m_z, 0.5f));
REQUIRE(d == dist); REQUIRE_THAT(d, Catch::Matchers::WithinAbs(dist, 0.5f));
REQUIRE(so.string() == symm2); REQUIRE(so.string() == symm2);
} }
} }
...@@ -532,15 +530,15 @@ TEST_CASE("symm_2bi3_1a, *utf::tolerance(0.1f)") ...@@ -532,15 +530,15 @@ TEST_CASE("symm_2bi3_1a, *utf::tolerance(0.1f)")
auto sa1 = c.symmetry_copy(p1, cif::sym_op(symm1)); auto sa1 = c.symmetry_copy(p1, cif::sym_op(symm1));
auto sa2 = c.symmetry_copy(p2, cif::sym_op(symm2)); auto sa2 = c.symmetry_copy(p2, cif::sym_op(symm2));
REQUIRE(cif::distance(sa1, sa2) == dist); REQUIRE_THAT(cif::distance(sa1, sa2), Catch::Matchers::WithinAbs(dist, 0.5f));
const auto &[d, p, so] = c.closest_symmetry_copy(p1, p2); const auto &[d, p, so] = c.closest_symmetry_copy(p1, p2);
REQUIRE(p.m_x == sa2.m_x); REQUIRE_THAT(p.m_x, Catch::Matchers::WithinAbs(sa2.m_x, 0.5f));
REQUIRE(p.m_y == sa2.m_y); REQUIRE_THAT(p.m_y, Catch::Matchers::WithinAbs(sa2.m_y, 0.5f));
REQUIRE(p.m_z == sa2.m_z); REQUIRE_THAT(p.m_z, Catch::Matchers::WithinAbs(sa2.m_z, 0.5f));
REQUIRE(d == dist); REQUIRE_THAT(d, Catch::Matchers::WithinAbs(dist, 0.5f));
REQUIRE(so.string() == symm2); REQUIRE(so.string() == symm2);
} }
} }
...@@ -563,7 +561,7 @@ TEST_CASE("symm_3bwh_1, *utf::tolerance(0.1f)") ...@@ -563,7 +561,7 @@ TEST_CASE("symm_3bwh_1, *utf::tolerance(0.1f)")
const auto&[ d, p, so ] = c.closest_symmetry_copy(a1.get_location(), a2.get_location()); const auto&[ d, p, so ] = c.closest_symmetry_copy(a1.get_location(), a2.get_location());
REQUIRE(d == distance(a1.get_location(), p)); REQUIRE_THAT(d, Catch::Matchers::WithinAbs(distance(a1.get_location(), p), 0.5f));
} }
} }
} }
...@@ -576,6 +574,6 @@ TEST_CASE("volume_3bwh_1, *utf::tolerance(0.1f)") ...@@ -576,6 +574,6 @@ TEST_CASE("volume_3bwh_1, *utf::tolerance(0.1f)")
cif::crystal c(db); cif::crystal c(db);
REQUIRE(c.get_cell().get_volume() == 741009.625f); REQUIRE_THAT(c.get_cell().get_volume(), Catch::Matchers::WithinRel(741009.625f, 0.01f));
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment