Files
rdkit/Code/GraphMol/catch_tests.cpp
Greg Landrum 223513a76e Start to use Catch2 for new tests (#1732)
* backup

* build works

* works

* builds on linux

* rename the test

* add another test to make sure that works
2018-09-04 10:32:17 -04:00

46 lines
1.5 KiB
C++

#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do
// this in one cpp file
#include "catch.hpp"
#include <GraphMol/RDKitBase.h>
#include <GraphMol/RDKitQueries.h>
#include <GraphMol/Chirality.h>
#include <GraphMol/SmilesParse/SmilesParse.h>
#include <GraphMol/SmilesParse/SmilesWrite.h>
#include <GraphMol/SmilesParse/SmartsWrite.h>
using namespace RDKit;
TEST_CASE("SMILES Parsing works", "[molops]") {
std::unique_ptr<RWMol> mol(SmilesToMol("C1CC1"));
REQUIRE(mol);
REQUIRE(mol->getNumAtoms() == 3);
}
TEST_CASE("Sanitization tests", "[molops]") {
std::unique_ptr<RWMol> mol(SmilesToMol("C1=CC=CC=C1Cc2ccccc2", false, false));
REQUIRE(mol);
REQUIRE(mol->getNumAtoms() == 13);
SECTION("properties") {
mol->updatePropertyCache();
CHECK(mol->getAtomWithIdx(0)->getTotalNumHs() == 1);
CHECK(!mol->getAtomWithIdx(0)->getIsAromatic());
CHECK(mol->getAtomWithIdx(7)->getIsAromatic());
SECTION("aromaticity") {
unsigned int opThatFailed;
MolOps::sanitizeMol(*mol, opThatFailed, MolOps::SANITIZE_SETAROMATICITY);
// mol->debugMol(std::cerr);
CHECK(mol->getAtomWithIdx(7)->getIsAromatic());
// blocked by #1730
// CHECK(mol->getAtomWithIdx(0)->getIsAromatic());
}
SECTION("kekulize") {
unsigned int opThatFailed;
MolOps::sanitizeMol(*mol, opThatFailed, MolOps::SANITIZE_KEKULIZE);
CHECK(!mol->getAtomWithIdx(0)->getIsAromatic());
CHECK(!mol->getAtomWithIdx(7)->getIsAromatic());
}
}
}