Commit 09dd6549 by Maarten L. Hekkelman

Change testing framework to Catch2

parent 640552ab
...@@ -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()
......
...@@ -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;
......
...@@ -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,15 +34,15 @@ ...@@ -33,15 +34,15 @@
// -------------------------------------------------------------------- // --------------------------------------------------------------------
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) membuf(char *text, size_t length)
{ {
this->setg(text, text, text + length); this->setg(text, text, text + length);
} }
} buffer(const_cast<char*>(text), length); } buffer(const_cast<char *>(text), length);
std::istream is(&buffer); std::istream is(&buffer);
return cif::file(is); return cif::file(is);
...@@ -49,36 +50,7 @@ cif::file operator""_cf(const char* text, size_t length) ...@@ -49,36 +50,7 @@ cif::file operator""_cf(const char* text, size_t length)
// -------------------------------------------------------------------- // --------------------------------------------------------------------
std::filesystem::path gTestDir = std::filesystem::current_path(); TEST_CASE("create_nonpoly_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];
else
{
while (not gTestDir.empty() and not std::filesystem::exists(gTestDir / "test"))
gTestDir = gTestDir.parent_path();
gTestDir /= "test";
}
// 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(create_nonpoly_1)
{ {
cif::VERBOSE = 1; cif::VERBOSE = 1;
...@@ -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,9 +163,9 @@ _atom_type.symbol C ...@@ -191,9 +163,9 @@ _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';
...@@ -202,7 +174,7 @@ _atom_type.symbol C ...@@ -202,7 +174,7 @@ _atom_type.symbol C
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(create_nonpoly_2) TEST_CASE("create_nonpoly_2")
{ {
cif::VERBOSE = 1; cif::VERBOSE = 1;
...@@ -218,7 +190,7 @@ BOOST_AUTO_TEST_CASE(create_nonpoly_2) ...@@ -218,7 +190,7 @@ 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{
...@@ -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_NOTHROW(s.validate_atoms());
} }
...@@ -24,38 +24,29 @@ ...@@ -24,38 +24,29 @@
* 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")) if (std::filesystem::exists(gTestDir / ".." / "rsrc" / "mmcif_pdbx.dic"))
cif::add_file_resource("components.cif", testdir / ".." / "data" / "ccd-subset.cif"); cif::add_file_resource("mmcif_pdbx.dic", gTestDir / ".." / "rsrc" / "mmcif_pdbx.dic");
if (std::filesystem::exists(testdir / ".." / "rsrc" / "mmcif_pdbx.dic")) cif::compound_factory::instance().push_dictionary(gTestDir / "REA.cif");
cif::add_file_resource("mmcif_pdbx.dic", testdir / ".." / "rsrc" / "mmcif_pdbx.dic"); cif::compound_factory::instance().push_dictionary(gTestDir / "RXA.cif");
cif::compound_factory::instance().push_dictionary(testdir / "REA.cif"); cif::file f(gTestDir / ".."/"examples"/"1cbs.cif.gz");
cif::compound_factory::instance().push_dictionary(testdir / "RXA.cif");
cif::file f(testdir / ".."/"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");
...@@ -69,12 +60,4 @@ int main(int argc, char* argv[]) ...@@ -69,12 +60,4 @@ int main(int argc, char* argv[])
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;
} }
#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(100ms); std::this_thread::sleep_for(100ms);
} }
int main()
{
test_one();
test_two();
test_three();
return 0;
}
\ No newline at end of file
...@@ -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);
} }
#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
#include <filesystem>
extern std::filesystem::path gTestDir;
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