void test_ticker() { using diffpy::eventticker::EventTicker; msftb = ScatteringFactorTable::createByType("X"); EventTicker e0 = msftb->ticker(); TS_ASSERT_EQUALS(e0, msftb->clone()->ticker()); TS_ASSERT_EQUALS(e0, dumpandload(msftb)->ticker()); msftb->setCustomAs("C", "C", 6.1); TS_ASSERT_LESS_THAN(e0, msftb->ticker()); }
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()); }
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)); }
void test_serialization() { ScatteringFactorTablePtr sftb1; msftb = ScatteringFactorTable::createByType("electronnumber"); msftb->setCustomAs("H", "H", 1.23); sftb1 = dumpandload(msftb); TS_ASSERT_EQUALS(string("electronnumber"), sftb1->type()); TS_ASSERT_EQUALS(1.23, sftb1->lookup("H")); TS_ASSERT_EQUALS(1u, sftb1->getCustomSymbols().size()); sftb1 = dumpandload(ScatteringFactorTable::createByType("N")); TS_ASSERT_EQUALS(string("periodictableneutron"), sftb1->type()); sftb1 = dumpandload(ScatteringFactorTable::createByType("X")); TS_ASSERT_EQUALS(string("periodictablexray"), sftb1->type()); }