Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
c1807bf1
Unverified
Commit
c1807bf1
authored
Nov 23, 2023
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
catch2 work
parent
09dd6549
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
51 deletions
+49
-51
CMakeLists.txt
+1
-1
test/unit-3d-test.cpp
+48
-50
No files found.
CMakeLists.txt
View file @
c1807bf1
...
...
@@ -495,7 +495,7 @@ if(BUILD_TESTING)
add_custom_command
(
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
}
COMMAND $<TARGET_FILE:
${
CIFPP_TEST
}
> --data-dir
${
CMAKE_CURRENT_SOURCE_DIR
}
/test
)
...
...
test/unit-3d-test.cpp
View file @
c1807bf1
...
...
@@ -27,6 +27,7 @@
#include "test-main.hpp"
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <stdexcept>
...
...
@@ -92,8 +93,7 @@ TEST_CASE("t1")
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
(
std
::
fmod
(
360
+
angle
,
360
)
==
std
::
fmod
(
360
-
angle0
,
360
));
REQUIRE_THAT
(
std
::
fmod
(
360
+
angle
,
360
),
Catch
::
Matchers
::
WithinRel
(
std
::
fmod
(
360
-
angle0
,
360
),
0.01
));
for
(
auto
&
p
:
p1
)
p
.
rotate
(
q2
);
...
...
@@ -119,8 +119,7 @@ TEST_CASE("t2")
auto
&&
[
angle
,
axis
]
=
cif
::
quaternion_to_angle_axis
(
q
);
// REQUIRE(angle == 45/*, tt::tolerance(0.01)*/);
REQUIRE
(
angle
==
45
);
REQUIRE_THAT
(
angle
,
Catch
::
Matchers
::
WithinRel
(
45.
f
,
0.01
f
));
}
TEST_CASE
(
"t3"
)
...
...
@@ -144,8 +143,7 @@ TEST_CASE("t3")
double
a
=
cif
::
angle
(
v
,
p
[
0
],
p
[
1
]);
// REQUIRE(a == 45/*, tt::tolerance(0.01)*/);
REQUIRE
(
a
==
45
);
REQUIRE_THAT
(
a
,
Catch
::
Matchers
::
WithinRel
(
45.
f
,
0.01
f
));
}
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
);
REQUIRE
(
a
==
0
/*, tt::tolerance(0.01f)*/
);
REQUIRE
_THAT
(
a
,
Catch
::
Matchers
::
WithinRel
(
0
,
0.01
f
)
);
auto
q
=
cif
::
construct_from_angle_axis
(
90
,
axis
);
p
.
rotate
(
q
);
REQUIRE
(
p
.
m_x
==
1
/*, tt::tolerance(0.01f)*/
);
REQUIRE
(
p
.
m_y
==
0
/*, tt::tolerance(0.01f)*/
);
REQUIRE
(
p
.
m_z
==
1
/*, tt::tolerance(0.01f)*/
);
REQUIRE
_THAT
(
p
.
m_x
,
Catch
::
Matchers
::
WithinRel
(
1
,
0.01
f
)
);
REQUIRE
_THAT
(
p
.
m_y
,
Catch
::
Matchers
::
WithinRel
(
0
,
0.01
f
)
);
REQUIRE
_THAT
(
p
.
m_z
,
Catch
::
Matchers
::
WithinRel
(
1
,
0.01
f
)
);
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.01
f
)
);
q
=
cif
::
construct_from_angle_axis
(
-
90
,
axis
);
p
.
rotate
(
q
);
REQUIRE
(
p
.
m_x
==
1
/*, tt::tolerance(0.01f)*/
);
REQUIRE
(
p
.
m_y
==
1
/*, tt::tolerance(0.01f)*/
);
REQUIRE
(
p
.
m_z
==
0
/*, tt::tolerance(0.01f)*/
);
REQUIRE
_THAT
(
p
.
m_x
,
Catch
::
Matchers
::
WithinRel
(
1
,
0.01
f
)
);
REQUIRE
_THAT
(
p
.
m_y
,
Catch
::
Matchers
::
WithinRel
(
1
,
0.01
f
)
);
REQUIRE
_THAT
(
p
.
m_z
,
Catch
::
Matchers
::
WithinRel
(
0
,
0.01
f
)
);
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.01
f
)
);
}
...
...
@@ -227,7 +225,7 @@ TEST_CASE("dh_q_1")
pts
[
3
].
rotate
(
q
,
pts
[
2
]);
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.1
f
)
);
}
}
...
...
@@ -290,9 +288,9 @@ TEST_CASE("m2q_0, *utf::tolerance(0.001f)")
cif
::
point
p3
=
rot
*
p1
;
REQUIRE
(
p2
.
m_x
==
p3
.
m_x
);
REQUIRE
(
p2
.
m_y
==
p3
.
m_y
);
REQUIRE
(
p2
.
m_z
==
p3
.
m_z
);
REQUIRE
_THAT
(
p2
.
m_x
,
Catch
::
Matchers
::
WithinRel
(
p3
.
m_x
,
0.01
f
)
);
REQUIRE
_THAT
(
p2
.
m_y
,
Catch
::
Matchers
::
WithinRel
(
p3
.
m_y
,
0.01
f
)
);
REQUIRE
_THAT
(
p2
.
m_z
,
Catch
::
Matchers
::
WithinRel
(
p3
.
m_z
,
0.01
f
)
);
}
}
...
...
@@ -365,15 +363,15 @@ TEST_CASE("symm_1")
cif
::
point
f
=
fractional
(
p
,
c
);
REQUIRE
(
f
.
m_x
==
0.1
f
/*, tt::tolerance(0.01)*/
);
REQUIRE
(
f
.
m_y
==
0.1
f
/*, tt::tolerance(0.01)*/
);
REQUIRE
(
f
.
m_z
==
0.1
f
/*, tt::tolerance(0.01)*/
);
REQUIRE
_THAT
(
f
.
m_x
,
Catch
::
Matchers
::
WithinRel
(
0.1
f
,
0.01
f
)
);
REQUIRE
_THAT
(
f
.
m_y
,
Catch
::
Matchers
::
WithinRel
(
0.1
f
,
0.01
f
)
);
REQUIRE
_THAT
(
f
.
m_z
,
Catch
::
Matchers
::
WithinRel
(
0.1
f
,
0.01
f
)
);
cif
::
point
o
=
orthogonal
(
f
,
c
);
REQUIRE
(
o
.
m_x
==
1.
f
/*, tt::tolerance(0.01)*/
);
REQUIRE
(
o
.
m_y
==
1.
f
/*, tt::tolerance(0.01)*/
);
REQUIRE
(
o
.
m_z
==
1.
f
/*, tt::tolerance(0.01)*/
);
REQUIRE
_THAT
(
o
.
m_x
,
Catch
::
Matchers
::
WithinRel
(
1.
f
,
0.01
f
)
);
REQUIRE
_THAT
(
o
.
m_y
,
Catch
::
Matchers
::
WithinRel
(
1.
f
,
0.01
f
)
);
REQUIRE
_THAT
(
o
.
m_z
,
Catch
::
Matchers
::
WithinRel
(
1.
f
,
0.01
f
)
);
}
TEST_CASE
(
"symm_2"
)
...
...
@@ -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
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
(
distance
(
a
,
sg
(
a
,
c
,
"1_545"
_symop
))
==
static_cast
<
float
>
(
c
.
get_b
()
));
REQUIRE
(
distance
(
a
,
sg
(
a
,
c
,
"1_554"
_symop
))
==
static_cast
<
float
>
(
c
.
get_c
()
));
REQUIRE
_THAT
(
distance
(
a
,
sg
(
a
,
c
,
"1_455"
_symop
)),
Catch
::
Matchers
::
WithinRel
(
static_cast
<
float
>
(
c
.
get_a
()),
0.01
f
));
REQUIRE
_THAT
(
distance
(
a
,
sg
(
a
,
c
,
"1_545"
_symop
)),
Catch
::
Matchers
::
WithinRel
(
static_cast
<
float
>
(
c
.
get_b
()),
0.01
f
));
REQUIRE
_THAT
(
distance
(
a
,
sg
(
a
,
c
,
"1_554"
_symop
)),
Catch
::
Matchers
::
WithinRel
(
static_cast
<
float
>
(
c
.
get_c
()),
0.01
f
));
auto
sb2
=
sg
(
b
,
c
,
"4_565"
_symop
);
REQUIRE
(
sb
.
m_x
==
sb2
.
m_x
);
REQUIRE
(
sb
.
m_y
==
sb2
.
m_y
);
REQUIRE
(
sb
.
m_z
==
sb2
.
m_z
);
REQUIRE
_THAT
(
sb
.
m_x
,
Catch
::
Matchers
::
WithinRel
(
sb2
.
m_x
,
0.01
f
)
);
REQUIRE
_THAT
(
sb
.
m_y
,
Catch
::
Matchers
::
WithinRel
(
sb2
.
m_y
,
0.01
f
)
);
REQUIRE
_THAT
(
sb
.
m_z
,
Catch
::
Matchers
::
WithinRel
(
sb2
.
m_z
,
0.01
f
)
);
REQUIRE
(
distance
(
a
,
sb2
)
==
7.42
f
);
REQUIRE
_THAT
(
distance
(
a
,
sb2
),
Catch
::
Matchers
::
WithinRel
(
7.42
f
,
0.01
f
)
);
}
// --------------------------------------------------------------------
...
...
@@ -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
sp1
=
c
.
symmetry_copy
(
a
.
get_location
(),
"2_565"
_symop
);
REQUIRE
(
sp1
.
m_x
==
p
.
m_x
);
REQUIRE
(
sp1
.
m_y
==
p
.
m_y
);
REQUIRE
(
sp1
.
m_z
==
p
.
m_z
);
REQUIRE
_THAT
(
sp1
.
m_x
,
Catch
::
Matchers
::
WithinAbs
(
p
.
m_x
,
1.0
f
)
);
REQUIRE
_THAT
(
sp1
.
m_y
,
Catch
::
Matchers
::
WithinAbs
(
p
.
m_y
,
1.0
f
)
);
REQUIRE
_THAT
(
sp1
.
m_z
,
Catch
::
Matchers
::
WithinAbs
(
p
.
m_z
,
1.0
f
)
);
const
auto
&
[
d
,
sp2
,
so
]
=
c
.
closest_symmetry_copy
(
p
,
a
.
get_location
());
REQUIRE
(
d
<
1
);
REQUIRE
(
sp2
.
m_x
==
p
.
m_x
);
REQUIRE
(
sp2
.
m_y
==
p
.
m_y
);
REQUIRE
(
sp2
.
m_z
==
p
.
m_z
);
REQUIRE
_THAT
(
sp2
.
m_x
,
Catch
::
Matchers
::
WithinAbs
(
p
.
m_x
,
1.0
f
)
);
REQUIRE
_THAT
(
sp2
.
m_y
,
Catch
::
Matchers
::
WithinAbs
(
p
.
m_y
,
1.0
f
)
);
REQUIRE
_THAT
(
sp2
.
m_z
,
Catch
::
Matchers
::
WithinAbs
(
p
.
m_z
,
1.0
f
)
);
}
...
...
@@ -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
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
,
1.0
f
)
);
auto
pa1
=
a1
.
get_location
();
const
auto
&
[
d
,
p
,
so
]
=
c
.
closest_symmetry_copy
(
pa1
,
a2
.
get_location
());
REQUIRE
(
p
.
m_x
==
sa2
.
m_x
);
REQUIRE
(
p
.
m_y
==
sa2
.
m_y
);
REQUIRE
(
p
.
m_z
==
sa2
.
m_z
);
REQUIRE
_THAT
(
p
.
m_x
,
Catch
::
Matchers
::
WithinAbs
(
sa2
.
m_x
,
1.0
f
)
);
REQUIRE
_THAT
(
p
.
m_y
,
Catch
::
Matchers
::
WithinAbs
(
sa2
.
m_y
,
1.0
f
)
);
REQUIRE
_THAT
(
p
.
m_z
,
Catch
::
Matchers
::
WithinAbs
(
sa2
.
m_z
,
1.0
f
)
);
REQUIRE
(
d
==
dist
);
REQUIRE
_THAT
(
d
,
Catch
::
Matchers
::
WithinAbs
(
dist
,
1.0
f
)
);
REQUIRE
(
so
.
string
()
==
symm2
);
}
}
...
...
@@ -532,15 +530,15 @@ TEST_CASE("symm_2bi3_1a, *utf::tolerance(0.1f)")
auto
sa1
=
c
.
symmetry_copy
(
p1
,
cif
::
sym_op
(
symm1
));
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
,
1.0
f
)
);
const
auto
&
[
d
,
p
,
so
]
=
c
.
closest_symmetry_copy
(
p1
,
p2
);
REQUIRE
(
p
.
m_x
==
sa2
.
m_x
);
REQUIRE
(
p
.
m_y
==
sa2
.
m_y
);
REQUIRE
(
p
.
m_z
==
sa2
.
m_z
);
REQUIRE
_THAT
(
p
.
m_x
,
Catch
::
Matchers
::
WithinAbs
(
sa2
.
m_x
,
1.0
f
)
);
REQUIRE
_THAT
(
p
.
m_y
,
Catch
::
Matchers
::
WithinAbs
(
sa2
.
m_y
,
1.0
f
)
);
REQUIRE
_THAT
(
p
.
m_z
,
Catch
::
Matchers
::
WithinAbs
(
sa2
.
m_z
,
1.0
f
)
);
REQUIRE
(
d
==
dist
);
REQUIRE
_THAT
(
d
,
Catch
::
Matchers
::
WithinAbs
(
dist
,
1.0
f
)
);
REQUIRE
(
so
.
string
()
==
symm2
);
}
}
...
...
@@ -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
());
REQUIRE
(
d
==
distance
(
a1
.
get_location
(),
p
));
REQUIRE
_THAT
(
d
,
Catch
::
Matchers
::
WithinAbs
(
distance
(
a1
.
get_location
(),
p
),
1.0
f
));
}
}
}
...
...
@@ -576,6 +574,6 @@ TEST_CASE("volume_3bwh_1, *utf::tolerance(0.1f)")
cif
::
crystal
c
(
db
);
REQUIRE
(
c
.
get_cell
().
get_volume
()
==
741009.625
f
);
REQUIRE
_THAT
(
c
.
get_cell
().
get_volume
(),
Catch
::
Matchers
::
WithinRel
(
741009.625
f
,
0.01
f
)
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment