Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
MultiBeamConfigTest.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/pipeline/test/MultiBeamConfigTest.h"
25 #include "cheetah/pipeline/MultiBeamConfig.h"
26 #include <boost/property_tree/xml_parser.hpp>
27 
28 namespace ska {
29 namespace cheetah {
30 namespace pipeline {
31 namespace test {
32 
33 
34 MultiBeamConfigTest::MultiBeamConfigTest()
35  : ::testing::Test()
36 {
37 }
38 
39 MultiBeamConfigTest::~MultiBeamConfigTest()
40 {
41 }
42 
43 void MultiBeamConfigTest::SetUp()
44 {
45 }
46 
47 void MultiBeamConfigTest::TearDown()
48 {
49 }
50 
51 TEST_F(MultiBeamConfigTest, test_multiple_beam_config_parse)
52 {
53  MultiBeamConfig<uint8_t> mb_config;
54  std::vector<std::string> sigproc_filenames = { "sigproc_1.fil", "sigproc_2.fil" };
55 
56  // Make a property tree
57  boost::property_tree::ptree pt_root;
58  boost::property_tree::ptree pt_beams;
59 
60  boost::property_tree::ptree pt_beam_1;
61  boost::property_tree::ptree pt_beam_2;
62  boost::property_tree::ptree source_1;
63  boost::property_tree::ptree source_2;
64  boost::property_tree::ptree source_3;
65  source_3.put<std::string>("id","source_3_id");
66 
67  // Sigproc files
68 
69  boost::property_tree::ptree pt_sigproc_1;
70  pt_sigproc_1.put<std::string>("file",sigproc_filenames[0]);
71  pt_sigproc_1.put<std::string>("id","sigproc_1_id");
72  boost::property_tree::ptree pt_sigproc_2;
73  pt_sigproc_2.put<std::string>("file",sigproc_filenames[1]);
74  pt_sigproc_2.put<std::string>("id","sigproc_2_id");
75  source_1.add_child("sigproc",pt_sigproc_1);
76  source_2.add_child("sigproc", pt_sigproc_2);
77 
78  pt_beam_1.put<std::string>("active", "true");
79  pt_beam_2.put<std::string>("active", "true");
80  pt_beam_1.add_child("source", source_1);
81  pt_beam_2.add_child("source", source_2);
82  pt_beams.add_child("beam", pt_beam_1);
83  pt_beams.add_child("beam", pt_beam_2);
84  pt_root.put_child("beams", pt_beams);
85 
86  //boost::property_tree::xml_parser::write_xml(std::cout, pt_root);
87 
88  boost::program_options::variables_map vm;
89  mb_config.parse_property_tree(pt_beams, vm);
90  boost::program_options::notify(vm);
91 
92  auto it = mb_config.beams();
93  unsigned count=0;
94  while (it != mb_config.beams_end())
95  {
96  auto const& beam_config = *it;
97  ASSERT_EQ(1U, beam_config.sigproc_config().sigproc_files().size());
98  ASSERT_EQ(beam_config.sigproc_config().sigproc_files()[0], sigproc_filenames[count]);
99  ++it;
100  ++count;
101  }
102  ASSERT_EQ(count, 2U);
103 }
104 
105 } // namespace test
106 } // namespace pipeline
107 } // namespace cheetah
108 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35