1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
//
// Copyright (C) 2018 Novartis Institutes Of BioMedical Research
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#include <RDGeneral/test.h>
#include <GraphMol/RDKitBase.h>
#include <GraphMol/MonomerInfo.h>
#include <GraphMol/RDKitQueries.h>
#include <RDGeneral/types.h>
#include <RDGeneral/RDLog.h>
#include <GraphMol/FileParsers/FileParsers.h>
#include <GraphMol/FileParsers/MolWriters.h>
#include <GraphMol/SmilesParse/SmilesParse.h>
#include <GraphMol/SmilesParse/SmilesWrite.h>
#include <sstream>
#include <iostream>
using namespace std;
using namespace RDKit;
// memory tests for valgrind
void testRemoveAtomBond(RWMol &m, int atomidx, int bondidx) {
const Bond *b = m.getBondWithIdx(bondidx);
if (bondidx >= 0) m.removeBond(b->getBeginAtomIdx(), b->getEndAtomIdx());
if (atomidx >= 0) m.removeAtom(atomidx);
}
void testRemovals(RWMol m) {
for (unsigned int i = 0; i < m.getNumAtoms() / 2; i++) {
int atomidx = (i % 2 == 0) ? m.getNumAtoms() - 1 : 0;
int bondidx = (i % 2 == 0) ? m.getNumBonds() - 1 : 0;
testRemoveAtomBond(m, atomidx, bondidx);
}
}
void test1() {
std::string smi = "CCC";
for (int i = 4; i < 20; ++i) {
smi += "C";
RWMol *m = SmilesToMol(smi.c_str());
testRemovals(*m);
delete m;
}
}
void test2() {
std::string smi = "CCC";
auto m = std::unique_ptr<ROMol>(SmilesToMol(smi));
for (const auto at : m->atoms()) {
TEST_ASSERT(at->getAtomicNum() == 6);
}
for (const auto bnd : m->bonds()) {
TEST_ASSERT(bnd->getBondType() == Bond::SINGLE);
}
}
void testCopyConstructor() {
RDKit::RWMol mol1;
RDKit::RWMol mol2(mol1);
RDKit::RWMol mol3;
mol3 = mol2;
}
// -------------------------------------------------------------------
int main() {
RDLog::InitLogs();
// boost::logging::enable_logs("rdApp.info");
test1();
testCopyConstructor();
return 0;
}
|