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_ElectronNumber()
 {
     msftb = ScatteringFactorTable::createByType("electronnumber");
     TS_ASSERT_EQUALS(8.0, msftb->lookup("O"));
     TS_ASSERT_EQUALS(10.0, msftb->lookup("O2-"));
     TS_ASSERT_EQUALS(18.0, msftb->lookup("K+"));
     TS_ASSERT_EQUALS(18.0, msftb->lookup("K1+"));
     TS_ASSERT_EQUALS(68.0, msftb->lookup("W6+"));
     TS_ASSERT_THROWS(msftb->lookup("H4+"), invalid_argument);
     TS_ASSERT_THROWS(msftb->lookup("O0+"), invalid_argument);
 }
 void test_periodictableXray()
 {
     msftb = ScatteringFactorTable::createByType("X");
     TS_ASSERT_DELTA(1.0, msftb->lookup("H"), 0.01);
     TS_ASSERT_DELTA(8.0, msftb->lookup("O"), 0.01);
     TS_ASSERT_DELTA(10.0, msftb->lookup("O2-"), 0.01);
     TS_ASSERT_DELTA(11.0, msftb->lookup("Na"), 0.01);
     TS_ASSERT_DELTA(10.0, msftb->lookup("Na+"), 0.01);
     TS_ASSERT_EQUALS(msftb->lookup("Na+"), msftb->lookup("Na1+"));
     TS_ASSERT_DELTA(74.0, msftb->lookup("W"), 0.04);
     TS_ASSERT_DELTA(88.0, msftb->lookup("Ra"), 0.04);
     TS_ASSERT_EQUALS(msftb->lookup("Si"), msftb->lookup("Si0+"));
 }
void ScatteringFactorTableOwner::setScatteringFactorTable(
        ScatteringFactorTablePtr sft)
{
    ensureNonNull("ScatteringFactorTable", sft);
    if (msftable != sft)  sft->ticker().click();
    msftable = sft;
}
 void test_SFTNeutron()
 {
     msftb = ScatteringFactorTable::createByType("N");
     TS_ASSERT_DELTA(3.63, msftb->lookup("Na"), mtol);
     TS_ASSERT_DELTA(-3.37, msftb->lookup("Ti"), mtol);
     TS_ASSERT_DELTA(5.805, msftb->lookup("O"), mtol);
     TS_ASSERT_DELTA(6.6484, msftb->lookup("C"), mtol);
     TS_ASSERT_EQUALS(msftb->lookup("Na"), msftb->lookup("Na1+"));
     TS_ASSERT_EQUALS(msftb->lookup("Ge"), msftb->lookup("Ge0+"));
     TS_ASSERT_EQUALS("neutron", msftb->clone()->type());
 }
 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());
 }
 void test_SFTElectron()
 {
     using diffpy::mathutils::DOUBLE_MAX;
     msftb = ScatteringFactorTable::createByType("E");
     TS_ASSERT_EQUALS(DOUBLE_MAX, msftb->lookup("H"));
     TS_ASSERT_EQUALS(DOUBLE_MAX, msftb->lookup("Ra"));
     TS_ASSERT_DELTA(3.42104, msftb->lookup("Na", 1), 1e-5);
     TS_ASSERT_DELTA(1.34868, msftb->lookup("Na", 3), 1e-5);
     TS_ASSERT_DELTA(0.832158, msftb->lookup("Na", 5), 1e-5);
     TS_ASSERT_THROWS(msftb->lookup("H4+"), invalid_argument);
     TS_ASSERT_THROWS(msftb->lookup("H4+", 3), invalid_argument);
     TS_ASSERT_EQUALS("electron", msftb->clone()->type());
 }
 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_THROWS(msftb->lookup(""), invalid_argument);
     TS_ASSERT_DELTA(6.0, msftb->lookup("C"), 0.01);
     msftb->setCustomAs("C", "C", 6.3);
     TS_ASSERT_DELTA(6.3, msftb->lookup("C"), meps);
     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_DELTA(msftb->lookup("C", 2.5),
             msftb->lookup("Calias", 2.5), meps);
 }