PeakTest.h 1.32 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
#ifndef MANTID_DATAOBJECTS_PEAKTEST_H_
#define MANTID_DATAOBJECTS_PEAKTEST_H_

#include <cxxtest/TestSuite.h>
#include "MantidKernel/Timer.h"
#include "MantidKernel/System.h"
#include <iostream>
#include <iomanip>

#include "MantidDataObjects/Peak.h"
11
#include "MantidTestHelpers/ComponentCreationHelper.h"
12
13

using namespace Mantid::DataObjects;
14
15
using namespace Mantid::Geometry;
using namespace Mantid::Kernel;
16
17
18
19

class PeakTest : public CxxTest::TestSuite
{
public:
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  /// Common instrument
  IInstrument_sptr inst;
  void setUp()
  {
    inst = ComponentCreationHelper::createTestInstrumentRectangular(5, 100);
  }

  void test_constructor()
  {
    // detector IDs start at 10000
    Peak p(inst, 10000, 2.0);
    TS_ASSERT_DELTA(p.getInitialEnergy(), 2.0, 1e-5)
    TS_ASSERT_DELTA(p.getFinalEnergy(), 2.0, 1e-5)
    TS_ASSERT_DELTA(p.getH(), 0.0, 1e-5)
    TS_ASSERT_DELTA(p.getK(), 0.0, 1e-5)
    TS_ASSERT_DELTA(p.getL(), 0.0, 1e-5)
    TS_ASSERT_EQUALS(p.getDetectorID(), 10000)
  }

  void test_badDetectorID_throws()
  {
    Peak p(inst, 10000, 2.0);
    TS_ASSERT_THROWS_ANYTHING( p.setDetectorID(7) );
  }
44

45
  void test_getBank_and_row()
46
  {
47
48
49
50
    Peak p(inst, 10000, 2.0);
    TS_ASSERT_EQUALS(p.getBankName(), "bank1")
    TS_ASSERT_EQUALS(p.getRow(), 0)
    TS_ASSERT_EQUALS(p.getCol(), 0)
51
52
53
54
55
56
57
58
  }


};


#endif /* MANTID_DATAOBJECTS_PEAKTEST_H_ */