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; }
void test1() { string smi = "CCOC"; Mol *m = SmilesToMol(smi); Mol::AtomIterator atIt; unsigned int idx = 0; for (atIt = m->beginAtoms(); atIt != m->endAtoms(); atIt++) { CHECK_INVARIANT((*atIt)->getIdx() == idx, "bad idx"); idx++; } atIt = m->beginAtoms(); CHECK_INVARIANT((*(atIt + 2))->getIdx() == 2, "bad idx"); atIt = m->beginAtoms(); Mol::AtomIterator atIt2 = m->beginAtoms(); CHECK_INVARIANT(atIt == atIt2, "iterators don't compare equal"); atIt++; CHECK_INVARIANT((*atIt)->getIdx() == 1, "bad idx"); atIt += 2; CHECK_INVARIANT((*atIt)->getIdx() == 3, "bad idx"); atIt -= 1; CHECK_INVARIANT((*atIt)->getIdx() == 2, "bad idx"); CHECK_INVARIANT(atIt != atIt2, "iterators don't compare different"); CHECK_INVARIANT(atIt2 < atIt, "iterator inequality failed"); CHECK_INVARIANT(atIt2 <= atIt, "iterator inequality failed"); CHECK_INVARIANT(atIt > atIt2, "iterator inequality failed"); CHECK_INVARIANT(atIt >= atIt2, "iterator inequality failed"); atIt--; --atIt; CHECK_INVARIANT((*atIt)->getIdx() == 0, "bad idx"); CHECK_INVARIANT(atIt == atIt2, "iterator inequality failed"); atIt++; ++atIt; CHECK_INVARIANT((*atIt)->getIdx() == 2, "bad idx"); atIt = m->beginAtoms(); atIt = atIt + 2; atIt = atIt - 2; CHECK_INVARIANT((*atIt)->getIdx() == 0, "bad idx"); atIt2 = m->beginAtoms(); atIt2 += 2; CHECK_INVARIANT(atIt2 - atIt == 2, "subtraction failed"); CHECK_INVARIANT(atIt - atIt2 == -2, "subtraction failed"); // past the end stuff atIt2 = m->endAtoms(); atIt = m->beginAtoms() + 10; CHECK_INVARIANT(atIt >= atIt2, "past-the-end failed"); // this is whack atIt = m->beginAtoms(); atIt -= 10; CHECK_INVARIANT(atIt >= atIt2, "past-the-end failed"); BOOST_LOG(rdInfoLog) << "test1 done" << endl; };