Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
CandidateTest.cpp
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2016 The SKA organisation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "cheetah/data/test/CandidateTest.h"
25 #include "cheetah/data/Candidate.h"
26 
27 namespace ska {
28 namespace cheetah {
29 namespace data {
30 namespace test {
31 
32 
33 CandidateTest::CandidateTest() : ::testing::Test()
34 {
35 }
36 
37 CandidateTest::~CandidateTest()
38 {
39 }
40 
41 void CandidateTest::SetUp()
42 {
43 }
44 
45 void CandidateTest::TearDown()
46 {
47 }
48 
49 // test_input_data
50 // Sets the input data and re-read them
51 //
52 TEST_F(CandidateTest, test_input_data)
53 {
54  typedef Candidate<Cpu, double> CandidateType;
55 
56  typename CandidateType::SecPerSecType pdot_val = 0.000001;
57  typename CandidateType::Dm dm_val = 10. * parsecs_per_cube_cm;
58  std::size_t ident_val = 0;
60  //set the pulsar_candidate period to 1.24 ms
61  CandidateType::MsecTimeType period_val(0.00124 * boost::units::si::seconds);
62  // generate a pulsar_candidate with the specified period, pdot, dm, ident
63  CandidateType pulsar_cand(period_val, pdot_val, dm_val) ;
64  // real check
65  ASSERT_EQ(pdot_val, pulsar_cand.pdot());
66  ASSERT_EQ(period_val, pulsar_cand.period());
67  ASSERT_EQ(ident_val, pulsar_cand.ident());
68 }
69 
70 
71 // test_set_parameter
72 // Create a zero-sized Candidate object, sets data members and re-read them
73 //
74 TEST_F(CandidateTest, test_set_parameter)
75 {
76  typedef Candidate<Cpu, double> CandidateType;
77  typename CandidateType::SecPerSecType pdot_val = 0.000001;
78  typename CandidateType::Dm dm_val = 10. * parsecs_per_cube_cm;
79  std::size_t ident_val = 5;
81  //set the pulsar_candidate period to 1.24 ms
82  CandidateType::MsecTimeType period_val(0.00124 * boost::units::si::seconds);
83  CandidateType::MsecTimeType width_val(0.0002 * boost::units::si::seconds);
84  // create a pulsar_candidate with default values
85  CandidateType pulsar_cand ;
86 
87  // assign specific values
88  pulsar_cand.period(period_val);
89  pulsar_cand.pdot(pdot_val);
90  pulsar_cand.width(width_val);
91  pulsar_cand.dm(dm_val);
92  pulsar_cand.ident(ident_val);
93 
94  // real check
95  ASSERT_EQ(pdot_val, pulsar_cand.pdot());
96  ASSERT_EQ(period_val, pulsar_cand.period());
97  ASSERT_EQ(dm_val, pulsar_cand.dm());
98  ASSERT_EQ(ident_val, pulsar_cand.ident());
99  ASSERT_EQ(width_val, pulsar_cand.width());
100 }
101 
102 // test_candidate_copy
103 // Create a Candidate object, do the copy and compare the
104 // members values.
105 //
106 TEST_F(CandidateTest, test_candidate_copy)
107 {
108  typedef Candidate<Cpu, double> CandidateType;
109  typename CandidateType::SecPerSecType pdot_val = 0.000001;
110  typename CandidateType::Dm dm_val = 10. * parsecs_per_cube_cm;
111  double sigma_val = 20;
112  std::size_t ident_val = 5;
114  //set the pulsar_candidate period to 1.24 ms
115  CandidateType::MsecTimeType period_val(0.00124 * boost::units::si::seconds);
116  //set the pulsar_candidate pulse width
117  CandidateType::MsecTimeType width_val(0.0002 * boost::units::si::seconds);
118  // create a pulsar_candidate with configured values
119  CandidateType pulsar_cand(period_val, pdot_val, dm_val, width_val, sigma_val, ident_val);
120 
121  // do the copy
122  CandidateType pulsar_cand_copy(pulsar_cand);
123 
124  // compare the two candidates
125  ASSERT_EQ(pulsar_cand_copy.pdot(), pulsar_cand.pdot());
126  ASSERT_EQ(pulsar_cand_copy.period(), pulsar_cand.period());
127  ASSERT_EQ(pulsar_cand_copy.dm(), pulsar_cand.dm());
128  ASSERT_EQ(pulsar_cand_copy.ident(), pulsar_cand.ident());
129  ASSERT_EQ(pulsar_cand_copy.width(), pulsar_cand.width());
130  ASSERT_EQ(pulsar_cand_copy.sigma(), pulsar_cand.sigma());
131 }
132 } // namespace test
133 } // namespace data
134 } // namespace cheetah
135 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35