mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
* Fix #8638 * add a test --------- Co-authored-by: greg landrum <greg.landrum@gmail.com>
This commit is contained in:
@@ -1442,14 +1442,14 @@ void ResonanceMolSupplier::mainLoop(unsigned int ti, unsigned int nt) {
|
||||
// atoms and bonds which do not belong to a conjugated group are given
|
||||
// index -1
|
||||
void ResonanceMolSupplier::assignConjGrpIdx() {
|
||||
unsigned int na = d_mol->getNumAtoms();
|
||||
d_atomConjGrpIdx.resize(na, -1);
|
||||
unsigned int nb = d_mol->getNumBonds();
|
||||
if (!nb) {
|
||||
return;
|
||||
}
|
||||
std::stack<unsigned int> bondIndexStack;
|
||||
d_bondConjGrpIdx.resize(nb, -1);
|
||||
unsigned int na = d_mol->getNumAtoms();
|
||||
d_atomConjGrpIdx.resize(na, -1);
|
||||
for (d_nConjGrp = 0; true; ++d_nConjGrp) {
|
||||
for (const auto b : d_mol->bonds()) {
|
||||
unsigned int i = b->getIdx();
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <GraphMol/SmilesParse/SmilesParse.h>
|
||||
#include <GraphMol/SmilesParse/SmilesWrite.h>
|
||||
#include <GraphMol/SmilesParse/SmartsWrite.h>
|
||||
#include <GraphMol/Resonance.h>
|
||||
#include <GraphMol/test_fixtures.h>
|
||||
|
||||
using namespace RDKit;
|
||||
@@ -4837,3 +4838,12 @@ TEST_CASE("clearPropertyCache") {
|
||||
CHECK(atom->needsUpdatePropertyCache());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"github #8638: ResonanceMolSupplier raises an error if Mol has no bonds") {
|
||||
auto mol = "C"_smiles;
|
||||
REQUIRE(mol);
|
||||
ResonanceMolSupplier rsuppl(*mol);
|
||||
CHECK(rsuppl.getNumConjGrps() == 0);
|
||||
CHECK(rsuppl.getAtomConjGrpIdx(0) == -1);
|
||||
}
|
||||
Reference in New Issue
Block a user