testCorsikaBlock.cc
Go to the documentation of this file.
1 
9 #include <io/CorsikaBlock.h>
10 #include <io/CorsikaIOException.h>
11 
12 #include <cppunit/extensions/HelperMacros.h>
13 
14 #include <tst/Verify.h>
15 
16 using io::Corsika::Block;
17 
18 
19 class TestCorsikaBlock : public CppUnit::TestFixture {
20 
27 
28 public:
29  // shared data for tests
31 
32  static const int kBlockSize = 1092;
33  static const int kBlockSizeParticleData = 1092 + 4*Block::kPadding;
34 
35  void
37  {
39  fId->SetID("TEST");
40  }
41 
42  void
44  {
45  delete fId;
46  fId = nullptr;
47  }
48 
49  void
51  {
52  CPPUNIT_ASSERT(fId->Is("TEST"));
53  CPPUNIT_ASSERT(fId->Is("TEST1")); // comparison only on 1st 4 letters
54  CPPUNIT_ASSERT(!fId->Is("TES"));
55  CPPUNIT_ASSERT(!fId->Is("ABCD"));
56  }
57 
58  void
60  {
62  tst::Expected();
63  bad.SetID("no");
64  }
65 
66  void
68  {
69  CPPUNIT_ASSERT(sizeof(io::Corsika::BlockID) == 4);
70  CPPUNIT_ASSERT(sizeof(io::Corsika::RunHeader) == kBlockSize);
71  CPPUNIT_ASSERT(sizeof(io::Corsika::RunTrailer) == kBlockSize);
72  CPPUNIT_ASSERT(sizeof(io::Corsika::EventHeader) == kBlockSize);
73  CPPUNIT_ASSERT(sizeof(io::Corsika::EventTrailer) == kBlockSize);
74  CPPUNIT_ASSERT(sizeof(Block::ParticleBlock) == kBlockSizeParticleData);
75  CPPUNIT_ASSERT(sizeof(Block::CherenkovBlock) == kBlockSizeParticleData);
76  }
77 
78  void
80  {
81  CPPUNIT_ASSERT(sizeof(Block) == kBlockSizeParticleData);
82  }
83 
84 };
85 
86 
event header struct for Corsika files
Definition: CorsikaBlock.h:182
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
run header struct for Corsika files
Definition: CorsikaBlock.h:136
Base for exceptions in the CORSIKA reader.
void Expected()
Print `Expected&#39; for expected failures.
Definition: Verify.h:85
run trailer struct for Corsika files
Definition: CorsikaBlock.h:286
BasicBlock< ParticleData, CherenkovData, kParticlesInBlock, 39 > Block
Definition: CorsikaBlock.h:443
CPPUNIT_TEST_EXCEPTION(TestIDThrow, io::CorsikaIOException)
CPPUNIT_TEST(TestID)
io::Corsika::BlockID * fId
CPPUNIT_TEST_SUITE(TestCorsikaBlock)
void SetID(const char *const theID)
set from c-string (for testing)
Definition: CorsikaBlock.cc:18
static const int kBlockSizeParticleData
static const int kBlockSize
This class represents a corsika block. It deals with all the different sub-types of blocks...
bool Is(const char *const theID) const
Compare ID&#39;s.
Definition: CorsikaBlock.cc:33
Sub-block used in CORSIKA files.
Definition: CorsikaBlock.h:112
event trailer struct for Corsika files
Definition: CorsikaBlock.h:300

, generated on Tue Sep 26 2023.