本文整理汇总了C++中Bond::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Bond::isValid方法的具体用法?C++ Bond::isValid怎么用?C++ Bond::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bond
的用法示例。
在下文中一共展示了Bond::isValid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mol
TEST(RWMoleculeTest, BondType)
{
Molecule m;
RWMolecule mol(m);
typedef RWMolecule::AtomType Atom;
typedef RWMolecule::BondType Bond;
Atom a0 = mol.addAtom(1);
Atom a1 = mol.addAtom(2);
Atom a2 = mol.addAtom(3);
Bond b0 = mol.addBond(a0, a1);
Bond b1 = mol.addBond(1, 2);
Bond invalid = mol.addBond(0, 9);
EXPECT_TRUE(b0.isValid());
EXPECT_FALSE(invalid.isValid());
EXPECT_FALSE(Bond().isValid());
EXPECT_FALSE(Bond(&mol, 3).isValid());
EXPECT_EQ(&mol, b0.molecule());
EXPECT_EQ(0, b0.index());
EXPECT_EQ(a0, b0.atom1());
EXPECT_EQ(a2, b1.atom2());
b1.setOrder(2);
EXPECT_EQ(2, b1.order());
EXPECT_EQ(2, mol.bondOrder(1));
Bond other(&mol, 0);
EXPECT_EQ(b0, other);
EXPECT_NE(b1, other);
}
示例2:
TEST_F(MoleculeTest, addBond)
{
Molecule molecule;
EXPECT_EQ(molecule.bondCount(), static_cast<Index>(0));
Atom a = molecule.addAtom(1);
Atom b = molecule.addAtom(1);
Bond bondAB = molecule.addBond(a, b);
EXPECT_TRUE(bondAB.isValid());
EXPECT_EQ(bondAB.molecule(), &molecule);
EXPECT_EQ(molecule.bondCount(), static_cast<Index>(1));
EXPECT_EQ(bondAB.index(), static_cast<Index>(0));
EXPECT_EQ(bondAB.atom1().index(), a.index());
EXPECT_EQ(bondAB.atom2().index(), b.index());
EXPECT_EQ(bondAB.order(), static_cast<unsigned char>(1));
Atom c = molecule.addAtom(1);
Bond bondBC = molecule.addBond(b, c, 2);
EXPECT_TRUE(bondBC.isValid());
EXPECT_EQ(molecule.bondCount(), static_cast<Index>(2));
EXPECT_EQ(bondBC.index(), static_cast<Index>(1));
EXPECT_EQ(bondBC.order(), static_cast<unsigned char>(2));
// try to lookup nonexistant bond
Bond bond = molecule.bond(a, c);
EXPECT_FALSE(bond.isValid());
// try to lookup bond between a and b
bond = molecule.bond(a, b);
EXPECT_TRUE(bond.isValid());
EXPECT_EQ(bond.molecule(), &molecule);
EXPECT_EQ(bond.atom1().index(), a.index());
EXPECT_EQ(bond.atom2().index(), b.index());
// try to lookup bond between b and c by index
bond = molecule.bond(1);
EXPECT_TRUE(bond.isValid());
EXPECT_EQ(bond.molecule(), &molecule);
EXPECT_EQ(bond.atom1().index(), b.index());
EXPECT_EQ(bond.atom2().index(), c.index());
}