testParticlePropertiesFactory.cc
Go to the documentation of this file.
1 
13 // header for unit test testParticlePropertiesFactory
14 #include <utl/ParticlePropertiesFactory.h>
15 #include <utl/ParticleProperties.h>
16 #include <utl/NucleusProperties.h>
17 #include <utl/Particle.h>
18 #include <utl/PhysicalConstants.h>
19 #include <string>
20 
21 #include <tst/Verify.h>
22 #include <cppunit/extensions/HelperMacros.h>
23 
24 using namespace utl;
25 using namespace tst;
26 using std::string;
27 
28 
33  : public CppUnit::TestFixture
34 {
35  CPPUNIT_TEST_SUITE(testParticlePropertiesFactory);
36  CPPUNIT_TEST(testCreate);
37  // CPPUNIT_TEST(testFN);
38  // CPPUNIT_TEST_EXCEPTION(testFN, anException);
39  CPPUNIT_TEST_SUITE_END();
40 public:
41  // shared data for tests
42 
43  void setUp() { }
44 
45  void tearDown() { }
46 
47  void testCreate()
48  {
51  CPPUNIT_ASSERT(Verify<Equal>(pp->GetType(), int(Particle::eElectron)));
52  CPPUNIT_ASSERT(Verify<Equal>(pp->GetMass(), kElectronMass));
53 
55  CPPUNIT_ASSERT(Verify<Equal>(pp->GetType(), int(Particle::eAntiNeutron)));
56  CPPUNIT_ASSERT(Verify<Equal>(pp->GetName(), string("anti_neutron")));
57  CPPUNIT_ASSERT(Verify<Equal>(pp->GetMass(), kNeutronMass));
58 
60  CPPUNIT_ASSERT(Verify<Equal>(pp->GetType(), int(Particle::eIron)));
61  CPPUNIT_ASSERT(Verify<Equal>(pp->GetName(), string("Fe 56")));
62  // reduce precision due to binding, to match imprecise mass formula.
63  CPPUNIT_ASSERT(Verify<CloseTo>(pp->GetMass(), 55.405*kProtonMass, 0.011));
64 
65  // the first unregistered nucleus. We have names up to Fe.
66  pp =
68  CPPUNIT_ASSERT(Verify<Equal>(pp->GetType(), 1000027065));
69  CPPUNIT_ASSERT(Verify<Equal>(pp->GetName(), string("N(27) 65")));
70  // reduce precision due to binding, to match imprecise mass formula.
71  CPPUNIT_ASSERT(Verify<CloseTo>(pp->GetMass(), 65*kProtonMass, 0.01));
72  }
73 
74 };
75 
77 
78 
79 // Configure (x)emacs for this file ...
80 // Local Variables:
81 // mode:c++
82 // compile-command: "make -C .. -k testParticles && ../testParticles"
83 // End:
constexpr double kProtonMass
constexpr double kElectronMass
boost::shared_ptr< const VParticleProperties > ParticlePropertiesPtr
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
constexpr double kNeutronMass
static int TypeCode(const unsigned int charge, const unsigned int atomicNumber)
Calculate the particle type code from Z and A.
static ObjectPtrType Create(const IdentifierType &id)
Create an object (0-argument constructor)

, generated on Tue Sep 26 2023.