void test5() { string smi = "CCCC"; Mol *m = SmilesToMol(smi); Mol::BondIterator bondIt; unsigned int idx = 0; for (bondIt = m->beginBonds(); bondIt != m->endBonds(); bondIt++) { CHECK_INVARIANT((*bondIt)->getIdx() == idx, "bad idx"); idx++; } CHECK_INVARIANT(idx == 3, "bad idx"); idx = 0; for (bondIt = m->beginBonds(); bondIt != m->endBonds(); bondIt++) { CHECK_INVARIANT((*bondIt)->getIdx() == idx, "bad idx"); idx++; } CHECK_INVARIANT(idx == 3, "bad idx"); idx = 0; Mol::BondIterator beginP(m->beginBonds()); Mol::BondIterator endP(m->endBonds()); for (bondIt = beginP; bondIt != endP; bondIt++) { CHECK_INVARIANT((*bondIt)->getIdx() == idx, "bad idx"); idx++; } CHECK_INVARIANT(idx == 3, "bad idx"); BOOST_LOG(rdInfoLog) << "test5 done" << endl; }
void test2() { string smi = "C1COC1"; Mol *m = SmilesToMol(smi); Mol::BondIterator bondIt; unsigned int idx = 0; for (bondIt = m->beginBonds(); bondIt != m->endBonds(); bondIt++) { CHECK_INVARIANT((*bondIt)->getIdx() == idx, "bad idx"); idx++; } bondIt = m->beginBonds(); Mol::BondIterator bondIt2 = m->beginBonds(); CHECK_INVARIANT(bondIt == bondIt2, "iterators don't compare equal"); bondIt++; CHECK_INVARIANT((*bondIt)->getIdx() == 1, "bad idx"); bondIt++; bondIt++; bondIt--; CHECK_INVARIANT((*bondIt)->getIdx() == 2, "bad idx"); CHECK_INVARIANT(bondIt != bondIt2, "iterators don't compare different"); bondIt--; --bondIt; CHECK_INVARIANT((*bondIt)->getIdx() == 0, "bad idx"); CHECK_INVARIANT(bondIt == bondIt2, "iterator inequality failed"); bondIt++; ++bondIt; CHECK_INVARIANT((*bondIt)->getIdx() == 2, "bad idx"); // past the end stuff bondIt2 = m->endBonds(); bondIt = m->beginBonds(); bondIt--; BOOST_LOG(rdInfoLog) << "test2 done" << endl; };
void testIssue263() { string smi = "c1ccccc1C"; #if 1 Mol *m = SmilesToMol(smi); Mol::AtomIterator atomIt; unsigned int idx = 0; for (atomIt = m->beginAtoms(); atomIt != m->endAtoms(); ++atomIt) { TEST_ASSERT((*atomIt)->getIdx() == idx); idx++; } TEST_ASSERT(idx == 7); Mol::BondIterator bondIt; idx = 0; for (bondIt = m->beginBonds(); bondIt != m->endBonds(); ++bondIt) { CHECK_INVARIANT((*bondIt)->getIdx() == idx, "bad idx"); idx++; } CHECK_INVARIANT(idx == 7, "bad idx"); #endif BOOST_LOG(rdInfoLog) << "testIssue263 done" << endl; }