Ejemplo n.º 1
0
void testHasPropWithValueMatch() {
  {
    QueryAtom qA;
    qA.setQuery(makePropQuery<Atom, int>("foo", 2));
    Atom a1(6);
    TEST_ASSERT(!qA.Match(&a1));
    a1.setProp<int>("foo", 1);
    TEST_ASSERT(!qA.Match(&a1));
    a1.setProp<int>("foo", 2);
    TEST_ASSERT(qA.Match(&a1));

    a1.clearProp("foo");
    a1.setProp<double>("foo", 2);
    TEST_ASSERT(!qA.Match(&a1));
  }

  {
    QueryAtom qA;
    qA.setQuery(makePropQuery<Atom, std::string>("foo", "bar"));
    Atom a1(6);
    TEST_ASSERT(!qA.Match(&a1));
    a1.setProp<std::string>("foo", "bar");
    TEST_ASSERT(qA.Match(&a1));
  }

  {
    QueryBond qA;
    qA.setQuery(makePropQuery<Bond, int>("foo", 2));
    Bond a1;
    TEST_ASSERT(!qA.Match(&a1));
    a1.setProp<int>("foo", 1);
    TEST_ASSERT(!qA.Match(&a1));
    a1.setProp<int>("foo", 2);
    TEST_ASSERT(qA.Match(&a1));

    a1.clearProp("foo");
    a1.setProp<double>("foo", 2);
    TEST_ASSERT(!qA.Match(&a1));
  }

  {
    QueryBond qA;
    qA.setQuery(makePropQuery<Bond, std::string>("foo", "bar"));
    Bond a1;
    TEST_ASSERT(!qA.Match(&a1));
    a1.setProp<std::string>("foo", "bar");
    TEST_ASSERT(qA.Match(&a1));
  }
}
Ejemplo n.º 2
0
void testHasPropWithDoubleValueMatch() {
  {
    QueryAtom qA;
    qA.setQuery(makePropQuery<Atom, double>("foo", 2));
    Atom a1(6);
    TEST_ASSERT(!qA.Match(&a1));
    a1.setProp<double>("foo", 1);
    TEST_ASSERT(!qA.Match(&a1));
    a1.setProp<double>("foo", 2);
    TEST_ASSERT(qA.Match(&a1));
  }
  {
    QueryBond qA;
    qA.setQuery(makePropQuery<Bond, double>("foo", 2));
    Bond a1;
    TEST_ASSERT(!qA.Match(&a1));
    a1.setProp<double>("foo", 1);
    TEST_ASSERT(!qA.Match(&a1));
    a1.setProp<double>("foo", 2);
    TEST_ASSERT(qA.Match(&a1));
  }
}
Ejemplo n.º 3
0
void testExtraBondQueries() {
  BOOST_LOG(rdErrorLog) << "---------------------- Test extra bond queries"
                        << std::endl;

  {  // stereo
    QueryBond qB;
    qB.setQuery(makeBondHasStereoQuery());
    Bond b1(Bond::DOUBLE);
    TEST_ASSERT(!qB.Match(&b1));
    b1.setStereo(Bond::STEREOE);
    TEST_ASSERT(qB.Match(&b1));
    b1.setStereo(Bond::STEREOANY);
    TEST_ASSERT(qB.Match(&b1));
    qB.getQuery()->setNegation(true);
    b1.setStereo(Bond::STEREONONE);
    TEST_ASSERT(qB.Match(&b1));
    b1.setStereo(Bond::STEREOE);
    TEST_ASSERT(!qB.Match(&b1));
    b1.setStereo(Bond::STEREOANY);
    TEST_ASSERT(!qB.Match(&b1));
  }
  BOOST_LOG(rdErrorLog) << "Done!" << std::endl;
}
Ejemplo n.º 4
0
QueryBond *HasPropQueryBond(const std::string &propname, bool negate) {
  QueryBond *res = new QueryBond();
  res->setQuery(makeHasPropQuery<Bond>(propname));
  if (negate) res->getQuery()->setNegation(true);
  return res;
}