mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
Switch a bunch of C++ tests to use catch2 (#8625)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (C) 2017 Greg Landrum
|
||||
// Copyright (C) 2017-2025 Greg Landrum and other RDKit contributors
|
||||
//
|
||||
// @@ All Rights Reserved @@
|
||||
// This file is part of the RDKit.
|
||||
@@ -7,7 +7,7 @@
|
||||
// which is included in the file license.txt, found at the root
|
||||
// of the RDKit source tree.
|
||||
//
|
||||
#include <RDGeneral/test.h>
|
||||
#include <catch2/catch_all.hpp>
|
||||
#include "MaxMinPicker.h"
|
||||
#include <iostream>
|
||||
#include <RDGeneral/Invariant.h>
|
||||
@@ -18,26 +18,17 @@ double dist_on_line(unsigned int i, unsigned int j) {
|
||||
return std::fabs((double)i - (double)j);
|
||||
}
|
||||
} // namespace
|
||||
void testGithub1421() {
|
||||
BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl;
|
||||
BOOST_LOG(rdErrorLog)
|
||||
<< "Testing github issue 1421: MaxMinPicker picking non-existent element."
|
||||
<< std::endl;
|
||||
TEST_CASE("testGithub1421") {
|
||||
RDPickers::MaxMinPicker pkr;
|
||||
RDKit::INT_VECT picks;
|
||||
int poolSz = 1000;
|
||||
picks = pkr.lazyPick(dist_on_line, poolSz, 10, RDKit::INT_VECT(), 2748);
|
||||
for (auto pick : picks) {
|
||||
TEST_ASSERT(pick < poolSz);
|
||||
REQUIRE(pick < poolSz);
|
||||
}
|
||||
BOOST_LOG(rdErrorLog) << "Done" << std::endl;
|
||||
}
|
||||
|
||||
void testGithub2245() {
|
||||
BOOST_LOG(rdErrorLog) << "-------------------------------------" << std::endl;
|
||||
BOOST_LOG(rdErrorLog) << "Testing github issue 2245: MinMax Diversity picker "
|
||||
"seeding shows deterministic / non-random behaviour."
|
||||
<< std::endl;
|
||||
TEST_CASE("testGithub2245") {
|
||||
const int MAX_ALLOWED_FAILURES = 3;
|
||||
int maxAllowedFailures;
|
||||
{
|
||||
@@ -52,9 +43,9 @@ void testGithub2245() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
TEST_ASSERT(maxAllowedFailures);
|
||||
REQUIRE(maxAllowedFailures);
|
||||
}
|
||||
{ // make sure the default is also random
|
||||
{
|
||||
RDPickers::MaxMinPicker pkr;
|
||||
int poolSz = 1000;
|
||||
auto picks1 = pkr.lazyPick(dist_on_line, poolSz, 10);
|
||||
@@ -65,23 +56,15 @@ void testGithub2245() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
TEST_ASSERT(maxAllowedFailures);
|
||||
REQUIRE(maxAllowedFailures);
|
||||
}
|
||||
{ // and we're still reproducible when we want to be
|
||||
{
|
||||
RDPickers::MaxMinPicker pkr;
|
||||
int poolSz = 1000;
|
||||
auto picks1 =
|
||||
pkr.lazyPick(dist_on_line, poolSz, 10, RDKit::INT_VECT(), 0xf00d);
|
||||
auto picks2 =
|
||||
pkr.lazyPick(dist_on_line, poolSz, 10, RDKit::INT_VECT(), 0xf00d);
|
||||
TEST_ASSERT(picks1 == picks2);
|
||||
REQUIRE(picks1 == picks2);
|
||||
}
|
||||
BOOST_LOG(rdErrorLog) << "Done" << std::endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
RDLog::InitLogs();
|
||||
testGithub1421();
|
||||
testGithub2245();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user