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
09dd6549
Unverified
Commit
09dd6549
authored
Nov 22, 2023
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change testing framework to Catch2
parent
640552ab
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
262 additions
and
334 deletions
+262
-334
CMakeLists.txt
+27
-5
test/format-test.cpp
+5
-45
test/model-test.cpp
+59
-88
test/rename-compound-test.cpp
+20
-37
test/spinner-test.cpp
+5
-13
test/sugar-test.cpp
+25
-47
test/test-main.cpp
+39
-0
test/test-main.hpp
+3
-0
test/unit-3d-test.cpp
+79
-99
No files found.
CMakeLists.txt
View file @
09dd6549
...
@@ -451,17 +451,39 @@ write_basic_package_version_file(
...
@@ -451,17 +451,39 @@ write_basic_package_version_file(
)
)
if
(
BUILD_TESTING
)
if
(
BUILD_TESTING
)
find_package
(
Boost REQUIRED
)
set
(
CATCH_BUILD_TESTING OFF
)
list
(
APPEND CIFPP_tests unit-v2 unit-3d format model rename-compound sugar spinner
)
find_package
(
Catch2 3 QUIET
)
if
(
NOT Catch2_FOUND
)
Include
(
FetchContent
)
FetchContent_Declare
(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0
)
FetchContent_MakeAvailable
(
Catch2
)
endif
()
list
(
APPEND CIFPP_tests
# unit-v2
unit-3d
format
model
rename-compound
sugar
spinner
)
foreach
(
CIFPP_TEST IN LISTS CIFPP_tests
)
foreach
(
CIFPP_TEST IN LISTS CIFPP_tests
)
set
(
CIFPP_TEST
"
${
CIFPP_TEST
}
-test"
)
set
(
CIFPP_TEST
"
${
CIFPP_TEST
}
-test"
)
set
(
CIFPP_TEST_SOURCE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/
${
CIFPP_TEST
}
.cpp"
)
set
(
CIFPP_TEST_SOURCE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/
${
CIFPP_TEST
}
.cpp"
)
add_executable
(
${
CIFPP_TEST
}
${
CIFPP_TEST_SOURCE
}
)
add_executable
(
${
CIFPP_TEST
}
${
CIFPP_TEST_SOURCE
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/test-main.cpp"
)
target_link_libraries
(
${
CIFPP_TEST
}
PRIVATE Threads::Threads cifpp::cifpp
Boost::boost
)
target_link_libraries
(
${
CIFPP_TEST
}
PRIVATE Threads::Threads cifpp::cifpp
Catch2::Catch2
)
target_include_directories
(
${
CIFPP_TEST
}
PRIVATE
${
EIGEN_INCLUDE_DIR
}
)
target_include_directories
(
${
CIFPP_TEST
}
PRIVATE
${
EIGEN_INCLUDE_DIR
}
)
if
(
MSVC
)
if
(
MSVC
)
...
@@ -476,7 +498,7 @@ if(BUILD_TESTING)
...
@@ -476,7 +498,7 @@ if(BUILD_TESTING)
COMMAND $<TARGET_FILE:
${
CIFPP_TEST
}
> --
${
CMAKE_CURRENT_SOURCE_DIR
}
/test
)
COMMAND $<TARGET_FILE:
${
CIFPP_TEST
}
> --
${
CMAKE_CURRENT_SOURCE_DIR
}
/test
)
add_test
(
NAME
${
CIFPP_TEST
}
add_test
(
NAME
${
CIFPP_TEST
}
COMMAND $<TARGET_FILE:
${
CIFPP_TEST
}
> --
${
CMAKE_CURRENT_SOURCE_DIR
}
/test
)
COMMAND $<TARGET_FILE:
${
CIFPP_TEST
}
> --
data-dir
${
CMAKE_CURRENT_SOURCE_DIR
}
/test
)
endforeach
()
endforeach
()
endif
()
endif
()
...
...
test/format-test.cpp
View file @
09dd6549
...
@@ -24,69 +24,29 @@
...
@@ -24,69 +24,29 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
#define BOOST_TEST_ALTERNATIVE_INIT_API
#include <catch2/catch_test_macros.hpp>
#include <boost/test/included/unit_test.hpp>
#include <stdexcept>
#include <stdexcept>
#include <cif++.hpp>
#include <cif++.hpp>
namespace
tt
=
boost
::
test_tools
;
std
::
filesystem
::
path
gTestDir
=
std
::
filesystem
::
current_path
();
// filled in first test
// --------------------------------------------------------------------
cif
::
file
operator
""
_cf
(
const
char
*
text
,
size_t
length
)
{
struct
membuf
:
public
std
::
streambuf
{
membuf
(
char
*
text
,
size_t
length
)
{
this
->
setg
(
text
,
text
,
text
+
length
);
}
}
buffer
(
const_cast
<
char
*>
(
text
),
length
);
std
::
istream
is
(
&
buffer
);
return
cif
::
file
(
is
);
}
// --------------------------------------------------------------------
bool
init_unit_test
()
{
cif
::
VERBOSE
=
1
;
// // not a test, just initialize test dir
// if (boost::unit_test::framework::master_test_suite().argc == 2)
// gTestDir = boost::unit_test::framework::master_test_suite().argv[1];
// // do this now, avoids the need for installing
// cif::add_file_resource("mmcif_pdbx.dic", gTestDir / ".." / "rsrc" / "mmcif_pdbx.dic");
// // initialize CCD location
// cif::add_file_resource("components.cif", gTestDir / ".." / "data" / "ccd-subset.cif");
return
true
;
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
fmt_1
)
TEST_CASE
(
"fmt_1"
)
{
{
std
::
ostringstream
os
;
std
::
ostringstream
os
;
std
::
string
world
(
"world"
);
std
::
string
world
(
"world"
);
os
<<
cif
::
format
(
"Hello, %-10.10s, the magic number is %d and pi is %g"
,
world
,
42
,
cif
::
kPI
);
os
<<
cif
::
format
(
"Hello, %-10.10s, the magic number is %d and pi is %g"
,
world
,
42
,
cif
::
kPI
);
BOOST_CHECK_EQUAL
(
os
.
str
(),
"Hello, world , the magic number is 42 and pi is 3.14159"
);
REQUIRE
(
os
.
str
()
==
"Hello, world , the magic number is 42 and pi is 3.14159"
);
BOOST_CHECK_EQUAL
(
cif
::
format
(
"Hello, %-10.10s, the magic number is %d and pi is %g"
,
world
,
42
,
cif
::
kPI
).
str
(),
REQUIRE
(
cif
::
format
(
"Hello, %-10.10s, the magic number is %d and pi is %g"
,
world
,
42
,
cif
::
kPI
).
str
()
==
"Hello, world , the magic number is 42 and pi is 3.14159"
);
"Hello, world , the magic number is 42 and pi is 3.14159"
);
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
clr_1
)
TEST_CASE
(
"clr_1"
)
{
{
using
namespace
cif
::
colour
;
using
namespace
cif
::
colour
;
...
...
test/model-test.cpp
View file @
09dd6549
/*-
/*-
* SPDX-License-Identifier: BSD-2-Clause
* SPDX-License-Identifier: BSD-2-Clause
*
*
* Copyright (c) 2021 NKI/AVL, Netherlands Cancer Institute
* Copyright (c) 2021 NKI/AVL, Netherlands Cancer Institute
*
*
* Redistribution and use in source and binary forms, with or without
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer
* list of conditions and the following disclaimer
* 2. Redistributions in binary form must reproduce the above copyright notice,
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
...
@@ -24,8 +24,9 @@
...
@@ -24,8 +24,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
#define BOOST_TEST_ALTERNATIVE_INIT_API
#include "test-main.hpp"
#include <boost/test/included/unit_test.hpp>
#include <catch2/catch_test_macros.hpp>
#include <stdexcept>
#include <stdexcept>
...
@@ -33,59 +34,30 @@
...
@@ -33,59 +34,30 @@
// --------------------------------------------------------------------
// --------------------------------------------------------------------
cif
::
file
operator
""
_cf
(
const
char
*
text
,
size_t
length
)
cif
::
file
operator
""
_cf
(
const
char
*
text
,
size_t
length
)
{
{
struct
membuf
:
public
std
::
streambuf
struct
membuf
:
public
std
::
streambuf
{
membuf
(
char
*
text
,
size_t
length
)
{
this
->
setg
(
text
,
text
,
text
+
length
);
}
}
buffer
(
const_cast
<
char
*>
(
text
),
length
);
std
::
istream
is
(
&
buffer
);
return
cif
::
file
(
is
);
}
// --------------------------------------------------------------------
std
::
filesystem
::
path
gTestDir
=
std
::
filesystem
::
current_path
();
bool
init_unit_test
()
{
cif
::
VERBOSE
=
1
;
// not a test, just initialize test dir
if
(
boost
::
unit_test
::
framework
::
master_test_suite
().
argc
==
2
)
gTestDir
=
boost
::
unit_test
::
framework
::
master_test_suite
().
argv
[
1
];
else
{
{
while
(
not
gTestDir
.
empty
()
and
not
std
::
filesystem
::
exists
(
gTestDir
/
"test"
))
membuf
(
char
*
text
,
size_t
length
)
gTestDir
=
gTestDir
.
parent_path
();
{
gTestDir
/=
"test"
;
this
->
setg
(
text
,
text
,
text
+
length
);
}
}
}
buffer
(
const_cast
<
char
*>
(
text
),
length
);
// do this now, avoids the need for installing
cif
::
add_file_resource
(
"mmcif_pdbx.dic"
,
gTestDir
/
".."
/
"rsrc"
/
"mmcif_pdbx.dic"
);
std
::
istream
is
(
&
buffer
);
return
cif
::
file
(
is
);
// initialize CCD location
cif
::
add_file_resource
(
"components.cif"
,
gTestDir
/
".."
/
"data"
/
"ccd-subset.cif"
);
cif
::
compound_factory
::
instance
().
push_dictionary
(
gTestDir
/
"HEM.cif"
);
return
true
;
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
create_nonpoly_1
)
TEST_CASE
(
"create_nonpoly_1"
)
{
{
cif
::
VERBOSE
=
1
;
cif
::
VERBOSE
=
1
;
cif
::
file
file
;
cif
::
file
file
;
file
.
load_dictionary
(
"mmcif_pdbx.dic"
);
file
.
load_dictionary
(
"mmcif_pdbx.dic"
);
file
.
emplace
(
"TEST"
);
// create a datablock
file
.
emplace
(
"TEST"
);
// create a datablock
cif
::
mm
::
structure
structure
(
file
);
cif
::
mm
::
structure
structure
(
file
);
std
::
string
entity_id
=
structure
.
create_non_poly_entity
(
"HEM"
);
std
::
string
entity_id
=
structure
.
create_non_poly_entity
(
"HEM"
);
...
@@ -119,7 +91,7 @@ _atom_site.pdbx_formal_charge
...
@@ -119,7 +91,7 @@ _atom_site.pdbx_formal_charge
auto
hem_atoms
=
atom_site
.
rows
();
auto
hem_atoms
=
atom_site
.
rows
();
std
::
vector
<
cif
::
mm
::
atom
>
atom_data
;
std
::
vector
<
cif
::
mm
::
atom
>
atom_data
;
for
(
auto
hem_atom
:
hem_atoms
)
for
(
auto
hem_atom
:
hem_atoms
)
atom_data
.
emplace_back
(
hem_data
,
hem_atom
);
atom_data
.
emplace_back
(
hem_data
,
hem_atom
);
structure
.
create_non_poly
(
entity_id
,
atom_data
);
structure
.
create_non_poly
(
entity_id
,
atom_data
);
...
@@ -191,25 +163,25 @@ _atom_type.symbol C
...
@@ -191,25 +163,25 @@ _atom_type.symbol C
expected
.
load_dictionary
(
"mmcif_pdbx.dic"
);
expected
.
load_dictionary
(
"mmcif_pdbx.dic"
);
if
(
not
(
expected
.
front
()
==
structure
.
get_datablock
()))
if
(
not
(
expected
.
front
()
==
structure
.
get_datablock
()))
{
{
BOOST_TEST
(
false
);
REQUIRE
(
false
);
std
::
cout
<<
expected
.
front
()
<<
'\n'
std
::
cout
<<
expected
.
front
()
<<
'\n'
<<
'\n'
<<
'\n'
<<
structure
.
get_datablock
()
<<
'\n'
;
<<
structure
.
get_datablock
()
<<
'\n'
;
}
}
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
create_nonpoly_2
)
TEST_CASE
(
"create_nonpoly_2"
)
{
{
cif
::
VERBOSE
=
1
;
cif
::
VERBOSE
=
1
;
cif
::
file
file
;
cif
::
file
file
;
file
.
load_dictionary
(
"mmcif_pdbx.dic"
);
file
.
load_dictionary
(
"mmcif_pdbx.dic"
);
file
.
emplace
(
"TEST"
);
// create a datablock
file
.
emplace
(
"TEST"
);
// create a datablock
cif
::
mm
::
structure
structure
(
file
);
cif
::
mm
::
structure
structure
(
file
);
cif
::
file
lig
(
gTestDir
/
"HEM.cif"
);
cif
::
file
lig
(
gTestDir
/
"HEM.cif"
);
...
@@ -218,8 +190,8 @@ BOOST_AUTO_TEST_CASE(create_nonpoly_2)
...
@@ -218,8 +190,8 @@ BOOST_AUTO_TEST_CASE(create_nonpoly_2)
std
::
vector
<
cif
::
row_initializer
>
atoms
;
std
::
vector
<
cif
::
row_initializer
>
atoms
;
for
(
const
auto
&
[
type_symbol
,
label_atom_id
,
Cartn_x
,
Cartn_y
,
Cartn_z
]
:
for
(
const
auto
&
[
type_symbol
,
label_atom_id
,
Cartn_x
,
Cartn_y
,
Cartn_z
]
:
chem_comp_atom
.
rows
<
std
::
string
,
std
::
string
,
float
,
float
,
float
>
(
chem_comp_atom
.
rows
<
std
::
string
,
std
::
string
,
float
,
float
,
float
>
(
"type_symbol"
,
"atom_id"
,
"model_Cartn_x"
,
"model_Cartn_y"
,
"model_Cartn_z"
))
"type_symbol"
,
"atom_id"
,
"model_Cartn_x"
,
"model_Cartn_y"
,
"model_Cartn_z"
))
{
{
atoms
.
emplace_back
(
cif
::
row_initializer
{
atoms
.
emplace_back
(
cif
::
row_initializer
{
{
"type_symbol"
,
type_symbol
},
{
"type_symbol"
,
type_symbol
},
...
@@ -227,8 +199,7 @@ BOOST_AUTO_TEST_CASE(create_nonpoly_2)
...
@@ -227,8 +199,7 @@ BOOST_AUTO_TEST_CASE(create_nonpoly_2)
{
"auth_atom_id"
,
label_atom_id
},
{
"auth_atom_id"
,
label_atom_id
},
{
"Cartn_x"
,
Cartn_x
},
{
"Cartn_x"
,
Cartn_x
},
{
"Cartn_y"
,
Cartn_y
},
{
"Cartn_y"
,
Cartn_y
},
{
"Cartn_z"
,
Cartn_z
}
{
"Cartn_z"
,
Cartn_z
}
});
});
if
(
atoms
.
size
()
==
4
)
if
(
atoms
.
size
()
==
4
)
break
;
break
;
...
@@ -303,23 +274,23 @@ _atom_type.symbol C
...
@@ -303,23 +274,23 @@ _atom_type.symbol C
expected
.
load_dictionary
(
"mmcif_pdbx.dic"
);
expected
.
load_dictionary
(
"mmcif_pdbx.dic"
);
if
(
not
(
expected
.
front
()
==
structure
.
get_datablock
()))
REQUIRE
(
expected
.
front
()
==
structure
.
get_datablock
());
if
(
not
(
expected
.
front
()
==
structure
.
get_datablock
()))
{
{
BOOST_TEST
(
false
);
// REQUIRE
(false);
std
::
cout
<<
expected
.
front
()
<<
'\n'
std
::
cout
<<
expected
.
front
()
<<
'\n'
<<
'\n'
<<
'\n'
<<
structure
.
get_datablock
()
<<
'\n'
;
<<
structure
.
get_datablock
()
<<
'\n'
;
expected
.
save
(
"/tmp/a"
);
expected
.
save
(
"/tmp/a"
);
file
.
save
(
"/tmp/b"
);
file
.
save
(
"/tmp/b"
);
}
}
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
test_atom_id
)
TEST_CASE
(
"test_atom_id"
)
{
{
auto
data
=
R"(
auto
data
=
R"(
data_TEST
data_TEST
...
@@ -389,15 +360,15 @@ _struct_asym.details ?
...
@@ -389,15 +360,15 @@ _struct_asym.details ?
cif
::
mm
::
structure
s
(
data
);
cif
::
mm
::
structure
s
(
data
);
BOOST_CHECK_EQUAL
(
s
.
get_atom_by_id
(
"1"
).
get_label_atom_id
(),
"CHA"
);
REQUIRE
(
s
.
get_atom_by_id
(
"1"
).
get_label_atom_id
()
==
"CHA"
);
BOOST_CHECK_EQUAL
(
s
.
get_atom_by_id
(
"2"
).
get_label_atom_id
(),
"CHC"
);
REQUIRE
(
s
.
get_atom_by_id
(
"2"
).
get_label_atom_id
()
==
"CHC"
);
BOOST_CHECK_EQUAL
(
s
.
get_atom_by_id
(
"3"
).
get_label_atom_id
(),
"CHB"
);
REQUIRE
(
s
.
get_atom_by_id
(
"3"
).
get_label_atom_id
()
==
"CHB"
);
BOOST_CHECK_EQUAL
(
s
.
get_atom_by_id
(
"4"
).
get_label_atom_id
(),
"CHD"
);
REQUIRE
(
s
.
get_atom_by_id
(
"4"
).
get_label_atom_id
()
==
"CHD"
);
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
atom_numbers_1
)
TEST_CASE
(
"atom_numbers_1"
)
{
{
const
std
::
filesystem
::
path
test1
(
gTestDir
/
".."
/
"examples"
/
"1cbs.cif.gz"
);
const
std
::
filesystem
::
path
test1
(
gTestDir
/
".."
/
"examples"
/
"1cbs.cif.gz"
);
cif
::
file
file
(
test1
.
string
());
cif
::
file
file
(
test1
.
string
());
...
@@ -409,27 +380,27 @@ BOOST_AUTO_TEST_CASE(atom_numbers_1)
...
@@ -409,27 +380,27 @@ BOOST_AUTO_TEST_CASE(atom_numbers_1)
auto
ai
=
atoms
.
begin
();
auto
ai
=
atoms
.
begin
();
for
(
const
auto
&
[
id
,
label_asym_id
,
label_seq_id
,
label_atom_id
,
auth_seq_id
,
label_comp_id
]
:
for
(
const
auto
&
[
id
,
label_asym_id
,
label_seq_id
,
label_atom_id
,
auth_seq_id
,
label_comp_id
]
:
db
[
"atom_site"
].
rows
<
std
::
string
,
std
::
string
,
int
,
std
::
string
,
std
::
string
,
std
::
string
>
(
"id"
,
"label_asym_id"
,
"label_seq_id"
,
"label_atom_id"
,
"auth_seq_id"
,
"label_comp_id"
))
db
[
"atom_site"
].
rows
<
std
::
string
,
std
::
string
,
int
,
std
::
string
,
std
::
string
,
std
::
string
>
(
"id"
,
"label_asym_id"
,
"label_seq_id"
,
"label_atom_id"
,
"auth_seq_id"
,
"label_comp_id"
))
{
{
auto
atom
=
structure
.
get_atom_by_id
(
id
);
auto
atom
=
structure
.
get_atom_by_id
(
id
);
BOOST_CHECK_EQUAL
(
atom
.
get_label_asym_id
(),
label_asym_id
);
REQUIRE
(
atom
.
get_label_asym_id
()
==
label_asym_id
);
BOOST_CHECK_EQUAL
(
atom
.
get_label_seq_id
(),
label_seq_id
);
REQUIRE
(
atom
.
get_label_seq_id
()
==
label_seq_id
);
BOOST_CHECK_EQUAL
(
atom
.
get_label_atom_id
(),
label_atom_id
);
REQUIRE
(
atom
.
get_label_atom_id
()
==
label_atom_id
);
BOOST_CHECK_EQUAL
(
atom
.
get_auth_seq_id
(),
auth_seq_id
);
REQUIRE
(
atom
.
get_auth_seq_id
()
==
auth_seq_id
);
BOOST_CHECK_EQUAL
(
atom
.
get_label_comp_id
(),
label_comp_id
);
REQUIRE
(
atom
.
get_label_comp_id
()
==
label_comp_id
);
BOOST_ASSERT
(
ai
!=
atoms
.
end
());
REQUIRE
(
ai
!=
atoms
.
end
());
BOOST_CHECK_EQUAL
(
ai
->
id
(),
id
);
REQUIRE
(
ai
->
id
()
==
id
);
++
ai
;
++
ai
;
}
}
BOOST_ASSERT
(
ai
==
atoms
.
end
());
REQUIRE
(
ai
==
atoms
.
end
());
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
test_load_2
)
TEST_CASE
(
"test_load_2"
)
{
{
using
namespace
cif
::
literals
;
using
namespace
cif
::
literals
;
...
@@ -440,17 +411,17 @@ BOOST_AUTO_TEST_CASE(test_load_2)
...
@@ -440,17 +411,17 @@ BOOST_AUTO_TEST_CASE(test_load_2)
cif
::
mm
::
structure
s
(
file
);
cif
::
mm
::
structure
s
(
file
);
BOOST_CHECK
(
s
.
polymers
().
size
()
==
1
);
REQUIRE
(
s
.
polymers
().
size
()
==
1UL
);
auto
&
pdbx_poly_seq_scheme
=
db
[
"pdbx_poly_seq_scheme"
];
auto
&
pdbx_poly_seq_scheme
=
db
[
"pdbx_poly_seq_scheme"
];
for
(
auto
&
poly
:
s
.
polymers
())
for
(
auto
&
poly
:
s
.
polymers
())
{
{
BOOST_CHECK_EQUAL
(
poly
.
size
(),
pdbx_poly_seq_scheme
.
find
(
"asym_id"
_key
==
poly
.
get_asym_id
()).
size
());
REQUIRE
(
poly
.
size
()
==
pdbx_poly_seq_scheme
.
find
(
"asym_id"
_key
==
poly
.
get_asym_id
()).
size
());
}
}
}
}
BOOST_AUTO_TEST_CASE
(
remove_residue_1
)
TEST_CASE
(
"remove_residue_1"
)
{
{
using
namespace
cif
::
literals
;
using
namespace
cif
::
literals
;
...
@@ -460,5 +431,5 @@ BOOST_AUTO_TEST_CASE(remove_residue_1)
...
@@ -460,5 +431,5 @@ BOOST_AUTO_TEST_CASE(remove_residue_1)
cif
::
mm
::
structure
s
(
file
);
cif
::
mm
::
structure
s
(
file
);
s
.
remove_residue
(
s
.
get_residue
(
"B"
));
s
.
remove_residue
(
s
.
get_residue
(
"B"
));
BOOST_CHECK_NO_
THROW
(
s
.
validate_atoms
());
REQUIRE_NO
THROW
(
s
.
validate_atoms
());
}
}
test/rename-compound-test.cpp
View file @
09dd6549
...
@@ -24,57 +24,40 @@
...
@@ -24,57 +24,40 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
#include "test-main.hpp"
#include <cif++.hpp>
#include <cif++.hpp>
#include <catch2/catch_test_macros.hpp>
#include <iostream>
#include <iostream>
#include <fstream>
#include <fstream>
int
main
(
int
argc
,
char
*
argv
[]
)
TEST_CASE
(
"rename"
)
{
{
cif
::
VERBOSE
=
3
;
cif
::
VERBOSE
=
3
;
try
if
(
std
::
filesystem
::
exists
(
gTestDir
/
".."
/
"data"
/
"ccd-subset.cif"
))
{
cif
::
add_file_resource
(
"components.cif"
,
gTestDir
/
".."
/
"data"
/
"ccd-subset.cif"
);
std
::
filesystem
::
path
testdir
=
std
::
filesystem
::
current_path
();
if
(
argc
==
3
)
testdir
=
argv
[
2
];
else
{
while
(
not
testdir
.
empty
()
and
not
std
::
filesystem
::
exists
(
testdir
/
"test"
))
testdir
=
testdir
.
parent_path
();
testdir
/=
"test"
;
}
if
(
std
::
filesystem
::
exists
(
testdir
/
".."
/
"data"
/
"ccd-subset.cif"
))
cif
::
add_file_resource
(
"components.cif"
,
testdir
/
".."
/
"data"
/
"ccd-subset.cif"
);
if
(
std
::
filesystem
::
exists
(
testd
ir
/
".."
/
"rsrc"
/
"mmcif_pdbx.dic"
))
if
(
std
::
filesystem
::
exists
(
gTestD
ir
/
".."
/
"rsrc"
/
"mmcif_pdbx.dic"
))
cif
::
add_file_resource
(
"mmcif_pdbx.dic"
,
testd
ir
/
".."
/
"rsrc"
/
"mmcif_pdbx.dic"
);
cif
::
add_file_resource
(
"mmcif_pdbx.dic"
,
gTestD
ir
/
".."
/
"rsrc"
/
"mmcif_pdbx.dic"
);
cif
::
compound_factory
::
instance
().
push_dictionary
(
testd
ir
/
"REA.cif"
);
cif
::
compound_factory
::
instance
().
push_dictionary
(
gTestD
ir
/
"REA.cif"
);
cif
::
compound_factory
::
instance
().
push_dictionary
(
testd
ir
/
"RXA.cif"
);
cif
::
compound_factory
::
instance
().
push_dictionary
(
gTestD
ir
/
"RXA.cif"
);
cif
::
file
f
(
testd
ir
/
".."
/
"examples"
/
"1cbs.cif.gz"
);
cif
::
file
f
(
gTestD
ir
/
".."
/
"examples"
/
"1cbs.cif.gz"
);
cif
::
mm
::
structure
structure
(
f
);
cif
::
mm
::
structure
structure
(
f
);
auto
&
res
=
structure
.
get_residue
(
"B"
);
auto
&
res
=
structure
.
get_residue
(
"B"
);
structure
.
change_residue
(
res
,
"RXA"
,
{});
structure
.
change_residue
(
res
,
"RXA"
,
{});
structure
.
cleanup_empty_categories
();
structure
.
cleanup_empty_categories
();
f
.
save
(
std
::
cout
);
f
.
save
(
std
::
cout
);
if
(
not
f
.
is_valid
())
if
(
not
f
.
is_valid
())
throw
std
::
runtime_error
(
"Invalid"
);
throw
std
::
runtime_error
(
"Invalid"
);
f
.
save
(
std
::
cout
);
f
.
save
(
std
::
cout
);
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cerr
<<
e
.
what
()
<<
'\n'
;
exit
(
1
);
}
return
0
;
}
}
test/spinner-test.cpp
View file @
09dd6549
#include "cif++/utilities.hpp"
#include "cif++/utilities.hpp"
#include <catch2/catch_test_macros.hpp>
#include <random>
#include <random>
#include <thread>
#include <thread>
void
test_one
(
)
TEST_CASE
(
"test_one"
)
{
{
std
::
random_device
rd
;
std
::
random_device
rd
;
std
::
mt19937
gen
(
rd
());
std
::
mt19937
gen
(
rd
());
...
@@ -20,7 +22,7 @@ void test_one()
...
@@ -20,7 +22,7 @@ void test_one()
}
}
}
}
void
test_two
(
)
TEST_CASE
(
"test_two"
)
{
{
cif
::
progress_bar
pb
(
10
,
"test"
);
cif
::
progress_bar
pb
(
10
,
"test"
);
...
@@ -29,7 +31,7 @@ void test_two()
...
@@ -29,7 +31,7 @@ void test_two()
pb
.
consumed
(
1
);
pb
.
consumed
(
1
);
}
}
void
test_three
(
)
TEST_CASE
(
"test_three"
)
{
{
using
namespace
std
::
literals
;
using
namespace
std
::
literals
;
...
@@ -38,12 +40,3 @@ void test_three()
...
@@ -38,12 +40,3 @@ void test_three()
std
::
this_thread
::
sleep_for
(
100
ms
);
std
::
this_thread
::
sleep_for
(
100
ms
);
}
}
int
main
()
{
test_one
();
test_two
();
test_three
();
return
0
;
}
\ No newline at end of file
test/sugar-test.cpp
View file @
09dd6549
...
@@ -24,8 +24,9 @@
...
@@ -24,8 +24,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
#define BOOST_TEST_ALTERNATIVE_INIT_API
#include "test-main.hpp"
#include <boost/test/included/unit_test.hpp>
#include <catch2/catch_test_macros.hpp>
#include <stdexcept>
#include <stdexcept>
...
@@ -49,30 +50,7 @@ cif::file operator""_cf(const char* text, size_t length)
...
@@ -49,30 +50,7 @@ cif::file operator""_cf(const char* text, size_t length)
// --------------------------------------------------------------------
// --------------------------------------------------------------------
std
::
filesystem
::
path
gTestDir
=
std
::
filesystem
::
current_path
();
TEST_CASE
(
"sugar_name_1"
)
bool
init_unit_test
()
{
cif
::
VERBOSE
=
1
;
// not a test, just initialize test dir
if
(
boost
::
unit_test
::
framework
::
master_test_suite
().
argc
==
2
)
gTestDir
=
boost
::
unit_test
::
framework
::
master_test_suite
().
argv
[
1
];
// do this now, avoids the need for installing
cif
::
add_file_resource
(
"mmcif_pdbx.dic"
,
gTestDir
/
".."
/
"rsrc"
/
"mmcif_pdbx.dic"
);
// initialize CCD location
cif
::
add_file_resource
(
"components.cif"
,
gTestDir
/
".."
/
"data"
/
"ccd-subset.cif"
);
cif
::
compound_factory
::
instance
().
push_dictionary
(
gTestDir
/
"HEM.cif"
);
return
true
;
}
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
sugar_name_1
)
{
{
using
namespace
cif
::
literals
;
using
namespace
cif
::
literals
;
...
@@ -85,20 +63,20 @@ BOOST_AUTO_TEST_CASE(sugar_name_1)
...
@@ -85,20 +63,20 @@ BOOST_AUTO_TEST_CASE(sugar_name_1)
auto
&
branches
=
s
.
branches
();
auto
&
branches
=
s
.
branches
();
BOOST_CHECK_EQUAL
(
branches
.
size
(),
4
);
REQUIRE
(
branches
.
size
()
==
4UL
);
for
(
auto
&
branch
:
branches
)
for
(
auto
&
branch
:
branches
)
{
{
auto
entityID
=
branch
.
front
().
get_entity_id
();
auto
entityID
=
branch
.
front
().
get_entity_id
();
auto
name
=
entity
.
find1
<
std
::
string
>
(
"id"
_key
==
entityID
,
"pdbx_description"
);
auto
name
=
entity
.
find1
<
std
::
string
>
(
"id"
_key
==
entityID
,
"pdbx_description"
);
BOOST_CHECK_EQUAL
(
branch
.
name
(),
name
);
REQUIRE
(
branch
.
name
()
==
name
);
}
}
}
}
// // --------------------------------------------------------------------
// // --------------------------------------------------------------------
//
BOOST_AUTO_TEST_CASE(create_sugar_1
)
//
TEST_CASE("create_sugar_1"
)
// {
// {
// using namespace cif::literals;
// using namespace cif::literals;
...
@@ -125,19 +103,19 @@ BOOST_AUTO_TEST_CASE(sugar_name_1)
...
@@ -125,19 +103,19 @@ BOOST_AUTO_TEST_CASE(sugar_name_1)
// auto &branch = s.create_branch(ai);
// auto &branch = s.create_branch(ai);
//
BOOST_CHECK_EQUAL(branch.name(),
"2-acetamido-2-deoxy-beta-D-glucopyranose");
//
REQUIRE(branch.name() ==
"2-acetamido-2-deoxy-beta-D-glucopyranose");
//
BOOST_CHECK_EQUAL(branch.size(),
1);
//
REQUIRE(branch.size() ==
1);
//
BOOST_CHECK_EQUAL(branch[0].atoms().size(),
nagAtoms.size());
//
REQUIRE(branch[0].atoms().size() ==
nagAtoms.size());
//
BOOST_CHECK
(file.is_valid());
//
REQUIRE
(file.is_valid());
// file.save(gTestDir / "test-create_sugar_1.cif");
// file.save(gTestDir / "test-create_sugar_1.cif");
// }
// }
// // --------------------------------------------------------------------
// // --------------------------------------------------------------------
//
BOOST_AUTO_TEST_CASE(create_sugar_2
)
//
TEST_CASE("create_sugar_2"
)
// {
// {
// using namespace cif::literals;
// using namespace cif::literals;
...
@@ -148,7 +126,7 @@ BOOST_AUTO_TEST_CASE(sugar_name_1)
...
@@ -148,7 +126,7 @@ BOOST_AUTO_TEST_CASE(sugar_name_1)
// // Get branch for H
// // Get branch for H
// auto &bH = s.get_branch_by_asym_id("H");
// auto &bH = s.get_branch_by_asym_id("H");
//
BOOST_CHECK_EQUAL(bH.size(),
2);
//
REQUIRE(bH.size() ==
2);
// std::vector<cif::row_initializer> ai[2];
// std::vector<cif::row_initializer> ai[2];
...
@@ -163,24 +141,24 @@ BOOST_AUTO_TEST_CASE(sugar_name_1)
...
@@ -163,24 +141,24 @@ BOOST_AUTO_TEST_CASE(sugar_name_1)
// s.remove_branch(bH);
// s.remove_branch(bH);
//
BOOST_CHECK
(file.is_valid());
//
REQUIRE
(file.is_valid());
// auto &bN = s.create_branch(ai[0]);
// auto &bN = s.create_branch(ai[0]);
// s.extend_branch(bN.get_asym_id(), ai[1], 1, "O4");
// s.extend_branch(bN.get_asym_id(), ai[1], 1, "O4");
//
BOOST_CHECK_EQUAL(bN.name(),
"2-acetamido-2-deoxy-beta-D-glucopyranose-(1-4)-2-acetamido-2-deoxy-beta-D-glucopyranose");
//
REQUIRE(bN.name() ==
"2-acetamido-2-deoxy-beta-D-glucopyranose-(1-4)-2-acetamido-2-deoxy-beta-D-glucopyranose");
//
BOOST_CHECK_EQUAL(bN.size(),
2);
//
REQUIRE(bN.size() ==
2);
//
BOOST_CHECK
(file.is_valid());
//
REQUIRE
(file.is_valid());
// file.save(gTestDir / "test-create_sugar_2.cif");
// file.save(gTestDir / "test-create_sugar_2.cif");
//
BOOST_CHECK
_NO_THROW(cif::mm::structure s2(file));
//
REQUIRE
_NO_THROW(cif::mm::structure s2(file));
// }
// }
// --------------------------------------------------------------------
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
delete_sugar_1
)
TEST_CASE
(
"delete_sugar_1"
)
{
{
using
namespace
cif
::
literals
;
using
namespace
cif
::
literals
;
...
@@ -191,20 +169,20 @@ BOOST_AUTO_TEST_CASE(delete_sugar_1)
...
@@ -191,20 +169,20 @@ BOOST_AUTO_TEST_CASE(delete_sugar_1)
// Get branch for H
// Get branch for H
auto
&
bG
=
s
.
get_branch_by_asym_id
(
"G"
);
auto
&
bG
=
s
.
get_branch_by_asym_id
(
"G"
);
BOOST_CHECK_EQUAL
(
bG
.
size
(),
4
);
REQUIRE
(
bG
.
size
()
==
4UL
);
s
.
remove_residue
(
bG
[
1
]);
s
.
remove_residue
(
bG
[
1
]);
BOOST_CHECK_EQUAL
(
bG
.
size
(),
1
);
REQUIRE
(
bG
.
size
()
==
1UL
);
auto
&
bN
=
s
.
get_branch_by_asym_id
(
"G"
);
auto
&
bN
=
s
.
get_branch_by_asym_id
(
"G"
);
BOOST_CHECK_EQUAL
(
bN
.
name
(),
"2-acetamido-2-deoxy-beta-D-glucopyranose"
);
REQUIRE
(
bN
.
name
()
==
"2-acetamido-2-deoxy-beta-D-glucopyranose"
);
BOOST_CHECK_EQUAL
(
bN
.
size
(),
1
);
REQUIRE
(
bN
.
size
()
==
1UL
);
BOOST_CHECK
(
file
.
is_valid
());
REQUIRE
(
file
.
is_valid
());
// file.save(gTestDir / "test-create_sugar_3.cif");
// file.save(gTestDir / "test-create_sugar_3.cif");
BOOST_CHECK_NO_THROW
(
cif
::
mm
::
structure
s2
(
file
)
);
cif
::
mm
::
structure
s2
(
file
);
}
}
test/test-main.cpp
0 → 100644
View file @
09dd6549
#include "test-main.hpp"
#include <cif++.hpp>
#include <catch2/catch_session.hpp>
std
::
filesystem
::
path
gTestDir
=
std
::
filesystem
::
current_path
();
int
main
(
int
argc
,
char
*
argv
[])
{
Catch
::
Session
session
;
// There must be exactly one instance
// Build a new parser on top of Catch2's
using
namespace
Catch
::
Clara
;
auto
cli
=
session
.
cli
()
// Get Catch2's command line parser
|
Opt
(
gTestDir
,
"data-dir"
)
// bind variable to a new option, with a hint string
[
"-D"
][
"--data-dir"
]
// the option names it will respond to
(
"The directory containing the data files"
);
// description string for the help output
// Now pass the new composite back to Catch2 so it uses that
session
.
cli
(
cli
);
// Let Catch2 (using Clara) parse the command line
int
returnCode
=
session
.
applyCommandLine
(
argc
,
argv
);
if
(
returnCode
!=
0
)
// Indicates a command line error
return
returnCode
;
// do this now, avoids the need for installing
cif
::
add_file_resource
(
"mmcif_pdbx.dic"
,
gTestDir
/
".."
/
"rsrc"
/
"mmcif_pdbx.dic"
);
// initialize CCD location
cif
::
add_file_resource
(
"components.cif"
,
gTestDir
/
".."
/
"data"
/
"ccd-subset.cif"
);
cif
::
compound_factory
::
instance
().
push_dictionary
(
gTestDir
/
"HEM.cif"
);
return
session
.
run
();
}
\ No newline at end of file
test/test-main.hpp
0 → 100644
View file @
09dd6549
#include <filesystem>
extern
std
::
filesystem
::
path
gTestDir
;
test/unit-3d-test.cpp
View file @
09dd6549
...
@@ -24,8 +24,9 @@
...
@@ -24,8 +24,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
#define BOOST_TEST_ALTERNATIVE_INIT_API
#include "test-main.hpp"
#include <boost/test/included/unit_test.hpp>
#include <catch2/catch_test_macros.hpp>
#include <stdexcept>
#include <stdexcept>
...
@@ -33,11 +34,6 @@
...
@@ -33,11 +34,6 @@
#include <Eigen/Eigenvalues>
#include <Eigen/Eigenvalues>
namespace
tt
=
boost
::
test_tools
;
namespace
utf
=
boost
::
unit_test
;
std
::
filesystem
::
path
gTestDir
=
std
::
filesystem
::
current_path
();
// filled in first test
// --------------------------------------------------------------------
// --------------------------------------------------------------------
cif
::
file
operator
""
_cf
(
const
char
*
text
,
size_t
length
)
cif
::
file
operator
""
_cf
(
const
char
*
text
,
size_t
length
)
...
@@ -56,28 +52,9 @@ cif::file operator""_cf(const char *text, size_t length)
...
@@ -56,28 +52,9 @@ cif::file operator""_cf(const char *text, size_t length)
// --------------------------------------------------------------------
// --------------------------------------------------------------------
bool
init_unit_test
()
{
cif
::
VERBOSE
=
1
;
// not a test, just initialize test dir
if
(
boost
::
unit_test
::
framework
::
master_test_suite
().
argc
==
2
)
gTestDir
=
boost
::
unit_test
::
framework
::
master_test_suite
().
argv
[
1
];
// do this now, avoids the need for installing
cif
::
add_file_resource
(
"mmcif_pdbx.dic"
,
gTestDir
/
".."
/
"rsrc"
/
"mmcif_pdbx.dic"
);
// initialize CCD location
cif
::
add_file_resource
(
"components.cif"
,
gTestDir
/
".."
/
"data"
/
"ccd-subset.cif"
);
return
true
;
}
// --------------------------------------------------------------------
// 3d tests
// 3d tests
BOOST_AUTO_TEST_CASE
(
t1
)
TEST_CASE
(
"t1"
)
{
{
// std::random_device rnd;
// std::random_device rnd;
// std::mt19937 gen(rnd());
// std::mt19937 gen(rnd());
...
@@ -115,19 +92,20 @@ BOOST_AUTO_TEST_CASE(t1)
...
@@ -115,19 +92,20 @@ BOOST_AUTO_TEST_CASE(t1)
const
auto
&&
[
angle
,
axis
]
=
cif
::
quaternion_to_angle_axis
(
q2
);
const
auto
&&
[
angle
,
axis
]
=
cif
::
quaternion_to_angle_axis
(
q2
);
BOOST_TEST
(
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)/*, tt::tolerance(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
);
auto
rmsd
=
cif
::
RMSd
(
p1
,
p2
);
auto
rmsd
=
cif
::
RMSd
(
p1
,
p2
);
BOOST_TEST
(
rmsd
<
1e-5
);
REQUIRE
(
rmsd
<
1e-5
);
// std::cout << "rmsd: " << RMSd(p1, p2) << '\n';
// std::cout << "rmsd: " << RMSd(p1, p2) << '\n';
}
}
BOOST_AUTO_TEST_CASE
(
t2
)
TEST_CASE
(
"t2"
)
{
{
cif
::
point
p
[]
=
{
cif
::
point
p
[]
=
{
{
1
,
1
,
0
},
{
1
,
1
,
0
},
...
@@ -141,10 +119,11 @@ BOOST_AUTO_TEST_CASE(t2)
...
@@ -141,10 +119,11 @@ BOOST_AUTO_TEST_CASE(t2)
auto
&&
[
angle
,
axis
]
=
cif
::
quaternion_to_angle_axis
(
q
);
auto
&&
[
angle
,
axis
]
=
cif
::
quaternion_to_angle_axis
(
q
);
BOOST_TEST
(
angle
==
45
,
tt
::
tolerance
(
0.01
));
// REQUIRE(angle == 45/*, tt::tolerance(0.01)*/);
REQUIRE
(
angle
==
45
);
}
}
BOOST_AUTO_TEST_CASE
(
t3
)
TEST_CASE
(
"t3"
)
{
{
cif
::
point
p
[]
=
{
cif
::
point
p
[]
=
{
{
1
,
1
,
0
},
{
1
,
1
,
0
},
...
@@ -165,10 +144,11 @@ BOOST_AUTO_TEST_CASE(t3)
...
@@ -165,10 +144,11 @@ BOOST_AUTO_TEST_CASE(t3)
double
a
=
cif
::
angle
(
v
,
p
[
0
],
p
[
1
]);
double
a
=
cif
::
angle
(
v
,
p
[
0
],
p
[
1
]);
BOOST_TEST
(
a
==
45
,
tt
::
tolerance
(
0.01
));
// REQUIRE(a == 45/*, tt::tolerance(0.01)*/);
REQUIRE
(
a
==
45
);
}
}
BOOST_AUTO_TEST_CASE
(
dh_q_0
)
TEST_CASE
(
"dh_q_0"
)
{
{
cif
::
point
axis
(
1
,
0
,
0
);
cif
::
point
axis
(
1
,
0
,
0
);
...
@@ -182,33 +162,33 @@ BOOST_AUTO_TEST_CASE(dh_q_0)
...
@@ -182,33 +162,33 @@ BOOST_AUTO_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
);
BOOST_TEST
(
a
==
0
,
tt
::
tolerance
(
0.01
f
)
);
REQUIRE
(
a
==
0
/*, tt::tolerance(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
);
BOOST_TEST
(
p
.
m_x
==
1
,
tt
::
tolerance
(
0.01
f
)
);
REQUIRE
(
p
.
m_x
==
1
/*, tt::tolerance(0.01f)*/
);
BOOST_TEST
(
p
.
m_y
==
0
,
tt
::
tolerance
(
0.01
f
)
);
REQUIRE
(
p
.
m_y
==
0
/*, tt::tolerance(0.01f)*/
);
BOOST_TEST
(
p
.
m_z
==
1
,
tt
::
tolerance
(
0.01
f
)
);
REQUIRE
(
p
.
m_z
==
1
/*, tt::tolerance(0.01f)*/
);
a
=
cif
::
dihedral_angle
(
t
[
0
],
t
[
1
],
t
[
2
],
p
);
a
=
cif
::
dihedral_angle
(
t
[
0
],
t
[
1
],
t
[
2
],
p
);
BOOST_TEST
(
a
==
90
,
tt
::
tolerance
(
0.01
f
)
);
REQUIRE
(
a
==
90
/*, tt::tolerance(0.01f)*/
);
q
=
cif
::
construct_from_angle_axis
(
-
90
,
axis
);
q
=
cif
::
construct_from_angle_axis
(
-
90
,
axis
);
p
.
rotate
(
q
);
p
.
rotate
(
q
);
BOOST_TEST
(
p
.
m_x
==
1
,
tt
::
tolerance
(
0.01
f
)
);
REQUIRE
(
p
.
m_x
==
1
/*, tt::tolerance(0.01f)*/
);
BOOST_TEST
(
p
.
m_y
==
1
,
tt
::
tolerance
(
0.01
f
)
);
REQUIRE
(
p
.
m_y
==
1
/*, tt::tolerance(0.01f)*/
);
BOOST_TEST
(
p
.
m_z
==
0
,
tt
::
tolerance
(
0.01
f
)
);
REQUIRE
(
p
.
m_z
==
0
/*, tt::tolerance(0.01f)*/
);
a
=
cif
::
dihedral_angle
(
t
[
0
],
t
[
1
],
t
[
2
],
p
);
a
=
cif
::
dihedral_angle
(
t
[
0
],
t
[
1
],
t
[
2
],
p
);
BOOST_TEST
(
a
==
0
,
tt
::
tolerance
(
0.01
f
)
);
REQUIRE
(
a
==
0
/*, tt::tolerance(0.01f)*/
);
}
}
BOOST_AUTO_TEST_CASE
(
dh_q_1
)
TEST_CASE
(
"dh_q_1"
)
{
{
struct
struct
{
{
...
@@ -247,13 +227,13 @@ BOOST_AUTO_TEST_CASE(dh_q_1)
...
@@ -247,13 +227,13 @@ BOOST_AUTO_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
]);
BOOST_TEST
(
dh
==
angle
,
tt
::
tolerance
(
0.1
f
)
);
REQUIRE
(
dh
==
angle
/*, tt::tolerance(0.1f)*/
);
}
}
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
m2q_0
,
*
utf
::
tolerance
(
0.001
f
)
)
TEST_CASE
(
"m2q_0, *utf::tolerance(0.001f)"
)
{
{
for
(
size_t
i
=
0
;
i
<
cif
::
kSymopNrTableSize
;
++
i
)
for
(
size_t
i
=
0
;
i
<
cif
::
kSymopNrTableSize
;
++
i
)
{
{
...
@@ -310,13 +290,13 @@ BOOST_AUTO_TEST_CASE(m2q_0, *utf::tolerance(0.001f))
...
@@ -310,13 +290,13 @@ BOOST_AUTO_TEST_CASE(m2q_0, *utf::tolerance(0.001f))
cif
::
point
p3
=
rot
*
p1
;
cif
::
point
p3
=
rot
*
p1
;
BOOST_TEST
(
p2
.
m_x
==
p3
.
m_x
);
REQUIRE
(
p2
.
m_x
==
p3
.
m_x
);
BOOST_TEST
(
p2
.
m_y
==
p3
.
m_y
);
REQUIRE
(
p2
.
m_y
==
p3
.
m_y
);
BOOST_TEST
(
p2
.
m_z
==
p3
.
m_z
);
REQUIRE
(
p2
.
m_z
==
p3
.
m_z
);
}
}
}
}
//
BOOST_AUTO_TEST_CASE(m2q_1, *utf::tolerance(0.001f)
)
//
"TEST_CASE(m2q_1, *utf::tolerance(0.001f)"
)
// {
// {
// for (size_t i = 0; i < cif::kSymopNrTableSize; ++i)
// for (size_t i = 0; i < cif::kSymopNrTableSize; ++i)
// {
// {
...
@@ -369,15 +349,15 @@ BOOST_AUTO_TEST_CASE(m2q_0, *utf::tolerance(0.001f))
...
@@ -369,15 +349,15 @@ BOOST_AUTO_TEST_CASE(m2q_0, *utf::tolerance(0.001f))
// cif::point p3 = rot * p1;
// cif::point p3 = rot * p1;
//
BOOST_TEST
(p2.m_x == p3.m_x);
//
REQUIRE
(p2.m_x == p3.m_x);
//
BOOST_TEST
(p2.m_y == p3.m_y);
//
REQUIRE
(p2.m_y == p3.m_y);
//
BOOST_TEST
(p2.m_z == p3.m_z);
//
REQUIRE
(p2.m_z == p3.m_z);
// }
// }
// }
// }
// --------------------------------------------------------------------
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
symm_1
)
TEST_CASE
(
"symm_1"
)
{
{
cif
::
cell
c
(
10
,
10
,
10
);
cif
::
cell
c
(
10
,
10
,
10
);
...
@@ -385,37 +365,37 @@ BOOST_AUTO_TEST_CASE(symm_1)
...
@@ -385,37 +365,37 @@ BOOST_AUTO_TEST_CASE(symm_1)
cif
::
point
f
=
fractional
(
p
,
c
);
cif
::
point
f
=
fractional
(
p
,
c
);
BOOST_TEST
(
f
.
m_x
==
0.1
f
,
tt
::
tolerance
(
0.01
)
);
REQUIRE
(
f
.
m_x
==
0.1
f
/*, tt::tolerance(0.01)*/
);
BOOST_TEST
(
f
.
m_y
==
0.1
f
,
tt
::
tolerance
(
0.01
)
);
REQUIRE
(
f
.
m_y
==
0.1
f
/*, tt::tolerance(0.01)*/
);
BOOST_TEST
(
f
.
m_z
==
0.1
f
,
tt
::
tolerance
(
0.01
)
);
REQUIRE
(
f
.
m_z
==
0.1
f
/*, tt::tolerance(0.01)*/
);
cif
::
point
o
=
orthogonal
(
f
,
c
);
cif
::
point
o
=
orthogonal
(
f
,
c
);
BOOST_TEST
(
o
.
m_x
==
1.
f
,
tt
::
tolerance
(
0.01
)
);
REQUIRE
(
o
.
m_x
==
1.
f
/*, tt::tolerance(0.01)*/
);
BOOST_TEST
(
o
.
m_y
==
1.
f
,
tt
::
tolerance
(
0.01
)
);
REQUIRE
(
o
.
m_y
==
1.
f
/*, tt::tolerance(0.01)*/
);
BOOST_TEST
(
o
.
m_z
==
1.
f
,
tt
::
tolerance
(
0.01
)
);
REQUIRE
(
o
.
m_z
==
1.
f
/*, tt::tolerance(0.01)*/
);
}
}
BOOST_AUTO_TEST_CASE
(
symm_2
)
TEST_CASE
(
"symm_2"
)
{
{
using
namespace
cif
::
literals
;
using
namespace
cif
::
literals
;
auto
symop
=
"1_555"
_symop
;
auto
symop
=
"1_555"
_symop
;
BOOST_TEST
(
symop
.
is_identity
()
==
true
);
REQUIRE
(
symop
.
is_identity
()
==
true
);
}
}
BOOST_AUTO_TEST_CASE
(
symm_3
)
TEST_CASE
(
"symm_3"
)
{
{
using
namespace
cif
::
literals
;
using
namespace
cif
::
literals
;
cif
::
spacegroup
sg
(
18
);
cif
::
spacegroup
sg
(
18
);
BOOST_TEST
(
sg
.
size
()
==
4
);
REQUIRE
(
sg
.
size
()
==
4UL
);
BOOST_TEST
(
sg
.
get_name
()
==
"P 21 21 2"
);
REQUIRE
(
sg
.
get_name
()
==
"P 21 21 2"
);
}
}
BOOST_AUTO_TEST_CASE
(
symm_4
,
*
utf
::
tolerance
(
0.1
f
)
)
TEST_CASE
(
"symm_4, *utf::tolerance(0.1f)"
)
{
{
using
namespace
cif
::
literals
;
using
namespace
cif
::
literals
;
...
@@ -427,21 +407,21 @@ BOOST_AUTO_TEST_CASE(symm_4, *utf::tolerance(0.1f))
...
@@ -427,21 +407,21 @@ BOOST_AUTO_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
BOOST_TEST
(
distance
(
a
,
sg
(
a
,
c
,
"1_455"
_symop
))
==
static_cast
<
float
>
(
c
.
get_a
()));
REQUIRE
(
distance
(
a
,
sg
(
a
,
c
,
"1_455"
_symop
))
==
static_cast
<
float
>
(
c
.
get_a
()));
BOOST_TEST
(
distance
(
a
,
sg
(
a
,
c
,
"1_545"
_symop
))
==
static_cast
<
float
>
(
c
.
get_b
()));
REQUIRE
(
distance
(
a
,
sg
(
a
,
c
,
"1_545"
_symop
))
==
static_cast
<
float
>
(
c
.
get_b
()));
BOOST_TEST
(
distance
(
a
,
sg
(
a
,
c
,
"1_554"
_symop
))
==
static_cast
<
float
>
(
c
.
get_c
()));
REQUIRE
(
distance
(
a
,
sg
(
a
,
c
,
"1_554"
_symop
))
==
static_cast
<
float
>
(
c
.
get_c
()));
auto
sb2
=
sg
(
b
,
c
,
"4_565"
_symop
);
auto
sb2
=
sg
(
b
,
c
,
"4_565"
_symop
);
BOOST_TEST
(
sb
.
m_x
==
sb2
.
m_x
);
REQUIRE
(
sb
.
m_x
==
sb2
.
m_x
);
BOOST_TEST
(
sb
.
m_y
==
sb2
.
m_y
);
REQUIRE
(
sb
.
m_y
==
sb2
.
m_y
);
BOOST_TEST
(
sb
.
m_z
==
sb2
.
m_z
);
REQUIRE
(
sb
.
m_z
==
sb2
.
m_z
);
BOOST_TEST
(
distance
(
a
,
sb2
)
==
7.42
f
);
REQUIRE
(
distance
(
a
,
sb2
)
==
7.42
f
);
}
}
// --------------------------------------------------------------------
// --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE
(
symm_4wvp_1
,
*
utf
::
tolerance
(
0.1
f
)
)
TEST_CASE
(
"symm_4wvp_1, *utf::tolerance(0.1f)"
)
{
{
using
namespace
cif
::
literals
;
using
namespace
cif
::
literals
;
...
@@ -456,21 +436,21 @@ BOOST_AUTO_TEST_CASE(symm_4wvp_1, *utf::tolerance(0.1f))
...
@@ -456,21 +436,21 @@ BOOST_AUTO_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
);
BOOST_TEST
(
sp1
.
m_x
==
p
.
m_x
);
REQUIRE
(
sp1
.
m_x
==
p
.
m_x
);
BOOST_TEST
(
sp1
.
m_y
==
p
.
m_y
);
REQUIRE
(
sp1
.
m_y
==
p
.
m_y
);
BOOST_TEST
(
sp1
.
m_z
==
p
.
m_z
);
REQUIRE
(
sp1
.
m_z
==
p
.
m_z
);
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
());
BOOST_TEST
(
d
<
1
);
REQUIRE
(
d
<
1
);
BOOST_TEST
(
sp2
.
m_x
==
p
.
m_x
);
REQUIRE
(
sp2
.
m_x
==
p
.
m_x
);
BOOST_TEST
(
sp2
.
m_y
==
p
.
m_y
);
REQUIRE
(
sp2
.
m_y
==
p
.
m_y
);
BOOST_TEST
(
sp2
.
m_z
==
p
.
m_z
);
REQUIRE
(
sp2
.
m_z
==
p
.
m_z
);
}
}
BOOST_AUTO_TEST_CASE
(
symm_2bi3_1
,
*
utf
::
tolerance
(
0.1
f
)
)
TEST_CASE
(
"symm_2bi3_1, *utf::tolerance(0.1f)"
)
{
{
cif
::
file
f
(
gTestDir
/
"2bi3.cif.gz"
);
cif
::
file
f
(
gTestDir
/
"2bi3.cif.gz"
);
...
@@ -502,22 +482,22 @@ BOOST_AUTO_TEST_CASE(symm_2bi3_1, *utf::tolerance(0.1f))
...
@@ -502,22 +482,22 @@ BOOST_AUTO_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
));
BOOST_TEST
(
cif
::
distance
(
sa1
,
sa2
)
==
dist
);
REQUIRE
(
cif
::
distance
(
sa1
,
sa2
)
==
dist
);
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
());
BOOST_TEST
(
p
.
m_x
==
sa2
.
m_x
);
REQUIRE
(
p
.
m_x
==
sa2
.
m_x
);
BOOST_TEST
(
p
.
m_y
==
sa2
.
m_y
);
REQUIRE
(
p
.
m_y
==
sa2
.
m_y
);
BOOST_TEST
(
p
.
m_z
==
sa2
.
m_z
);
REQUIRE
(
p
.
m_z
==
sa2
.
m_z
);
BOOST_TEST
(
d
==
dist
);
REQUIRE
(
d
==
dist
);
BOOST_TEST
(
so
.
string
()
==
symm2
);
REQUIRE
(
so
.
string
()
==
symm2
);
}
}
}
}
BOOST_AUTO_TEST_CASE
(
symm_2bi3_1a
,
*
utf
::
tolerance
(
0.1
f
)
)
TEST_CASE
(
"symm_2bi3_1a, *utf::tolerance(0.1f)"
)
{
{
using
namespace
cif
::
literals
;
using
namespace
cif
::
literals
;
...
@@ -552,20 +532,20 @@ BOOST_AUTO_TEST_CASE(symm_2bi3_1a, *utf::tolerance(0.1f))
...
@@ -552,20 +532,20 @@ BOOST_AUTO_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
));
BOOST_TEST
(
cif
::
distance
(
sa1
,
sa2
)
==
dist
);
REQUIRE
(
cif
::
distance
(
sa1
,
sa2
)
==
dist
);
const
auto
&
[
d
,
p
,
so
]
=
c
.
closest_symmetry_copy
(
p1
,
p2
);
const
auto
&
[
d
,
p
,
so
]
=
c
.
closest_symmetry_copy
(
p1
,
p2
);
BOOST_TEST
(
p
.
m_x
==
sa2
.
m_x
);
REQUIRE
(
p
.
m_x
==
sa2
.
m_x
);
BOOST_TEST
(
p
.
m_y
==
sa2
.
m_y
);
REQUIRE
(
p
.
m_y
==
sa2
.
m_y
);
BOOST_TEST
(
p
.
m_z
==
sa2
.
m_z
);
REQUIRE
(
p
.
m_z
==
sa2
.
m_z
);
BOOST_TEST
(
d
==
dist
);
REQUIRE
(
d
==
dist
);
BOOST_TEST
(
so
.
string
()
==
symm2
);
REQUIRE
(
so
.
string
()
==
symm2
);
}
}
}
}
BOOST_AUTO_TEST_CASE
(
symm_3bwh_1
,
*
utf
::
tolerance
(
0.1
f
)
)
TEST_CASE
(
"symm_3bwh_1, *utf::tolerance(0.1f)"
)
{
{
cif
::
file
f
(
gTestDir
/
"3bwh.cif.gz"
);
cif
::
file
f
(
gTestDir
/
"3bwh.cif.gz"
);
...
@@ -583,12 +563,12 @@ BOOST_AUTO_TEST_CASE(symm_3bwh_1, *utf::tolerance(0.1f))
...
@@ -583,12 +563,12 @@ BOOST_AUTO_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
());
BOOST_TEST
(
d
==
distance
(
a1
.
get_location
(),
p
));
REQUIRE
(
d
==
distance
(
a1
.
get_location
(),
p
));
}
}
}
}
}
}
BOOST_AUTO_TEST_CASE
(
volume_3bwh_1
,
*
utf
::
tolerance
(
0.1
f
)
)
TEST_CASE
(
"volume_3bwh_1, *utf::tolerance(0.1f)"
)
{
{
cif
::
file
f
(
gTestDir
/
"1juh.cif.gz"
);
cif
::
file
f
(
gTestDir
/
"1juh.cif.gz"
);
...
@@ -596,6 +576,6 @@ BOOST_AUTO_TEST_CASE(volume_3bwh_1, *utf::tolerance(0.1f))
...
@@ -596,6 +576,6 @@ BOOST_AUTO_TEST_CASE(volume_3bwh_1, *utf::tolerance(0.1f))
cif
::
crystal
c
(
db
);
cif
::
crystal
c
(
db
);
BOOST_CHECK_EQUAL
(
c
.
get_cell
().
get_volume
(),
741009.625
f
);
REQUIRE
(
c
.
get_cell
().
get_volume
()
==
741009.625
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