Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
OcldFileStreamerTest.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/Ocld.h"
25 #include "cheetah/exporters/test/OcldFileStreamerTest.h"
26 #include "cheetah/exporters/OcldFileStreamer.h"
27 #include "panda/test/TestDir.h"
28 
29 
30 namespace ska {
31 namespace cheetah {
32 namespace exporters {
33 namespace test {
34 
35 
36 OcldFileStreamerTest::OcldFileStreamerTest()
37  : ::testing::Test()
38 {
39 }
40 
41 OcldFileStreamerTest::~OcldFileStreamerTest()
42 {
43 }
44 
45 void OcldFileStreamerTest::SetUp()
46 {
47 }
48 
49 void OcldFileStreamerTest::TearDown()
50 {
51 }
52 
53 TEST_F(OcldFileStreamerTest, test_write_out)
54 {
55  panda::test::TestDir tmp_dir;
56  ASSERT_NO_THROW(tmp_dir.create());
57 
58  data::Ocld ocld;
59  typedef data::Ocld::CandidateType Candidate;
60  typename Candidate::TimeType pulse_period(100.0 * boost::units::si::milli * boost::units::si::seconds);
61  typename Candidate::SecPerSecType pulse_pdot(0.0);
62  typename Candidate::Dm dm(40.0 * data::parsec_per_cube_cm);
63  typename Candidate::MsecTimeType pulse_width(1.0 * boost::units::si::milli * boost::units::si::seconds);
64  ocld.push_back(Candidate(pulse_period, pulse_pdot, dm, pulse_width, 1.0));
65  OcldFileStreamerConfig config;
66  config.dir(tmp_dir.dir_name());
67  OcldFileStreamer writer(config);
68  writer << ocld;
69  sync();
70  auto it = boost::filesystem::directory_iterator(tmp_dir.path());
71  boost::filesystem::path file = *it;
72  ASSERT_EQ(file.extension().string(), ".ocld");
73  ASSERT_EQ(1U, std::distance(it, boost::filesystem::directory_iterator()));
74 }
75 
76 } // namespace test
77 } // namespace exporters
78 } // namespace cheetah
79 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35