EmpiricalFormula ef("C2"); const Element* e = db->getElement("C"); TEST_REAL_SIMILAR(ef.getAverageWeight(), e->getAverageWeight() * 2) END_SECTION START_SECTION(double getMonoWeight() const) EmpiricalFormula ef("C2"); const Element* e = db->getElement("C"); TEST_REAL_SIMILAR(ef.getMonoWeight(), e->getMonoWeight() * 2) TEST_REAL_SIMILAR(EmpiricalFormula("OH").getMonoWeight(), EmpiricalFormula("HO").getMonoWeight()); TEST_REAL_SIMILAR(EmpiricalFormula("").getMonoWeight(), 0.0) END_SECTION START_SECTION(String toString() const) EmpiricalFormula ef("C2H5"); String str = ef.toString(); TEST_EQUAL(String(str).hasSubstring("H5"), true) TEST_EQUAL(String(str).hasSubstring("C2"), true) END_SECTION START_SECTION([EXTRA](friend std::ostream& operator << (std::ostream&, const EmpiricalFormula&))) stringstream ss; EmpiricalFormula ef("C2H5"); ss << ef; TEST_EQUAL(String(ss.str()).hasSubstring("H5"), true); TEST_EQUAL(String(ss.str()).hasSubstring("C2"), true); END_SECTION START_SECTION(bool operator != (const EmpiricalFormula& rhs) const) EmpiricalFormula ef1("C2H5"), ef2(*e_ptr); TEST_EQUAL(ef1 != ef2, true)