コード例 #1
0
 void test_getCustomSymbols()
 {
     msftb = ScatteringFactorTable::createByType("X");
     TS_ASSERT(msftb->getCustomSymbols().empty());
     msftb->setCustomAs("C", "C", 6.1);
     TS_ASSERT_EQUALS(1u, msftb->getCustomSymbols().size());
     TS_ASSERT_EQUALS(1u, msftb->getCustomSymbols().count("C"));
     msftb->setCustomAs("C", "C", 6.3);
     TS_ASSERT_EQUALS(1u, msftb->getCustomSymbols().size());
     TS_ASSERT_EQUALS(1u, msftb->getCustomSymbols().count("C"));
     TS_ASSERT_DELTA(6.3, msftb->lookup("C"), meps);
     ScatteringFactorTablePtr sftb1 = msftb->clone();
     msftb->resetCustom("C");
     TS_ASSERT(msftb->getCustomSymbols().empty());
     TS_ASSERT_EQUALS(1u, sftb1->getCustomSymbols().size());
     TS_ASSERT_EQUALS(1u, sftb1->getCustomSymbols().count("C"));
     TS_ASSERT_DELTA(6.3, sftb1->lookup("C"), meps);
     sftb1->resetAll();
     TS_ASSERT(msftb->getCustomSymbols().empty());
 }
コード例 #2
0
 void test_setCustomAs()
 {
     msftb = ScatteringFactorTable::createByType("X");
     TS_ASSERT_DELTA(6.0, msftb->lookup("C"), 0.01);
     msftb->setCustomAs("C", "C", 6.3);
     TS_ASSERT_EQUALS(6.3, msftb->lookup("C"));
     msftb->setCustomAs("C", "C", 6.4);
     TS_ASSERT_DELTA(6.4, msftb->lookup("C"), meps);
     TS_ASSERT_THROWS(msftb->lookup("Ccustom"), invalid_argument);
     msftb->setCustomAs("Ccustom", "C", 6.5);
     TS_ASSERT_DELTA(6.5, msftb->lookup("Ccustom"), meps);
     msftb->resetCustom("C");
     TS_ASSERT_DELTA(6.5, msftb->lookup("Ccustom"), meps);
     TS_ASSERT_DELTA(6.0, msftb->lookup("C"), 0.01);
     msftb->resetAll();
     TS_ASSERT_THROWS(msftb->lookup("Ccustom"), invalid_argument);
     TS_ASSERT_DELTA(6.0, msftb->lookup("C"), 0.01);
     msftb->setCustomAs("Calias", "C");
     TS_ASSERT_EQUALS(msftb->lookup("C", 0),
             msftb->lookup("Calias", 0));
     TS_ASSERT_EQUALS(msftb->lookup("C", 2.5),
             msftb->lookup("Calias", 2.5));
 }