Commit a7f45317 by Maarten L. Hekkelman

switched last test to Catch2

parent 08f5a1ad
...@@ -356,8 +356,8 @@ if(CIFPP_DOWNLOAD_CCD) ...@@ -356,8 +356,8 @@ if(CIFPP_DOWNLOAD_CCD)
endif() endif()
# Installation directories # Installation directories
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.22) if(BUILD_FOR_CCP4)
cmake_dependent_option(CIFPP_DATA_DIR "Directory where dictionary and other static data is stored" CACHE PATH "${CMAKE_INSTALL_FULL_DATADIR}/libcifpp" "BUILD_FOR_CCP4" "$ENV{CCP4}/share/libcifpp") option(CIFPP_DATA_DIR "Directory where dictionary and other static data is stored" "$ENV{CCP4}/share/libcifpp")
else() else()
option(CIFPP_DATA_DIR "Directory where dictionary and other static data is stored" "${CMAKE_INSTALL_FULL_DATADIR}/libcifpp") option(CIFPP_DATA_DIR "Directory where dictionary and other static data is stored" "${CMAKE_INSTALL_FULL_DATADIR}/libcifpp")
endif() endif()
...@@ -489,7 +489,7 @@ if(BUILD_TESTING) ...@@ -489,7 +489,7 @@ if(BUILD_TESTING)
endif() endif()
list(APPEND CIFPP_tests list(APPEND CIFPP_tests
# unit-v2 unit-v2
unit-3d unit-3d
format format
model model
...@@ -543,7 +543,7 @@ if(CIFPP_INSTALL_UPDATE_SCRIPT) ...@@ -543,7 +543,7 @@ if(CIFPP_INSTALL_UPDATE_SCRIPT)
install(DIRECTORY DESTINATION ${CIFPP_CACHE_DIR}) install(DIRECTORY DESTINATION ${CIFPP_CACHE_DIR})
install(DIRECTORY DESTINATION "${CIFPP_ETC_DIR}/libcifpp/cache-update.d") install(DIRECTORY DESTINATION "${CIFPP_ETC_DIR}/libcifpp/cache-update.d")
# a config to, to make it complete # a config file, to make it complete
if(NOT EXISTS "${CIFPP_ETC_DIR}/libcifpp.conf") if(NOT EXISTS "${CIFPP_ETC_DIR}/libcifpp.conf")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libcifpp.conf [[# Uncomment the next line to enable automatic updates file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libcifpp.conf [[# Uncomment the next line to enable automatic updates
# update=true # update=true
......
...@@ -56,6 +56,7 @@ endif() ...@@ -56,6 +56,7 @@ endif()
cmake_pop_check_state() cmake_pop_check_state()
set(Atomic_FOUND ${_found} CACHE BOOL "TRUE if we can run a program using std::atomic" FORCE) set(Atomic_FOUND ${_found} CACHE BOOL "TRUE if we can run a program using std::atomic" FORCE)
mark_as_advanced(Atomic_FOUND)
if(Atomic_FIND_REQUIRED AND NOT Atomic_FOUND) if(Atomic_FIND_REQUIRED AND NOT Atomic_FOUND)
message(FATAL_ERROR "Cannot run simple program using std::atomic") message(FATAL_ERROR "Cannot run simple program using std::atomic")
......
...@@ -67,6 +67,7 @@ endif() ...@@ -67,6 +67,7 @@ endif()
cmake_pop_check_state() cmake_pop_check_state()
set(Filesystem_FOUND ${_found} CACHE BOOL "TRUE if we can run a program using std::filesystem" FORCE) set(Filesystem_FOUND ${_found} CACHE BOOL "TRUE if we can run a program using std::filesystem" FORCE)
mark_as_advanced(Filesystem_FOUND)
if(Filesystem_FIND_REQUIRED AND NOT Filesystem_FOUND) if(Filesystem_FIND_REQUIRED AND NOT Filesystem_FOUND)
message(FATAL_ERROR "Cannot run simple program using std::filesystem") message(FATAL_ERROR "Cannot run simple program using std::filesystem")
......
...@@ -24,19 +24,15 @@ ...@@ -24,19 +24,15 @@
* 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 <stdexcept> #include <catch2/catch_test_macros.hpp>
#include <cif++.hpp> #include <cif++.hpp>
#include "cif++/dictionary_parser.hpp" #include "cif++/dictionary_parser.hpp"
#include <stdexcept>
namespace tt = boost::test_tools;
std::filesystem::path gTestDir = std::filesystem::current_path(); // filled in first test
// -------------------------------------------------------------------- // --------------------------------------------------------------------
...@@ -56,50 +52,31 @@ cif::file operator""_cf(const char *text, size_t length) ...@@ -56,50 +52,31 @@ cif::file operator""_cf(const char *text, size_t length)
// -------------------------------------------------------------------- // --------------------------------------------------------------------
bool init_unit_test() TEST_CASE("id_1")
{
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(id_1)
{ {
BOOST_TEST(cif::cif_id_for_number(0) == "A"); REQUIRE(cif::cif_id_for_number(0) == "A");
BOOST_TEST(cif::cif_id_for_number(25) == "Z"); REQUIRE(cif::cif_id_for_number(25) == "Z");
BOOST_TEST(cif::cif_id_for_number(26) == "AA"); REQUIRE(cif::cif_id_for_number(26) == "AA");
BOOST_TEST(cif::cif_id_for_number(26 + 1) == "AB"); REQUIRE(cif::cif_id_for_number(26 + 1) == "AB");
BOOST_TEST(cif::cif_id_for_number(26 + 26 * 26 - 1) == "ZZ"); REQUIRE(cif::cif_id_for_number(26 + 26 * 26 - 1) == "ZZ");
BOOST_TEST(cif::cif_id_for_number(26 + 26 * 26) == "AAA"); REQUIRE(cif::cif_id_for_number(26 + 26 * 26) == "AAA");
BOOST_TEST(cif::cif_id_for_number(26 + 26 * 26 + 1) == "AAB"); REQUIRE(cif::cif_id_for_number(26 + 26 * 26 + 1) == "AAB");
std::set<std::string> testset; std::set<std::string> testset;
for (int i = 0; i < 100000; ++i) for (int i = 0; i < 100000; ++i)
{ {
std::string id = cif::cif_id_for_number(i); std::string id = cif::cif_id_for_number(i);
BOOST_TEST(testset.count(id) == 0); REQUIRE(testset.count(id) == 0);
testset.insert(id); testset.insert(id);
} }
BOOST_TEST(testset.size() == 100000); REQUIRE(testset.size() == 100000);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(cc_1) TEST_CASE("cc_1")
{ {
std::tuple<std::string_view, float, char> tests[] = { std::tuple<std::string_view, float, char> tests[] = {
{ "1.0", 1.0f, 0 }, { "1.0", 1.0f, 0 },
...@@ -126,14 +103,14 @@ BOOST_AUTO_TEST_CASE(cc_1) ...@@ -126,14 +103,14 @@ BOOST_AUTO_TEST_CASE(cc_1)
float tv; float tv;
const auto &[ptr, ec] = cif::from_chars(txt.data(), txt.data() + txt.length(), tv); const auto &[ptr, ec] = cif::from_chars(txt.data(), txt.data() + txt.length(), tv);
BOOST_CHECK(ec == std::errc()); REQUIRE(ec == std::errc());
BOOST_CHECK_EQUAL(tv, val); REQUIRE(tv == val);
if (ch != 0) if (ch != 0)
BOOST_CHECK_EQUAL(*ptr, ch); REQUIRE(*ptr == ch);
} }
} }
BOOST_AUTO_TEST_CASE(cc_2) TEST_CASE("cc_2")
{ {
std::tuple<float, int, std::string_view> tests[] = { std::tuple<float, int, std::string_view> tests[] = {
{ 1.1f, 1, "1.1" } { 1.1f, 1, "1.1" }
...@@ -144,13 +121,13 @@ BOOST_AUTO_TEST_CASE(cc_2) ...@@ -144,13 +121,13 @@ BOOST_AUTO_TEST_CASE(cc_2)
char buffer[64]; char buffer[64];
const auto &[ptr, ec] = cif::to_chars(buffer, buffer + sizeof(buffer), val, cif::chars_format::fixed, prec); const auto &[ptr, ec] = cif::to_chars(buffer, buffer + sizeof(buffer), val, cif::chars_format::fixed, prec);
BOOST_CHECK(ec == std::errc()); REQUIRE(ec == std::errc());
BOOST_CHECK_EQUAL(buffer, test); REQUIRE(buffer == test);
} }
} }
BOOST_AUTO_TEST_CASE(cc_3) TEST_CASE("cc_3")
{ {
cif::category c("foo"); cif::category c("foo");
c.emplace({ c.emplace({
...@@ -163,19 +140,19 @@ BOOST_AUTO_TEST_CASE(cc_3) ...@@ -163,19 +140,19 @@ BOOST_AUTO_TEST_CASE(cc_3)
}); });
auto row = c.front(); auto row = c.front();
BOOST_CHECK_EQUAL(row["f-1"].as<int>(), 1); REQUIRE(row["f-1"].as<int>() == 1);
BOOST_CHECK_EQUAL(row["f-2"].as<int>(), -1); REQUIRE(row["f-2"].as<int>() == -1);
BOOST_CHECK_EQUAL(row["f-3"].as<int>(), 1); REQUIRE(row["f-3"].as<int>() == 1);
// BOOST_CHECK_THROW(row["f-4"].as<int>(), std::exception); // REQUIRE_THROWS_AS(row["f-4"].as<int>(), std::exception);
// BOOST_CHECK_THROW(row["f-5"].as<int>(), std::exception); // REQUIRE_THROWS_AS(row["f-5"].as<int>(), std::exception);
// BOOST_CHECK_THROW(row["f-6"].as<int>(), std::exception); // REQUIRE_THROWS_AS(row["f-6"].as<int>(), std::exception);
BOOST_CHECK_EQUAL(row["f-4"].as<int>(), 0); REQUIRE(row["f-4"].as<int>() == 0);
BOOST_CHECK_EQUAL(row["f-5"].as<int>(), 0); REQUIRE(row["f-5"].as<int>() == 0);
BOOST_CHECK_EQUAL(row["f-6"].as<int>(), 0); REQUIRE(row["f-6"].as<int>() == 0);
} }
BOOST_AUTO_TEST_CASE(item_1) TEST_CASE("item_1")
{ {
using namespace cif; using namespace cif;
...@@ -187,46 +164,46 @@ BOOST_AUTO_TEST_CASE(item_1) ...@@ -187,46 +164,46 @@ BOOST_AUTO_TEST_CASE(item_1)
item ci2(i2); item ci2(i2);
item ci3(i3); item ci3(i3);
BOOST_CHECK_EQUAL(i1.value(), ci1.value()); REQUIRE(i1.value() == ci1.value());
BOOST_CHECK_EQUAL(i2.value(), ci2.value()); REQUIRE(i2.value() == ci2.value());
BOOST_CHECK_EQUAL(i3.value(), ci3.value()); REQUIRE(i3.value() == ci3.value());
item mi1(std::move(ci1)); item mi1(std::move(ci1));
item mi2(std::move(ci2)); item mi2(std::move(ci2));
item mi3(std::move(ci3)); item mi3(std::move(ci3));
BOOST_CHECK_EQUAL(i1.value(), mi1.value()); REQUIRE(i1.value() == mi1.value());
BOOST_CHECK_EQUAL(i2.value(), mi2.value()); REQUIRE(i2.value() == mi2.value());
BOOST_CHECK_EQUAL(i3.value(), mi3.value()); REQUIRE(i3.value() == mi3.value());
BOOST_CHECK(ci1.empty()); REQUIRE(ci1.empty());
BOOST_CHECK(ci2.empty()); REQUIRE(ci2.empty());
BOOST_CHECK(ci3.empty()); REQUIRE(ci3.empty());
} }
BOOST_AUTO_TEST_CASE(item_2) TEST_CASE("item_2")
{ {
using namespace cif; using namespace cif;
cif::item i0("test1"); cif::item i0("test1");
BOOST_CHECK(i0.value() == "."); REQUIRE(i0.value() == ".");
cif::item i1("test1", std:: optional<float>()); cif::item i1("test1", std:: optional<float>());
BOOST_CHECK(i1.value() == "?"); REQUIRE(i1.value() == "?");
cif::item i2("test1", std::make_optional<float>(1)); cif::item i2("test1", std::make_optional<float>(1));
BOOST_CHECK(i2.value() == "1"); REQUIRE(i2.value() == "1");
cif::item i3("test1", std::optional<float>(), 2); cif::item i3("test1", std::optional<float>(), 2);
BOOST_CHECK(i3.value() == "?"); REQUIRE(i3.value() == "?");
cif::item i4("test1", std::make_optional<float>(1), 2); cif::item i4("test1", std::make_optional<float>(1), 2);
BOOST_CHECK(i4.value() == "1.00"); REQUIRE(i4.value() == "1.00");
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(r_1) TEST_CASE("r_1")
{ {
cif::category c("foo"); cif::category c("foo");
c.emplace({ c.emplace({
...@@ -236,19 +213,19 @@ BOOST_AUTO_TEST_CASE(r_1) ...@@ -236,19 +213,19 @@ BOOST_AUTO_TEST_CASE(r_1)
}); });
auto row = c.front(); auto row = c.front();
BOOST_CHECK_EQUAL(row["f-1"].compare(1), 0); REQUIRE(row["f-1"].compare(1) == 0);
BOOST_CHECK_EQUAL(row["f-2"].compare("two"), 0); REQUIRE(row["f-2"].compare("two") == 0);
BOOST_CHECK_EQUAL(row["f-3"].compare(3.0f), 0); // This fails when running in valgrind... sigh REQUIRE(row["f-3"].compare(3.0f) == 0); // This fails when running in valgrind... sigh
const auto &[f1, f2, f3] = row.get<int, std::string, float>("f-1", "f-2", "f-3"); const auto &[f1, f2, f3] = row.get<int, std::string, float>("f-1", "f-2", "f-3");
BOOST_CHECK_EQUAL(f1, 1); REQUIRE(f1 == 1);
BOOST_CHECK_EQUAL(f2, "two"); REQUIRE(f2 == "two");
BOOST_CHECK_EQUAL(f3, 3.0f); // This fails when running in valgrind... sigh REQUIRE(f3 == 3.0f); // This fails when running in valgrind... sigh
BOOST_CHECK_EQUAL(row.get<int>("f-1"), 1); REQUIRE(row.get<int>("f-1") == 1);
BOOST_CHECK_EQUAL(row.get<std::string>("f-2"), "two"); REQUIRE(row.get<std::string>("f-2") == "two");
BOOST_CHECK_EQUAL(row.get<float>("f-3"), 3.0f); REQUIRE(row.get<float>("f-3") == 3.0f);
int f_1; int f_1;
std::string f_2; std::string f_2;
...@@ -256,12 +233,12 @@ BOOST_AUTO_TEST_CASE(r_1) ...@@ -256,12 +233,12 @@ BOOST_AUTO_TEST_CASE(r_1)
cif::tie(f_1, f_2, f_3) = row.get("f-1", "f-2", "f-3"); cif::tie(f_1, f_2, f_3) = row.get("f-1", "f-2", "f-3");
BOOST_CHECK_EQUAL(f_1, 1); REQUIRE(f_1 == 1);
BOOST_CHECK_EQUAL(f_2, "two"); REQUIRE(f_2 == "two");
BOOST_CHECK_EQUAL(f_3, 3.0f); // This fails when running in valgrind... sigh REQUIRE(f_3 == 3.0f); // This fails when running in valgrind... sigh
} }
BOOST_AUTO_TEST_CASE(r_2) TEST_CASE("r_2")
{ {
cif::category c("foo"); cif::category c("foo");
...@@ -272,7 +249,7 @@ BOOST_AUTO_TEST_CASE(r_2) ...@@ -272,7 +249,7 @@ BOOST_AUTO_TEST_CASE(r_2)
} }
} }
BOOST_AUTO_TEST_CASE(c_1) TEST_CASE("c_1")
{ {
cif::category c("foo"); cif::category c("foo");
...@@ -286,8 +263,8 @@ BOOST_AUTO_TEST_CASE(c_1) ...@@ -286,8 +263,8 @@ BOOST_AUTO_TEST_CASE(c_1)
for (auto r : c) for (auto r : c)
{ {
BOOST_CHECK_EQUAL(r["id"].as<int>(), n); REQUIRE(r["id"].as<int>() == n);
BOOST_CHECK_EQUAL(r["s"].compare(ts[n - 1]), 0); REQUIRE(r["s"].compare(ts[n - 1]) == 0);
++n; ++n;
} }
...@@ -300,8 +277,8 @@ BOOST_AUTO_TEST_CASE(c_1) ...@@ -300,8 +277,8 @@ BOOST_AUTO_TEST_CASE(c_1)
cif::tie(i, s) = r.get("id", "s"); cif::tie(i, s) = r.get("id", "s");
BOOST_CHECK_EQUAL(i, n); REQUIRE(i == n);
BOOST_CHECK_EQUAL(s.compare(ts[n - 1]), 0); REQUIRE(s.compare(ts[n - 1]) == 0);
++n; ++n;
} }
...@@ -309,13 +286,13 @@ BOOST_AUTO_TEST_CASE(c_1) ...@@ -309,13 +286,13 @@ BOOST_AUTO_TEST_CASE(c_1)
for (const auto &[i, s] : c.rows<int, std::string>("id", "s")) for (const auto &[i, s] : c.rows<int, std::string>("id", "s"))
{ {
BOOST_CHECK_EQUAL(i, n); REQUIRE(i == n);
BOOST_CHECK_EQUAL(s.compare(ts[n - 1]), 0); REQUIRE(s.compare(ts[n - 1]) == 0);
++n; ++n;
} }
} }
BOOST_AUTO_TEST_CASE(c_2) TEST_CASE("c_2")
{ {
std::tuple<int, const char *> D[] = { std::tuple<int, const char *> D[] = {
{ 1, "aap" }, { 1, "aap" },
...@@ -328,34 +305,34 @@ BOOST_AUTO_TEST_CASE(c_2) ...@@ -328,34 +305,34 @@ BOOST_AUTO_TEST_CASE(c_2)
for (const auto &[id, s] : D) for (const auto &[id, s] : D)
c.emplace({ { "id", id }, { "s", s } }); c.emplace({ { "id", id }, { "s", s } });
BOOST_CHECK(not c.empty()); REQUIRE(not c.empty());
BOOST_CHECK_EQUAL(c.size(), 3); REQUIRE(c.size() == 3);
cif::category c2(c); cif::category c2(c);
BOOST_CHECK(not c2.empty()); REQUIRE(not c2.empty());
BOOST_CHECK_EQUAL(c2.size(), 3); REQUIRE(c2.size() == 3);
cif::category c3(std::move(c)); cif::category c3(std::move(c));
BOOST_CHECK(not c3.empty()); REQUIRE(not c3.empty());
BOOST_CHECK_EQUAL(c3.size(), 3); REQUIRE(c3.size() == 3);
BOOST_CHECK(c.empty()); REQUIRE(c.empty());
BOOST_CHECK_EQUAL(c.size(), 0); REQUIRE(c.size() == 0);
c = c3; c = c3;
BOOST_CHECK(not c.empty()); REQUIRE(not c.empty());
BOOST_CHECK_EQUAL(c.size(), 3); REQUIRE(c.size() == 3);
c = std::move(c2); c = std::move(c2);
BOOST_CHECK(not c.empty()); REQUIRE(not c.empty());
BOOST_CHECK_EQUAL(c.size(), 3); REQUIRE(c.size() == 3);
} }
BOOST_AUTO_TEST_CASE(c_3) TEST_CASE("c_3")
{ {
std::tuple<int, const char *> D[] = { std::tuple<int, const char *> D[] = {
{ 1, "aap" }, { 1, "aap" },
...@@ -373,10 +350,10 @@ BOOST_AUTO_TEST_CASE(c_3) ...@@ -373,10 +350,10 @@ BOOST_AUTO_TEST_CASE(c_3)
for (auto r : c) for (auto r : c)
c2.emplace(r); c2.emplace(r);
// BOOST_CHECK(c == c2); // REQUIRE(c == c2);
} }
BOOST_AUTO_TEST_CASE(ci_1) TEST_CASE("ci_1")
{ {
cif::category c("foo"); cif::category c("foo");
...@@ -391,13 +368,13 @@ BOOST_AUTO_TEST_CASE(ci_1) ...@@ -391,13 +368,13 @@ BOOST_AUTO_TEST_CASE(ci_1)
cif::category::const_iterator i4 = i2; cif::category::const_iterator i4 = i2;
cif::category::const_iterator i5 = i1; cif::category::const_iterator i5 = i1;
BOOST_CHECK(i1 == i2); REQUIRE(i1 == i2);
BOOST_CHECK(i1 == i3); REQUIRE(i1 == i3);
BOOST_CHECK(i1 == i4); REQUIRE(i1 == i4);
BOOST_CHECK(i1 == i5); REQUIRE(i1 == i5);
} }
BOOST_AUTO_TEST_CASE(os_1) TEST_CASE("os_1")
{ {
using namespace cif::literals; using namespace cif::literals;
using namespace std::literals; using namespace std::literals;
...@@ -422,15 +399,15 @@ BOOST_AUTO_TEST_CASE(os_1) ...@@ -422,15 +399,15 @@ BOOST_AUTO_TEST_CASE(os_1)
{ {
auto rh = c.find1("id"_key == id); auto rh = c.find1("id"_key == id);
BOOST_CHECK_EQUAL(rh.get<int>("id"), id); REQUIRE(rh.get<int>("id") == id);
BOOST_CHECK_EQUAL(rh.get<std::string>("s"), s); REQUIRE(rh.get<std::string>("s") == s);
BOOST_CHECK_EQUAL(rh.get<std::string>("o"), "1,2: "s + s); REQUIRE(rh.get<std::string>("o") == "1,2: "s + s);
} }
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(get_1) TEST_CASE("get_1")
{ {
auto f = R"(data_TEST auto f = R"(data_TEST
# #
...@@ -453,17 +430,17 @@ _test.name ...@@ -453,17 +430,17 @@ _test.name
switch (id) switch (id)
{ {
case 1: BOOST_CHECK_EQUAL(*name, "aap"); break; case 1: REQUIRE(*name == "aap"); break;
case 2: BOOST_CHECK_EQUAL(*name, "noot"); break; case 2: REQUIRE(*name == "noot"); break;
case 3: BOOST_CHECK_EQUAL(*name, "mies"); break; case 3: REQUIRE(*name == "mies"); break;
default: BOOST_CHECK(name.has_value() == false); default: REQUIRE(name.has_value() == false);
} }
} }
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(f_1) TEST_CASE("f_1")
{ {
// using namespace mmcif; // using namespace mmcif;
...@@ -477,38 +454,38 @@ _test.name ...@@ -477,38 +454,38 @@ _test.name
3 mies 3 mies
)"_cf; )"_cf;
BOOST_ASSERT(not f.empty()); REQUIRE(f.empty() == false);
BOOST_ASSERT(f.size() == 1); REQUIRE(f.size() == 1);
auto &db = f.front(); auto &db = f.front();
BOOST_CHECK_EQUAL(db.name(), "TEST"); REQUIRE(db.name() == "TEST");
auto &test = db["test"]; auto &test = db["test"];
BOOST_CHECK_EQUAL(test.size(), 3); REQUIRE(test.size() == 3);
const char *ts[] = { "aap", "noot", "mies" }; const char *ts[] = { "aap", "noot", "mies" };
int n = 1; int n = 1;
for (const auto &[i, s] : test.rows<int, std::string>("id", "name")) for (const auto &[i, s] : test.rows<int, std::string>("id", "name"))
{ {
BOOST_CHECK_EQUAL(i, n); REQUIRE(i == n);
BOOST_CHECK_EQUAL(s.compare(ts[n - 1]), 0); REQUIRE(s.compare(ts[n - 1]) == 0);
++n; ++n;
} }
auto n2 = test.erase(cif::key("id") == 1, [](cif::row_handle r) auto n2 = test.erase(cif::key("id") == 1, [](cif::row_handle r)
{ {
BOOST_CHECK_EQUAL(r["id"].as<int>(), 1); REQUIRE(r["id"].as<int>() == 1);
BOOST_CHECK_EQUAL(r["name"].as<std::string>(), "aap"); }); REQUIRE(r["name"].as<std::string>() == "aap"); });
BOOST_CHECK_EQUAL(n2, 1); REQUIRE(n2 == 1);
// for (auto r: test) // for (auto r: test)
// test.erase(r); // test.erase(r);
test.clear(); test.clear();
BOOST_CHECK(test.empty()); REQUIRE(test.empty());
// fill again. // fill again.
...@@ -519,15 +496,15 @@ _test.name ...@@ -519,15 +496,15 @@ _test.name
n = 1; n = 1;
for (const auto &[i, s] : test.rows<int, std::string>("id", "name")) for (const auto &[i, s] : test.rows<int, std::string>("id", "name"))
{ {
BOOST_CHECK_EQUAL(i, n); REQUIRE(i == n);
BOOST_CHECK_EQUAL(s.compare(ts[n - 1]), 0); REQUIRE(s.compare(ts[n - 1]) == 0);
++n; ++n;
} }
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(ut2) TEST_CASE("ut2")
{ {
// using namespace mmcif; // using namespace mmcif;
...@@ -544,30 +521,30 @@ _test.value ...@@ -544,30 +521,30 @@ _test.value
auto &db = f.front(); auto &db = f.front();
BOOST_CHECK_EQUAL(db.name(), "TEST"); REQUIRE(db.name() == "TEST");
auto &test = db["test"]; auto &test = db["test"];
BOOST_CHECK_EQUAL(test.size(), 3); REQUIRE(test.size() == 3);
int n = 0; int n = 0;
for (auto r : test.find(cif::key("name") == "aap")) for (auto r : test.find(cif::key("name") == "aap"))
{ {
BOOST_CHECK_EQUAL(++n, 1); REQUIRE(++n == 1);
BOOST_CHECK_EQUAL(r["id"].as<int>(), 1); REQUIRE(r["id"].as<int>() == 1);
BOOST_CHECK_EQUAL(r["name"].as<std::string>(), "aap"); REQUIRE(r["name"].as<std::string>() == "aap");
BOOST_CHECK_EQUAL(r["value"].as<float>(), 1.0f); REQUIRE(r["value"].as<float>() == 1.0f);
} }
auto t = test.find(cif::key("id") == 1); auto t = test.find(cif::key("id") == 1);
BOOST_CHECK(not t.empty()); REQUIRE(not t.empty());
BOOST_CHECK_EQUAL(t.front()["name"].as<std::string>(), "aap"); REQUIRE(t.front()["name"].as<std::string>() == "aap");
auto t2 = test.find(cif::key("value") == 1.2f); auto t2 = test.find(cif::key("value") == 1.2f);
BOOST_CHECK(not t2.empty()); REQUIRE(not t2.empty());
BOOST_CHECK_EQUAL(t2.front()["name"].as<std::string>(), "mies"); REQUIRE(t2.front()["name"].as<std::string>() == "mies");
} }
BOOST_AUTO_TEST_CASE(ut3) TEST_CASE("ut3")
{ {
using namespace cif::literals; using namespace cif::literals;
...@@ -586,18 +563,18 @@ _test.value ...@@ -586,18 +563,18 @@ _test.value
auto &db = f.front(); auto &db = f.front();
BOOST_CHECK_EQUAL(db.name(), "TEST"); REQUIRE(db.name() == "TEST");
auto &test = db["test"]; auto &test = db["test"];
BOOST_CHECK_EQUAL(test.size(), 5); REQUIRE(test.size() == 5);
BOOST_CHECK(test.exists("value"_key == cif::null)); REQUIRE(test.exists("value"_key == cif::null));
BOOST_CHECK_EQUAL(test.find("value"_key == cif::null).size(), 2); REQUIRE(test.find("value"_key == cif::null).size() == 2);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(sw_1) TEST_CASE("sw_1")
{ {
using namespace cif::literals; using namespace cif::literals;
...@@ -617,18 +594,18 @@ _test.value ...@@ -617,18 +594,18 @@ _test.value
swap(test.front()["name"], test.back()["name"]); swap(test.front()["name"], test.back()["name"]);
BOOST_CHECK_EQUAL(test.find1<std::string>("id"_key == 1, "name"), "mies"); REQUIRE(test.find1<std::string>("id"_key == 1, "name") == "mies");
BOOST_CHECK_EQUAL(test.find1<std::string>("id"_key == 3, "name"), "aap"); REQUIRE(test.find1<std::string>("id"_key == 3, "name") == "aap");
swap(test.front()["name"], test.back()["name"]); swap(test.front()["name"], test.back()["name"]);
BOOST_CHECK_EQUAL(test.find1<std::string>("id"_key == 1, "name"), "aap"); REQUIRE(test.find1<std::string>("id"_key == 1, "name") == "aap");
BOOST_CHECK_EQUAL(test.find1<std::string>("id"_key == 3, "name"), "mies"); REQUIRE(test.find1<std::string>("id"_key == 3, "name") == "mies");
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(d1) TEST_CASE("d1")
{ {
const char dict[] = R"( const char dict[] = R"(
data_test_dict.dic data_test_dict.dic
...@@ -772,21 +749,21 @@ _cat_2.desc ...@@ -772,21 +749,21 @@ _cat_2.desc
auto &cat1 = f.front()["cat_1"]; auto &cat1 = f.front()["cat_1"];
auto &cat2 = f.front()["cat_2"]; auto &cat2 = f.front()["cat_2"];
BOOST_CHECK_EQUAL(cat1.size(), 3); REQUIRE(cat1.size() == 3);
BOOST_CHECK_EQUAL(cat2.size(), 3); REQUIRE(cat2.size() == 3);
cat1.erase(cif::key("id") == 1); cat1.erase(cif::key("id") == 1);
BOOST_CHECK_EQUAL(cat1.size(), 2); REQUIRE(cat1.size() == 2);
BOOST_CHECK_EQUAL(cat2.size(), 1); REQUIRE(cat2.size() == 1);
// BOOST_CHECK_THROW(cat2.emplace({ // REQUIRE_THROWS_AS(cat2.emplace({
// { "id", 4 }, // { "id", 4 },
// { "parent_id", 4 }, // { "parent_id", 4 },
// { "desc", "moet fout gaan" } // { "desc", "moet fout gaan" }
// }), std::exception); // }), std::exception);
BOOST_CHECK_THROW(cat2.emplace({ { "id", "vijf" }, // <- invalid value REQUIRE_THROWS_AS(cat2.emplace({ { "id", "vijf" }, // <- invalid value
{ "parent_id", 2 }, { "parent_id", 2 },
{ "desc", "moet fout gaan" } }), { "desc", "moet fout gaan" } }),
std::exception); std::exception);
...@@ -794,7 +771,7 @@ _cat_2.desc ...@@ -794,7 +771,7 @@ _cat_2.desc
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(d2) TEST_CASE("d2")
{ {
const char dict[] = R"( const char dict[] = R"(
data_test_dict.dic data_test_dict.dic
...@@ -892,34 +869,34 @@ mies Mies ...@@ -892,34 +869,34 @@ mies Mies
auto &cat1 = f.front()["cat_1"]; auto &cat1 = f.front()["cat_1"];
BOOST_CHECK_EQUAL(cat1.size(), 3); REQUIRE(cat1.size() == 3);
cat1.erase(cif::key("id") == "AAP"); cat1.erase(cif::key("id") == "AAP");
BOOST_CHECK_EQUAL(cat1.size(), 3); REQUIRE(cat1.size() == 3);
cat1.erase(cif::key("id") == "noot"); cat1.erase(cif::key("id") == "noot");
BOOST_CHECK_EQUAL(cat1.size(), 2); REQUIRE(cat1.size() == 2);
// should fail with duplicate key: // should fail with duplicate key:
BOOST_CHECK_THROW(cat1.emplace({ { "id", "aap" }, REQUIRE_THROWS_AS(cat1.emplace({ { "id", "aap" },
{ "c", "2e-aap" } }), { "c", "2e-aap" } }),
std::exception); std::exception);
cat1.erase(cif::key("id") == "aap"); cat1.erase(cif::key("id") == "aap");
BOOST_CHECK_EQUAL(cat1.size(), 1); REQUIRE(cat1.size() == 1);
cat1.emplace({ { "id", "aap" }, cat1.emplace({ { "id", "aap" },
{ "c", "2e-aap" } }); { "c", "2e-aap" } });
BOOST_CHECK_EQUAL(cat1.size(), 2); REQUIRE(cat1.size() == 2);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(d3) TEST_CASE("d3")
{ {
const char dict[] = R"( const char dict[] = R"(
data_test_dict.dic data_test_dict.dic
...@@ -1074,14 +1051,14 @@ _cat_2.desc ...@@ -1074,14 +1051,14 @@ _cat_2.desc
break; break;
} }
BOOST_CHECK_EQUAL(cat1.size(), 3); REQUIRE(cat1.size() == 3);
BOOST_CHECK_EQUAL(cat2.size(), 4); REQUIRE(cat2.size() == 4);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 1).size(), 0); REQUIRE(cat1.find(cif::key("id") == 1).size() == 0);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 10).size(), 1); REQUIRE(cat1.find(cif::key("id") == 10).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 1).size(), 0); REQUIRE(cat2.find(cif::key("parent_id") == 1).size() == 0);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 10).size(), 2); REQUIRE(cat2.find(cif::key("parent_id") == 10).size() == 2);
// check a rename in parent and child, this time only one child should be renamed // check a rename in parent and child, this time only one child should be renamed
...@@ -1091,36 +1068,36 @@ _cat_2.desc ...@@ -1091,36 +1068,36 @@ _cat_2.desc
break; break;
} }
BOOST_CHECK_EQUAL(cat1.size(), 3); REQUIRE(cat1.size() == 3);
BOOST_CHECK_EQUAL(cat2.size(), 4); REQUIRE(cat2.size() == 4);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 2).size(), 0); REQUIRE(cat1.find(cif::key("id") == 2).size() == 0);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 20).size(), 1); REQUIRE(cat1.find(cif::key("id") == 20).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 2).size(), 1); REQUIRE(cat2.find(cif::key("parent_id") == 2).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 20).size(), 1); REQUIRE(cat2.find(cif::key("parent_id") == 20).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 2 and cif::key("name2") == "noot").size(), 0); REQUIRE(cat2.find(cif::key("parent_id") == 2 and cif::key("name2") == "noot").size() == 0);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 2 and cif::key("name2") == "n2").size(), 1); REQUIRE(cat2.find(cif::key("parent_id") == 2 and cif::key("name2") == "n2").size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 20 and cif::key("name2") == "noot").size(), 1); REQUIRE(cat2.find(cif::key("parent_id") == 20 and cif::key("name2") == "noot").size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 20 and cif::key("name2") == "n2").size(), 0); REQUIRE(cat2.find(cif::key("parent_id") == 20 and cif::key("name2") == "n2").size() == 0);
// -------------------------------------------------------------------- // --------------------------------------------------------------------
cat1.erase(cif::key("id") == 10); cat1.erase(cif::key("id") == 10);
BOOST_CHECK_EQUAL(cat1.size(), 2); REQUIRE(cat1.size() == 2);
BOOST_CHECK_EQUAL(cat2.size(), 2); // TODO: Is this really what we want? REQUIRE(cat2.size() == 2); // TODO: Is this really what we want?
cat1.erase(cif::key("id") == 20); cat1.erase(cif::key("id") == 20);
BOOST_CHECK_EQUAL(cat1.size(), 1); REQUIRE(cat1.size() == 1);
BOOST_CHECK_EQUAL(cat2.size(), 1); // TODO: Is this really what we want? REQUIRE(cat2.size() == 1); // TODO: Is this really what we want?
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(d4) TEST_CASE("d4")
{ {
const char dict[] = R"( const char dict[] = R"(
data_test_dict.dic data_test_dict.dic
...@@ -1287,14 +1264,14 @@ _cat_2.parent_id3 ...@@ -1287,14 +1264,14 @@ _cat_2.parent_id3
break; break;
} }
BOOST_CHECK_EQUAL(cat1.size(), 4); REQUIRE(cat1.size() == 4);
BOOST_CHECK_EQUAL(cat2.size(), 13); REQUIRE(cat2.size() == 13);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 1).size(), 0); REQUIRE(cat1.find(cif::key("id") == 1).size() == 0);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 10).size(), 1); REQUIRE(cat1.find(cif::key("id") == 10).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 1).size(), 1); REQUIRE(cat2.find(cif::key("parent_id") == 1).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 10).size(), 2); REQUIRE(cat2.find(cif::key("parent_id") == 10).size() == 2);
for (auto r : cat1.find(cif::key("id") == 2)) for (auto r : cat1.find(cif::key("id") == 2))
{ {
...@@ -1302,14 +1279,14 @@ _cat_2.parent_id3 ...@@ -1302,14 +1279,14 @@ _cat_2.parent_id3
break; break;
} }
BOOST_CHECK_EQUAL(cat1.size(), 4); REQUIRE(cat1.size() == 4);
BOOST_CHECK_EQUAL(cat2.size(), 13); REQUIRE(cat2.size() == 13);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 2).size(), 0); REQUIRE(cat1.find(cif::key("id") == 2).size() == 0);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 20).size(), 1); REQUIRE(cat1.find(cif::key("id") == 20).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 2).size(), 2); REQUIRE(cat2.find(cif::key("parent_id") == 2).size() == 2);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 20).size(), 2); REQUIRE(cat2.find(cif::key("parent_id") == 20).size() == 2);
for (auto r : cat1.find(cif::key("id") == 3)) for (auto r : cat1.find(cif::key("id") == 3))
{ {
...@@ -1317,14 +1294,14 @@ _cat_2.parent_id3 ...@@ -1317,14 +1294,14 @@ _cat_2.parent_id3
break; break;
} }
BOOST_CHECK_EQUAL(cat1.size(), 4); REQUIRE(cat1.size() == 4);
BOOST_CHECK_EQUAL(cat2.size(), 13); REQUIRE(cat2.size() == 13);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 3).size(), 0); REQUIRE(cat1.find(cif::key("id") == 3).size() == 0);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 30).size(), 1); REQUIRE(cat1.find(cif::key("id") == 30).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 3).size(), 2); REQUIRE(cat2.find(cif::key("parent_id") == 3).size() == 2);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 30).size(), 1); REQUIRE(cat2.find(cif::key("parent_id") == 30).size() == 1);
for (auto r : cat1.find(cif::key("id") == 4)) for (auto r : cat1.find(cif::key("id") == 4))
{ {
...@@ -1332,19 +1309,19 @@ _cat_2.parent_id3 ...@@ -1332,19 +1309,19 @@ _cat_2.parent_id3
break; break;
} }
BOOST_CHECK_EQUAL(cat1.size(), 4); REQUIRE(cat1.size() == 4);
BOOST_CHECK_EQUAL(cat2.size(), 13); REQUIRE(cat2.size() == 13);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 4).size(), 0); REQUIRE(cat1.find(cif::key("id") == 4).size() == 0);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 10).size(), 1); REQUIRE(cat1.find(cif::key("id") == 10).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 4).size(), 3); REQUIRE(cat2.find(cif::key("parent_id") == 4).size() == 3);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 40).size(), 0); REQUIRE(cat2.find(cif::key("parent_id") == 40).size() == 0);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(d5) TEST_CASE("d5")
{ {
const char dict[] = R"( const char dict[] = R"(
data_test_dict.dic data_test_dict.dic
...@@ -1497,19 +1474,19 @@ _cat_2.parent_id3 ...@@ -1497,19 +1474,19 @@ _cat_2.parent_id3
// check iterate children // check iterate children
auto PR2set = cat1.find(cif::key("id") == 2); auto PR2set = cat1.find(cif::key("id") == 2);
BOOST_ASSERT(PR2set.size() == 1); REQUIRE(PR2set.size() == 1);
auto PR2 = PR2set.front(); auto PR2 = PR2set.front();
BOOST_CHECK_EQUAL(PR2["id"].as<int>(), 2); REQUIRE(PR2["id"].as<int>() == 2);
auto CR2set = cat1.get_children(PR2, cat2); auto CR2set = cat1.get_children(PR2, cat2);
BOOST_CHECK_EQUAL(CR2set.size(), 3); REQUIRE(CR2set.size() == 3);
BOOST_ASSERT(CR2set.size() == 3); REQUIRE(CR2set.size() == 3);
std::vector<int> CRids; std::vector<int> CRids;
std::transform(CR2set.begin(), CR2set.end(), std::back_inserter(CRids), [](cif::row_handle r) std::transform(CR2set.begin(), CR2set.end(), std::back_inserter(CRids), [](cif::row_handle r)
{ return r["id"].as<int>(); }); { return r["id"].as<int>(); });
std::sort(CRids.begin(), CRids.end()); std::sort(CRids.begin(), CRids.end());
BOOST_CHECK(CRids == std::vector<int>({ 4, 5, 6 })); REQUIRE(CRids == std::vector<int>({ 4, 5, 6 }));
// check a rename in parent and child // check a rename in parent and child
...@@ -1519,18 +1496,18 @@ _cat_2.parent_id3 ...@@ -1519,18 +1496,18 @@ _cat_2.parent_id3
break; break;
} }
BOOST_CHECK_EQUAL(cat1.size(), 3); REQUIRE(cat1.size() == 3);
BOOST_CHECK_EQUAL(cat2.size(), 7); REQUIRE(cat2.size() == 7);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 1).size(), 0); REQUIRE(cat1.find(cif::key("id") == 1).size() == 0);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 10).size(), 1); REQUIRE(cat1.find(cif::key("id") == 10).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 1).size(), 0); REQUIRE(cat2.find(cif::key("parent_id") == 1).size() == 0);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id2") == 1).size(), 0); REQUIRE(cat2.find(cif::key("parent_id2") == 1).size() == 0);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id3") == 1).size(), 0); REQUIRE(cat2.find(cif::key("parent_id3") == 1).size() == 0);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 10).size(), 1); REQUIRE(cat2.find(cif::key("parent_id") == 10).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id2") == 10).size(), 1); REQUIRE(cat2.find(cif::key("parent_id2") == 10).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id3") == 10).size(), 1); REQUIRE(cat2.find(cif::key("parent_id3") == 10).size() == 1);
for (auto r : cat1.find(cif::key("id") == 2)) for (auto r : cat1.find(cif::key("id") == 2))
{ {
...@@ -1538,18 +1515,18 @@ _cat_2.parent_id3 ...@@ -1538,18 +1515,18 @@ _cat_2.parent_id3
break; break;
} }
BOOST_CHECK_EQUAL(cat1.size(), 3); REQUIRE(cat1.size() == 3);
BOOST_CHECK_EQUAL(cat2.size(), 7); REQUIRE(cat2.size() == 7);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 2).size(), 0); REQUIRE(cat1.find(cif::key("id") == 2).size() == 0);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 20).size(), 1); REQUIRE(cat1.find(cif::key("id") == 20).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 2).size(), 0); REQUIRE(cat2.find(cif::key("parent_id") == 2).size() == 0);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id2") == 2).size(), 0); REQUIRE(cat2.find(cif::key("parent_id2") == 2).size() == 0);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id3") == 2).size(), 0); REQUIRE(cat2.find(cif::key("parent_id3") == 2).size() == 0);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 20).size(), 2); REQUIRE(cat2.find(cif::key("parent_id") == 20).size() == 2);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id2") == 20).size(), 2); REQUIRE(cat2.find(cif::key("parent_id2") == 20).size() == 2);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id3") == 20).size(), 2); REQUIRE(cat2.find(cif::key("parent_id3") == 20).size() == 2);
for (auto r : cat1.find(cif::key("id") == 3)) for (auto r : cat1.find(cif::key("id") == 3))
{ {
...@@ -1557,37 +1534,37 @@ _cat_2.parent_id3 ...@@ -1557,37 +1534,37 @@ _cat_2.parent_id3
break; break;
} }
BOOST_CHECK_EQUAL(cat1.size(), 3); REQUIRE(cat1.size() == 3);
BOOST_CHECK_EQUAL(cat2.size(), 7); REQUIRE(cat2.size() == 7);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 3).size(), 0); REQUIRE(cat1.find(cif::key("id") == 3).size() == 0);
BOOST_CHECK_EQUAL(cat1.find(cif::key("id") == 30).size(), 1); REQUIRE(cat1.find(cif::key("id") == 30).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 3).size(), 0); REQUIRE(cat2.find(cif::key("parent_id") == 3).size() == 0);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id2") == 3).size(), 0); REQUIRE(cat2.find(cif::key("parent_id2") == 3).size() == 0);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id3") == 3).size(), 0); REQUIRE(cat2.find(cif::key("parent_id3") == 3).size() == 0);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id") == 30).size(), 1); REQUIRE(cat2.find(cif::key("parent_id") == 30).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id2") == 30).size(), 1); REQUIRE(cat2.find(cif::key("parent_id2") == 30).size() == 1);
BOOST_CHECK_EQUAL(cat2.find(cif::key("parent_id3") == 30).size(), 1); REQUIRE(cat2.find(cif::key("parent_id3") == 30).size() == 1);
// test delete // test delete
cat1.erase(cif::key("id") == 10); cat1.erase(cif::key("id") == 10);
BOOST_CHECK_EQUAL(cat1.size(), 2); REQUIRE(cat1.size() == 2);
BOOST_CHECK_EQUAL(cat2.size(), 4); REQUIRE(cat2.size() == 4);
cat1.erase(cif::key("id") == 20); cat1.erase(cif::key("id") == 20);
BOOST_CHECK_EQUAL(cat1.size(), 1); REQUIRE(cat1.size() == 1);
BOOST_CHECK_EQUAL(cat2.size(), 1); REQUIRE(cat2.size() == 1);
cat1.erase(cif::key("id") == 30); cat1.erase(cif::key("id") == 30);
BOOST_CHECK_EQUAL(cat1.size(), 0); REQUIRE(cat1.size() == 0);
BOOST_CHECK_EQUAL(cat2.size(), 0); REQUIRE(cat2.size() == 0);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(d6) TEST_CASE("d6")
{ {
const char dict[] = R"( const char dict[] = R"(
data_test_dict.dic data_test_dict.dic
...@@ -1734,22 +1711,22 @@ _cat_2.parent_id_2 ...@@ -1734,22 +1711,22 @@ _cat_2.parent_id_2
auto &cat2 = f.front()["cat_2"]; auto &cat2 = f.front()["cat_2"];
// f.front().validate_links(); // f.front().validate_links();
// BOOST_CHECK(not ); // REQUIRE(not );
using namespace cif::literals; using namespace cif::literals;
BOOST_CHECK( cat2.has_parents(cat2.find1("id"_key == 0))); REQUIRE( cat2.has_parents(cat2.find1("id"_key == 0)));
BOOST_CHECK( cat2.has_parents(cat2.find1("id"_key == 1))); REQUIRE( cat2.has_parents(cat2.find1("id"_key == 1)));
BOOST_CHECK( cat2.has_parents(cat2.find1("id"_key == 2))); REQUIRE( cat2.has_parents(cat2.find1("id"_key == 2)));
BOOST_CHECK(not cat2.has_parents(cat2.find1("id"_key == 3))); REQUIRE(not cat2.has_parents(cat2.find1("id"_key == 3)));
BOOST_CHECK( cat2.has_parents(cat2.find1("id"_key == 4))); REQUIRE( cat2.has_parents(cat2.find1("id"_key == 4)));
BOOST_CHECK(not cat2.has_parents(cat2.find1("id"_key == 5))); REQUIRE(not cat2.has_parents(cat2.find1("id"_key == 5)));
BOOST_CHECK( cat2.has_parents(cat2.find1("id"_key == 6))); REQUIRE( cat2.has_parents(cat2.find1("id"_key == 6)));
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(c1) TEST_CASE("c1")
{ {
cif::VERBOSE = 1; cif::VERBOSE = 1;
...@@ -1770,22 +1747,22 @@ _test.name ...@@ -1770,22 +1747,22 @@ _test.name
for (auto r : db["test"].find(cif::key("id") == 1)) for (auto r : db["test"].find(cif::key("id") == 1))
{ {
const auto &[id, name] = r.get<int, std::string>("id", "name"); const auto &[id, name] = r.get<int, std::string>("id", "name");
BOOST_CHECK_EQUAL(id, 1); REQUIRE(id == 1);
BOOST_CHECK_EQUAL(name, "aap"); REQUIRE(name == "aap");
} }
for (auto r : db["test"].find(cif::key("id") == 4)) for (auto r : db["test"].find(cif::key("id") == 4))
{ {
const auto &[id, name] = r.get<int, std::string>("id", "name"); const auto &[id, name] = r.get<int, std::string>("id", "name");
BOOST_CHECK_EQUAL(id, 4); REQUIRE(id == 4);
BOOST_CHECK(name.empty()); REQUIRE(name.empty());
} }
for (auto r : db["test"].find(cif::key("id") == 5)) for (auto r : db["test"].find(cif::key("id") == 5))
{ {
const auto &[id, name] = r.get<int, std::string>("id", "name"); const auto &[id, name] = r.get<int, std::string>("id", "name");
BOOST_CHECK_EQUAL(id, 5); REQUIRE(id == 5);
BOOST_CHECK(name.empty()); REQUIRE(name.empty());
} }
// optional // optional
...@@ -1795,18 +1772,18 @@ _test.name ...@@ -1795,18 +1772,18 @@ _test.name
const auto &[id, name] = r.get<int, std::optional<std::string>>("id", "name"); const auto &[id, name] = r.get<int, std::optional<std::string>>("id", "name");
switch (id) switch (id)
{ {
case 1: BOOST_CHECK(name == "aap"); break; case 1: REQUIRE(name == "aap"); break;
case 2: BOOST_CHECK(name == "noot"); break; case 2: REQUIRE(name == "noot"); break;
case 3: BOOST_CHECK(name == "mies"); break; case 3: REQUIRE(name == "mies"); break;
case 4: case 4:
case 5: BOOST_CHECK(not name); break; case 5: REQUIRE(not name); break;
default: default:
BOOST_CHECK(false); REQUIRE(false);
} }
} }
} }
BOOST_AUTO_TEST_CASE(c2) TEST_CASE("c2")
{ {
cif::VERBOSE = 1; cif::VERBOSE = 1;
...@@ -1830,18 +1807,18 @@ _test.name ...@@ -1830,18 +1807,18 @@ _test.name
{ {
switch (id) switch (id)
{ {
case 1: BOOST_CHECK(name == "aap"); break; case 1: REQUIRE(name == "aap"); break;
case 2: BOOST_CHECK(name == "noot"); break; case 2: REQUIRE(name == "noot"); break;
case 3: BOOST_CHECK(name == "mies"); break; case 3: REQUIRE(name == "mies"); break;
case 4: case 4:
case 5: BOOST_CHECK(not name); break; case 5: REQUIRE(not name); break;
default: default:
BOOST_CHECK(false); REQUIRE(false);
} }
} }
} }
BOOST_AUTO_TEST_CASE(c3) TEST_CASE("c3")
{ {
auto f = R"(data_TEST auto f = R"(data_TEST
# #
...@@ -1862,23 +1839,23 @@ _test.name ...@@ -1862,23 +1839,23 @@ _test.name
{ {
switch (id) switch (id)
{ {
case 1: BOOST_CHECK(name == "aap"); break; case 1: REQUIRE(name == "aap"); break;
case 2: BOOST_CHECK(name == "noot"); break; case 2: REQUIRE(name == "noot"); break;
case 3: BOOST_CHECK(name == "mies"); break; case 3: REQUIRE(name == "mies"); break;
case 4: case 4:
case 5: BOOST_CHECK(not name); break; case 5: REQUIRE(not name); break;
default: default:
BOOST_CHECK(false); REQUIRE(false);
} }
} }
const auto &[id, name] = db["test"].find1<int, std::string>(cif::key("id") == 1, "id", "name"); const auto &[id, name] = db["test"].find1<int, std::string>(cif::key("id") == 1, "id", "name");
BOOST_CHECK_EQUAL(id, 1); REQUIRE(id == 1);
BOOST_CHECK_EQUAL(name, "aap"); REQUIRE(name == "aap");
} }
BOOST_AUTO_TEST_CASE(c4) TEST_CASE("c4")
{ {
auto f = R"(data_TEST auto f = R"(data_TEST
# #
...@@ -1895,39 +1872,39 @@ _test.name ...@@ -1895,39 +1872,39 @@ _test.name
auto &db = f.front(); auto &db = f.front();
// query tests // query tests
BOOST_TEST(db["test"].find_max<int>("id") == 5); REQUIRE(db["test"].find_max<int>("id") == 5);
BOOST_TEST(db["test"].find_max<int>("id", cif::key("name") != cif::null) == 3); REQUIRE(db["test"].find_max<int>("id", cif::key("name") != cif::null) == 3);
BOOST_TEST(db["test"].find_min<int>("id") == 1); REQUIRE(db["test"].find_min<int>("id") == 1);
BOOST_TEST(db["test"].find_min<int>("id", cif::key("name") == cif::null) == 4); REQUIRE(db["test"].find_min<int>("id", cif::key("name") == cif::null) == 4);
// count tests // count tests
BOOST_TEST(db["test"].count(cif::all()) == 5); REQUIRE(db["test"].count(cif::all()) == 5);
BOOST_TEST(db["test"].count(cif::key("name") != cif::null) == 3); REQUIRE(db["test"].count(cif::key("name") != cif::null) == 3);
BOOST_TEST(db["test"].count(cif::key("name") == cif::null) == 2); REQUIRE(db["test"].count(cif::key("name") == cif::null) == 2);
// find_first tests // find_first tests
BOOST_TEST(db["test"].find_first<int>(cif::key("id") == 1, "id") == 1); REQUIRE(db["test"].find_first<int>(cif::key("id") == 1, "id") == 1);
BOOST_TEST(db["test"].find_first<int>(cif::all(), "id") == 1); REQUIRE(db["test"].find_first<int>(cif::all(), "id") == 1);
std::optional<int> v; std::optional<int> v;
v = db["test"].find_first<std::optional<int>>(cif::key("id") == 1, "id"); v = db["test"].find_first<std::optional<int>>(cif::key("id") == 1, "id");
BOOST_TEST(v.has_value()); REQUIRE(v.has_value());
BOOST_TEST(*v == 1); REQUIRE(*v == 1);
v = db["test"].find_first<std::optional<int>>(cif::key("id") == 6, "id"); v = db["test"].find_first<std::optional<int>>(cif::key("id") == 6, "id");
BOOST_TEST(not v.has_value()); REQUIRE(not v.has_value());
// find1 tests // find1 tests
BOOST_TEST(db["test"].find1<int>(cif::key("id") == 1, "id") == 1); REQUIRE(db["test"].find1<int>(cif::key("id") == 1, "id") == 1);
BOOST_CHECK_THROW(db["test"].find1<int>(cif::all(), "id"), cif::multiple_results_error); REQUIRE_THROWS_AS(db["test"].find1<int>(cif::all(), "id"), cif::multiple_results_error);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// rename test // rename test
BOOST_AUTO_TEST_CASE(r1) TEST_CASE("r1")
{ {
/* /*
Rationale: Rationale:
...@@ -2137,20 +2114,20 @@ _cat_3.num ...@@ -2137,20 +2114,20 @@ _cat_3.num
cat3.update_value("name"_key == "aap" and "num"_key == 1, "name", "aapje"); cat3.update_value("name"_key == "aap" and "num"_key == 1, "name", "aapje");
BOOST_CHECK_EQUAL(cat3.size(), 2); REQUIRE(cat3.size() == 2);
{ {
int id, num; int id, num;
std::string name; std::string name;
cif::tie(id, name, num) = cat3.front().get("id", "name", "num"); cif::tie(id, name, num) = cat3.front().get("id", "name", "num");
BOOST_CHECK_EQUAL(id, 1); REQUIRE(id == 1);
BOOST_CHECK_EQUAL(num, 1); REQUIRE(num == 1);
BOOST_CHECK_EQUAL(name, "aapje"); REQUIRE(name == "aapje");
cif::tie(id, name, num) = cat3.back().get("id", "name", "num"); cif::tie(id, name, num) = cat3.back().get("id", "name", "num");
BOOST_CHECK_EQUAL(id, 2); REQUIRE(id == 2);
BOOST_CHECK_EQUAL(num, 2); REQUIRE(num == 2);
BOOST_CHECK_EQUAL(name, "aap"); REQUIRE(name == "aap");
} }
int i = 0; int i = 0;
...@@ -2159,70 +2136,70 @@ _cat_3.num ...@@ -2159,70 +2136,70 @@ _cat_3.num
switch (++i) switch (++i)
{ {
case 1: case 1:
BOOST_CHECK_EQUAL(id, 1); REQUIRE(id == 1);
BOOST_CHECK_EQUAL(num, 1); REQUIRE(num == 1);
BOOST_CHECK_EQUAL(name, "aapje"); REQUIRE(name == "aapje");
BOOST_CHECK_EQUAL(desc, "Een dier"); REQUIRE(desc == "Een dier");
break; break;
case 2: case 2:
BOOST_CHECK_EQUAL(id, 2); REQUIRE(id == 2);
BOOST_CHECK_EQUAL(num, 2); REQUIRE(num == 2);
BOOST_CHECK_EQUAL(name, "aap"); REQUIRE(name == "aap");
BOOST_CHECK_EQUAL(desc, "Een andere aap"); REQUIRE(desc == "Een andere aap");
break; break;
case 3: case 3:
BOOST_CHECK_EQUAL(id, 3); REQUIRE(id == 3);
BOOST_CHECK_EQUAL(num, 1); REQUIRE(num == 1);
BOOST_CHECK_EQUAL(name, "noot"); REQUIRE(name == "noot");
BOOST_CHECK_EQUAL(desc, "walnoot bijvoorbeeld"); REQUIRE(desc == "walnoot bijvoorbeeld");
break; break;
default: default:
BOOST_FAIL("Unexpected record"); REQUIRE(false /*"Unexpected record"*/);
} }
} }
BOOST_CHECK_EQUAL(cat1.size(), 4); REQUIRE(cat1.size() == 4);
i = 0; i = 0;
for (const auto &[id, name, desc] : cat1.rows<int, std::string, std::string>("id", "name", "desc")) for (const auto &[id, name, desc] : cat1.rows<int, std::string, std::string>("id", "name", "desc"))
{ {
switch (++i) switch (++i)
{ {
case 1: case 1:
BOOST_CHECK_EQUAL(id, 1); REQUIRE(id == 1);
BOOST_CHECK_EQUAL(name, "aapje"); REQUIRE(name == "aapje");
BOOST_CHECK_EQUAL(desc, "Aap"); REQUIRE(desc == "Aap");
break; break;
case 2: case 2:
BOOST_CHECK_EQUAL(id, 2); REQUIRE(id == 2);
BOOST_CHECK_EQUAL(name, "noot"); REQUIRE(name == "noot");
BOOST_CHECK_EQUAL(desc, "Noot"); REQUIRE(desc == "Noot");
break; break;
case 3: case 3:
BOOST_CHECK_EQUAL(id, 3); REQUIRE(id == 3);
BOOST_CHECK_EQUAL(name, "mies"); REQUIRE(name == "mies");
BOOST_CHECK_EQUAL(desc, "Mies"); REQUIRE(desc == "Mies");
break; break;
case 4: case 4:
BOOST_CHECK_EQUAL(id, 4); REQUIRE(id == 4);
BOOST_CHECK_EQUAL(name, "aap"); REQUIRE(name == "aap");
BOOST_CHECK_EQUAL(desc, "Aap"); REQUIRE(desc == "Aap");
break; break;
default: default:
BOOST_FAIL("Unexpected record"); REQUIRE(false /* "Unexpected record" */);
} }
} }
// f.save(std::cout); // f.save(std::cout);
} }
BOOST_AUTO_TEST_CASE(pc_1) TEST_CASE("pc_1")
{ {
/* /*
Parent/child tests Parent/child tests
...@@ -2424,29 +2401,29 @@ _cat_3.num ...@@ -2424,29 +2401,29 @@ _cat_3.num
// find all children in cat2 for the row with id == 1 in cat1 // find all children in cat2 for the row with id == 1 in cat1
auto rs1 = cat1.get_children(cat1.find1("id"_key == 1), cat2); auto rs1 = cat1.get_children(cat1.find1("id"_key == 1), cat2);
BOOST_TEST(rs1.size() == 2); REQUIRE(rs1.size() == 2);
auto rs2 = cat1.get_children(cat1.find1("id"_key == 2), cat2); auto rs2 = cat1.get_children(cat1.find1("id"_key == 2), cat2);
BOOST_TEST(rs2.size() == 1); REQUIRE(rs2.size() == 1);
auto rs3 = cat1.get_children(cat1.find1("id"_key == 3), cat2); auto rs3 = cat1.get_children(cat1.find1("id"_key == 3), cat2);
BOOST_TEST(rs3.size() == 0); REQUIRE(rs3.size() == 0);
// finding parents // finding parents
auto rs4 = cat2.get_parents(cat2.find1("id"_key == 1), cat1); auto rs4 = cat2.get_parents(cat2.find1("id"_key == 1), cat1);
BOOST_TEST(rs4.size() == 1); REQUIRE(rs4.size() == 1);
auto rs5 = cat3.get_parents(cat3.find1("id"_key == 1), cat2); auto rs5 = cat3.get_parents(cat3.find1("id"_key == 1), cat2);
BOOST_TEST(rs5.size() == 1); REQUIRE(rs5.size() == 1);
// This link is not defined: // This link is not defined:
auto rs6 = cat3.get_parents(cat3.find1("id"_key == 1), cat1); auto rs6 = cat3.get_parents(cat3.find1("id"_key == 1), cat1);
BOOST_TEST(rs6.size() == 0); REQUIRE(rs6.size() == 0);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
// BOOST_AUTO_TEST_CASE(bondmap_1) // TEST_CASE("bondmap_1")
// { // {
// cif::VERBOSE = 2; // cif::VERBOSE = 2;
...@@ -2553,10 +2530,10 @@ _cat_3.num ...@@ -2553,10 +2530,10 @@ _cat_3.num
// auto atoms = res.atoms(); // auto atoms = res.atoms();
// auto dc = components.get(compound); // auto dc = components.get(compound);
// BOOST_ASSERT(dc != nullptr); // REQUIRE(dc != nullptr);
// auto cc = dc->get("chem_comp_bond"); // auto cc = dc->get("chem_comp_bond");
// BOOST_ASSERT(cc != nullptr); // REQUIRE(cc != nullptr);
// std::set<std::tuple<std::string, std::string>> bonded; // std::set<std::tuple<std::string, std::string>> bonded;
...@@ -2583,8 +2560,8 @@ _cat_3.num ...@@ -2583,8 +2560,8 @@ _cat_3.num
// ? bonded.count({label_j, label_i}) // ? bonded.count({label_j, label_i})
// : bonded.count({label_i, label_j}); // : bonded.count({label_i, label_j});
// BOOST_CHECK(bonded_1 == bonded_t); // REQUIRE(bonded_1 == bonded_t);
// BOOST_CHECK(bonded_1_i == bonded_t); // REQUIRE(bonded_1_i == bonded_t);
// } // }
// } // }
// } // }
...@@ -2598,29 +2575,29 @@ _cat_3.num ...@@ -2598,29 +2575,29 @@ _cat_3.num
// auto C = poly[i].atomByID("C"); // auto C = poly[i].atomByID("C");
// auto N = poly[i + 1].atomByID("N"); // auto N = poly[i + 1].atomByID("N");
// BOOST_CHECK(bm(C, N)); // REQUIRE(bm(C, N));
// BOOST_CHECK(bm(N, C)); // REQUIRE(bm(N, C));
// } // }
// } // }
// BOOST_AUTO_TEST_CASE(bondmap_2) // TEST_CASE("bondmap_2")
// { // {
// BOOST_CHECK_THROW(mmcif::BondMap::atomIDsForCompound("UN_"), mmcif::BondMapException); // REQUIRE_THROWS_AS(mmcif::BondMap::atomIDsForCompound("UN_"), mmcif::BondMapException);
// mmcif::CompoundFactory::instance().pushDictionary(gTestDir / "UN_.cif"); // mmcif::CompoundFactory::instance().pushDictionary(gTestDir / "UN_.cif");
// BOOST_CHECK(mmcif::BondMap::atomIDsForCompound("UN_").empty() == false); // REQUIRE(mmcif::BondMap::atomIDsForCompound("UN_").empty() == false);
// } // }
BOOST_AUTO_TEST_CASE(reading_file_1) TEST_CASE("reading_file_1")
{ {
std::istringstream is("Hello, world!"); std::istringstream is("Hello, world!");
cif::file file; cif::file file;
BOOST_CHECK_THROW(file.load(is), std::runtime_error); REQUIRE_THROWS_AS(file.load(is), std::runtime_error);
} }
BOOST_AUTO_TEST_CASE(parser_test_1) TEST_CASE("parser_test_1")
{ {
auto data1 = R"( auto data1 = R"(
data_QM data_QM
...@@ -2630,12 +2607,12 @@ _test.text ?? ...@@ -2630,12 +2607,12 @@ _test.text ??
auto &db1 = data1.front(); auto &db1 = data1.front();
auto &test1 = db1["test"]; auto &test1 = db1["test"];
BOOST_CHECK_EQUAL(test1.size(), 1); REQUIRE(test1.size() == 1);
for (auto r : test1) for (auto r : test1)
{ {
auto text = r.get<std::string>("text"); auto text = r.get<std::string>("text");
BOOST_CHECK_EQUAL(text, "??"); REQUIRE(text == "??");
} }
std::stringstream ss; std::stringstream ss;
...@@ -2646,16 +2623,16 @@ _test.text ?? ...@@ -2646,16 +2623,16 @@ _test.text ??
auto &db2 = data2.front(); auto &db2 = data2.front();
auto &test2 = db2["test"]; auto &test2 = db2["test"];
BOOST_CHECK_EQUAL(test2.size(), 1); REQUIRE(test2.size() == 1);
for (auto r : test2) for (auto r : test2)
{ {
auto text = r.get<std::string>("text"); auto text = r.get<std::string>("text");
BOOST_CHECK_EQUAL(text, "??"); REQUIRE(text == "??");
} }
} }
BOOST_AUTO_TEST_CASE(output_test_1) TEST_CASE("output_test_1")
{ {
auto data1 = R"( auto data1 = R"(
data_Q data_Q
...@@ -2693,14 +2670,14 @@ boo.data_.whatever ...@@ -2693,14 +2670,14 @@ boo.data_.whatever
{ "_with.leading_underscore", false } { "_with.leading_underscore", false }
}; };
BOOST_CHECK_EQUAL(test1.size(), sizeof(kS) / sizeof(T)); REQUIRE(test1.size() == sizeof(kS) / sizeof(T));
size_t i = 0; size_t i = 0;
for (auto r : test1) for (auto r : test1)
{ {
auto text = r.get<std::string>("text"); auto text = r.get<std::string>("text");
BOOST_CHECK_EQUAL(text, kS[i].s); REQUIRE(text == kS[i].s);
BOOST_CHECK_EQUAL(cif::sac_parser::is_unquoted_string(kS[i].s), kS[i].q); REQUIRE(cif::sac_parser::is_unquoted_string(kS[i].s) == kS[i].q);
++i; ++i;
} }
...@@ -2712,17 +2689,17 @@ boo.data_.whatever ...@@ -2712,17 +2689,17 @@ boo.data_.whatever
auto &db2 = data2.front(); auto &db2 = data2.front();
auto &test2 = db2["test"]; auto &test2 = db2["test"];
BOOST_CHECK_EQUAL(test2.size(), sizeof(kS) / sizeof(T)); REQUIRE(test2.size() == sizeof(kS) / sizeof(T));
i = 0; i = 0;
for (auto r : test2) for (auto r : test2)
{ {
auto text = r.get<std::string>("text"); auto text = r.get<std::string>("text");
BOOST_CHECK_EQUAL(text, kS[i++].s); REQUIRE(text == kS[i++].s);
} }
} }
BOOST_AUTO_TEST_CASE(output_test_2) TEST_CASE("output_test_2")
{ {
auto data1 = R"( auto data1 = R"(
data_Q data_Q
...@@ -2749,14 +2726,14 @@ There it was!)", ...@@ -2749,14 +2726,14 @@ There it was!)",
false } false }
}; };
BOOST_CHECK_EQUAL(test1.size(), sizeof(kS) / sizeof(T)); REQUIRE(test1.size() == sizeof(kS) / sizeof(T));
size_t i = 0; size_t i = 0;
for (auto r : test1) for (auto r : test1)
{ {
auto text = r.get<std::string>("text"); auto text = r.get<std::string>("text");
BOOST_CHECK_EQUAL(text, kS[i].s); REQUIRE(text == kS[i].s);
BOOST_CHECK_EQUAL(cif::sac_parser::is_unquoted_string(kS[i].s), kS[i].q); REQUIRE(cif::sac_parser::is_unquoted_string(kS[i].s) == kS[i].q);
++i; ++i;
} }
...@@ -2768,135 +2745,135 @@ There it was!)", ...@@ -2768,135 +2745,135 @@ There it was!)",
auto &db2 = data2.front(); auto &db2 = data2.front();
auto &test2 = db2["test"]; auto &test2 = db2["test"];
BOOST_CHECK_EQUAL(test2.size(), sizeof(kS) / sizeof(T)); REQUIRE(test2.size() == sizeof(kS) / sizeof(T));
i = 0; i = 0;
for (auto r : test2) for (auto r : test2)
{ {
auto text = r.get<std::string>("text"); auto text = r.get<std::string>("text");
BOOST_CHECK_EQUAL(text, kS[i++].s); REQUIRE(text == kS[i++].s);
} }
} }
BOOST_AUTO_TEST_CASE(trim_test) TEST_CASE("trim_test")
{ {
BOOST_CHECK_EQUAL(cif::trim_copy("aap"), "aap"); REQUIRE(cif::trim_copy("aap") == "aap");
BOOST_CHECK_EQUAL(cif::trim_copy(" aap"), "aap"); REQUIRE(cif::trim_copy(" aap") == "aap");
BOOST_CHECK_EQUAL(cif::trim_copy(" aap "), "aap"); REQUIRE(cif::trim_copy(" aap ") == "aap");
BOOST_CHECK_EQUAL(cif::trim_copy("aap "), "aap"); REQUIRE(cif::trim_copy("aap ") == "aap");
BOOST_CHECK_EQUAL(cif::trim_copy(" aap "), "aap"); REQUIRE(cif::trim_copy(" aap ") == "aap");
BOOST_CHECK_EQUAL(cif::trim_left_copy("aap"), "aap"); REQUIRE(cif::trim_left_copy("aap") == "aap");
BOOST_CHECK_EQUAL(cif::trim_left_copy(" aap"), "aap"); REQUIRE(cif::trim_left_copy(" aap") == "aap");
BOOST_CHECK_EQUAL(cif::trim_left_copy(" aap "), "aap "); REQUIRE(cif::trim_left_copy(" aap ") == "aap ");
BOOST_CHECK_EQUAL(cif::trim_left_copy("aap "), "aap "); REQUIRE(cif::trim_left_copy("aap ") == "aap ");
BOOST_CHECK_EQUAL(cif::trim_left_copy("aap "), "aap "); REQUIRE(cif::trim_left_copy("aap ") == "aap ");
BOOST_CHECK_EQUAL(cif::trim_right_copy("aap"), "aap"); REQUIRE(cif::trim_right_copy("aap") == "aap");
BOOST_CHECK_EQUAL(cif::trim_right_copy(" aap"), " aap"); REQUIRE(cif::trim_right_copy(" aap") == " aap");
BOOST_CHECK_EQUAL(cif::trim_right_copy(" aap "), " aap"); REQUIRE(cif::trim_right_copy(" aap ") == " aap");
BOOST_CHECK_EQUAL(cif::trim_right_copy("aap "), "aap"); REQUIRE(cif::trim_right_copy("aap ") == "aap");
BOOST_CHECK_EQUAL(cif::trim_right_copy(" aap "), " aap"); REQUIRE(cif::trim_right_copy(" aap ") == " aap");
std::string s; std::string s;
s = "aap"; s = "aap";
cif::trim(s); cif::trim(s);
BOOST_CHECK_EQUAL(s, "aap"); REQUIRE(s == "aap");
s = " aap"; s = " aap";
cif::trim(s); cif::trim(s);
BOOST_CHECK_EQUAL(s, "aap"); REQUIRE(s == "aap");
s = " aap "; s = " aap ";
cif::trim(s); cif::trim(s);
BOOST_CHECK_EQUAL(s, "aap"); REQUIRE(s == "aap");
s = "aap "; s = "aap ";
cif::trim(s); cif::trim(s);
BOOST_CHECK_EQUAL(s, "aap"); REQUIRE(s == "aap");
s = " aap "; s = " aap ";
cif::trim(s); cif::trim(s);
BOOST_CHECK_EQUAL(s, "aap"); REQUIRE(s == "aap");
s = "aap"; s = "aap";
cif::trim_left(s); cif::trim_left(s);
BOOST_CHECK_EQUAL(s, "aap"); REQUIRE(s == "aap");
s = " aap"; s = " aap";
cif::trim_left(s); cif::trim_left(s);
BOOST_CHECK_EQUAL(s, "aap"); REQUIRE(s == "aap");
s = " aap "; s = " aap ";
cif::trim_left(s); cif::trim_left(s);
BOOST_CHECK_EQUAL(s, "aap "); REQUIRE(s == "aap ");
s = "aap "; s = "aap ";
cif::trim_left(s); cif::trim_left(s);
BOOST_CHECK_EQUAL(s, "aap "); REQUIRE(s == "aap ");
s = "aap "; s = "aap ";
cif::trim_left(s); cif::trim_left(s);
BOOST_CHECK_EQUAL(s, "aap "); REQUIRE(s == "aap ");
s = "aap"; s = "aap";
cif::trim_right(s); cif::trim_right(s);
BOOST_CHECK_EQUAL(s, "aap"); REQUIRE(s == "aap");
s = " aap"; s = " aap";
cif::trim_right(s); cif::trim_right(s);
BOOST_CHECK_EQUAL(s, " aap"); REQUIRE(s == " aap");
s = " aap "; s = " aap ";
cif::trim_right(s); cif::trim_right(s);
BOOST_CHECK_EQUAL(s, " aap"); REQUIRE(s == " aap");
s = "aap "; s = "aap ";
cif::trim_right(s); cif::trim_right(s);
BOOST_CHECK_EQUAL(s, "aap"); REQUIRE(s == "aap");
s = " aap "; s = " aap ";
cif::trim_right(s); cif::trim_right(s);
BOOST_CHECK_EQUAL(s, " aap"); REQUIRE(s == " aap");
} }
BOOST_AUTO_TEST_CASE(split_test) TEST_CASE("split_test")
{ {
std::vector<std::string_view> v, t; std::vector<std::string_view> v, t;
v = cif::split<>("aap;noot;mies", ";"); v = cif::split<>("aap;noot;mies", ";");
t = std::vector<std::string_view>{ "aap", "noot", "mies" }; t = std::vector<std::string_view>{ "aap", "noot", "mies" };
BOOST_CHECK(v == t); REQUIRE(v == t);
v = cif::split("aap;noot,mies", ";,"); v = cif::split("aap;noot,mies", ";,");
// t = std::vector<std::string>{ "aap", "noot", "mies" }; // t = std::vector<std::string>{ "aap", "noot", "mies" };
BOOST_CHECK(v == t); REQUIRE(v == t);
v = cif::split(";aap;noot,mies;", ";,"); v = cif::split(";aap;noot,mies;", ";,");
t = std::vector<std::string_view>{ "", "aap", "noot", "mies", "" }; t = std::vector<std::string_view>{ "", "aap", "noot", "mies", "" };
BOOST_CHECK(v == t); REQUIRE(v == t);
v = cif::split(";aap;noot,mies;", ";,", true); v = cif::split(";aap;noot,mies;", ";,", true);
t = std::vector<std::string_view>{ "aap", "noot", "mies" }; t = std::vector<std::string_view>{ "aap", "noot", "mies" };
BOOST_CHECK(v == t); REQUIRE(v == t);
} }
BOOST_AUTO_TEST_CASE(join_test) TEST_CASE("join_test")
{ {
BOOST_CHECK_EQUAL(cif::join(std::vector<std::string>{ "aap" }, ", "), "aap"); REQUIRE(cif::join(std::vector<std::string>{ "aap" }, ", ") == "aap");
BOOST_CHECK_EQUAL(cif::join(std::vector<std::string>{ "aap", "noot" }, ", "), "aap, noot"); REQUIRE(cif::join(std::vector<std::string>{ "aap", "noot" }, ", ") == "aap, noot");
BOOST_CHECK_EQUAL(cif::join(std::vector<std::string>{ "aap", "noot", "mies" }, ", "), "aap, noot, mies"); REQUIRE(cif::join(std::vector<std::string>{ "aap", "noot", "mies" }, ", ") == "aap, noot, mies");
} }
BOOST_AUTO_TEST_CASE(replace_all_test) TEST_CASE("replace_all_test")
{ {
std::string s("aap, noot, mies"); std::string s("aap, noot, mies");
cif::replace_all(s, ", ", ","); cif::replace_all(s, ", ", ",");
BOOST_CHECK_EQUAL(s, "aap,noot,mies"); REQUIRE(s == "aap,noot,mies");
cif::replace_all(s, ",", ", "); cif::replace_all(s, ",", ", ");
BOOST_CHECK_EQUAL(s, "aap, noot, mies"); REQUIRE(s == "aap, noot, mies");
cif::replace_all(s, ", ", ", "); cif::replace_all(s, ", ", ", ");
BOOST_CHECK_EQUAL(s, "aap, noot, mies"); REQUIRE(s == "aap, noot, mies");
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(reorder_test) TEST_CASE("reorder_test")
{ {
const char dict[] = R"( const char dict[] = R"(
...@@ -2994,7 +2971,7 @@ _cat_1.name ...@@ -2994,7 +2971,7 @@ _cat_1.name
std::istream is_data(&data_buffer); std::istream is_data(&data_buffer);
f.load(is_data); f.load(is_data);
BOOST_ASSERT(f.is_valid()); REQUIRE(f.is_valid());
auto &cat1 = f.front()["cat_1"]; auto &cat1 = f.front()["cat_1"];
cat1.reorder_by_index(); cat1.reorder_by_index();
...@@ -3005,15 +2982,15 @@ _cat_1.name ...@@ -3005,15 +2982,15 @@ _cat_1.name
for (const auto &[id, name] : cat1.rows<int, std::string>("id", "name")) for (const auto &[id, name] : cat1.rows<int, std::string>("id", "name"))
{ {
BOOST_CHECK_EQUAL(id, n); REQUIRE(id == n);
BOOST_CHECK_EQUAL(name, ts[n - 1]); REQUIRE(name == ts[n - 1]);
++n; ++n;
} }
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(audit_conform_test) TEST_CASE("audit_conform_test")
{ {
const char dict[] = R"( const char dict[] = R"(
...@@ -3193,22 +3170,22 @@ _cat_1.name ...@@ -3193,22 +3170,22 @@ _cat_1.name
std::istream is_data(&data_buffer); std::istream is_data(&data_buffer);
f.load(is_data); f.load(is_data);
BOOST_ASSERT(f.is_valid()); REQUIRE(f.is_valid());
std::stringstream ss; std::stringstream ss;
ss << f; ss << f;
cif::file f2(ss); cif::file f2(ss);
BOOST_ASSERT(f2.is_valid()); REQUIRE(f2.is_valid());
auto &audit_conform = f2.front()["audit_conform"]; auto &audit_conform = f2.front()["audit_conform"];
BOOST_CHECK_EQUAL(audit_conform.front()["dict_name"].as<std::string>(), "test_dict.dic"); REQUIRE(audit_conform.front()["dict_name"].as<std::string>() == "test_dict.dic");
BOOST_CHECK_EQUAL(audit_conform.front()["dict_version"].as<float>(), 1.0); REQUIRE(audit_conform.front()["dict_version"].as<float>() == 1.0);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(ix_op_1) TEST_CASE("ix_op_1")
{ {
const char dict[] = R"( const char dict[] = R"(
data_test_dict.dic data_test_dict.dic
...@@ -3311,12 +3288,12 @@ _cat_1.id_2 ...@@ -3311,12 +3288,12 @@ _cat_1.id_2
}; };
for (const auto &[key, test] : TESTS) for (const auto &[key, test] : TESTS)
BOOST_CHECK_EQUAL((bool)cat1[key], test); REQUIRE((bool)cat1[key] == test);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(cifv1_0_1) TEST_CASE("cifv1_0_1")
{ {
auto f = R"(data_TEST auto f = R"(data_TEST
# #
...@@ -3343,10 +3320,10 @@ _name ...@@ -3343,10 +3320,10 @@ _name
switch (id) switch (id)
{ {
case 1: BOOST_CHECK_EQUAL(*name, "aap"); break; case 1: REQUIRE(*name == "aap"); break;
case 2: BOOST_CHECK_EQUAL(*name, "noot"); break; case 2: REQUIRE(*name == "noot"); break;
case 3: BOOST_CHECK_EQUAL(*name, "mies"); break; case 3: REQUIRE(*name == "mies"); break;
default: BOOST_CHECK(name.has_value() == false); default: REQUIRE(name.has_value() == false);
} }
} }
...@@ -3356,12 +3333,12 @@ _name ...@@ -3356,12 +3333,12 @@ _name
auto f2 = cif::file(ss); auto f2 = cif::file(ss);
auto &db2 = f2.front(); auto &db2 = f2.front();
BOOST_TEST(db == db2); REQUIRE(db == db2);
} }
// BOOST_AUTO_TEST_CASE(cifv1_0_2) // TEST_CASE("cifv1_0_2")
// { // {
// BOOST_CHECK_THROW(R"(data_TEST // REQUIRE_THROWS_AS(R"(data_TEST
// # // #
// _version 1.0 // _version 1.0
// loop_ // loop_
...@@ -3375,7 +3352,7 @@ _name ...@@ -3375,7 +3352,7 @@ _name
// )"_cf, cif::parse_error); // )"_cf, cif::parse_error);
// } // }
BOOST_AUTO_TEST_CASE(cifv1_0_3) TEST_CASE("cifv1_0_3")
{ {
auto f = R"(data_TEST auto f = R"(data_TEST
# #
...@@ -3386,11 +3363,11 @@ _date today ...@@ -3386,11 +3363,11 @@ _date today
auto &db = f.front(); auto &db = f.front();
auto &cat = db[""]; auto &cat = db[""];
BOOST_CHECK(not cat.empty()); REQUIRE(not cat.empty());
auto r = cat.front(); auto r = cat.front();
BOOST_CHECK_EQUAL(r["version"].as<std::string>(), "1.0"); REQUIRE(r["version"].as<std::string>() == "1.0");
BOOST_CHECK_EQUAL(r["date"].as<std::string>(), "today"); REQUIRE(r["date"].as<std::string>() == "today");
std::stringstream ss; std::stringstream ss;
ss << db; ss << db;
...@@ -3398,10 +3375,10 @@ _date today ...@@ -3398,10 +3375,10 @@ _date today
auto f2 = cif::file(ss); auto f2 = cif::file(ss);
auto &db2 = f2.front(); auto &db2 = f2.front();
BOOST_TEST(db == db2); REQUIRE(db == db2);
} }
BOOST_AUTO_TEST_CASE(find1_opt_1) TEST_CASE("find1_opt_1")
{ {
using namespace cif::literals; using namespace cif::literals;
using namespace std::literals; using namespace std::literals;
...@@ -3421,26 +3398,26 @@ _test.value ...@@ -3421,26 +3398,26 @@ _test.value
auto &test = db["test"]; auto &test = db["test"];
auto v = test.find1<std::optional<float>>("id"_key == 1, "value"); auto v = test.find1<std::optional<float>>("id"_key == 1, "value");
BOOST_CHECK(v.has_value()); REQUIRE(v.has_value());
BOOST_TEST(*v == 1.0f); REQUIRE(*v == 1.0f);
v = test.find1<std::optional<float>>("id"_key == 4, "value"); v = test.find1<std::optional<float>>("id"_key == 4, "value");
BOOST_CHECK(v.has_value() == false); REQUIRE(v.has_value() == false);
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(compound_test_1) TEST_CASE("compound_test_1")
{ {
cif::compound_factory::instance().push_dictionary(gTestDir / "REA_v2.cif"); cif::compound_factory::instance().push_dictionary(gTestDir / "REA_v2.cif");
auto compound = cif::compound_factory::instance().create("REA_v2"); auto compound = cif::compound_factory::instance().create("REA_v2");
BOOST_ASSERT(compound != nullptr); REQUIRE(compound != nullptr);
BOOST_CHECK(compound->id() == "REA_v2"); REQUIRE(compound->id() == "REA_v2");
} }
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(pdb_parser_test_1) TEST_CASE("pdb_parser_test_1")
{ {
char k1CBS[] = R"(HEADER RETINOIC-ACID TRANSPORT 28-SEP-94 1CBS char k1CBS[] = R"(HEADER RETINOIC-ACID TRANSPORT 28-SEP-94 1CBS
TITLE CRYSTAL STRUCTURE OF CELLULAR RETINOIC-ACID-BINDING TITLE CRYSTAL STRUCTURE OF CELLULAR RETINOIC-ACID-BINDING
...@@ -3486,8 +3463,8 @@ ATOM 7 CD PRO A 1 15.762 13.216 43.724 1.00 30.71 C)" ...@@ -3486,8 +3463,8 @@ ATOM 7 CD PRO A 1 15.762 13.216 43.724 1.00 30.71 C)"
// -------------------------------------------------------------------- // --------------------------------------------------------------------
BOOST_AUTO_TEST_CASE(compound_not_found_test_1) TEST_CASE("compound_not_found_test_1")
{ {
auto cmp = cif::compound_factory::instance().create("&&&"); auto cmp = cif::compound_factory::instance().create("&&&");
BOOST_CHECK(cmp == nullptr); REQUIRE(cmp == nullptr);
} }
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