Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
ConfigurableChannelMaskTest.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/channel_mask/test/ConfigurableChannelMaskTest.h"
25 #include "cheetah/channel_mask/ConfigurableChannelMask.h"
26 
27 
28 namespace ska {
29 namespace cheetah {
30 namespace channel_mask {
31 namespace test {
32 
33 
34 ConfigurableChannelMaskTest::ConfigurableChannelMaskTest()
35  : ::testing::Test()
36 {
37 }
38 
39 ConfigurableChannelMaskTest::~ConfigurableChannelMaskTest()
40 {
41 }
42 
43 void ConfigurableChannelMaskTest::SetUp()
44 {
45 }
46 
47 void ConfigurableChannelMaskTest::TearDown()
48 {
49 }
50 
51 TEST_F(ConfigurableChannelMaskTest, test_mask_unset_type)
52 {
53  typedef uint8_t NumericalRep;
54  typedef data::TimeFrequency<Cpu, uint8_t> DataType;
55  typedef data::DimensionSpan<data::Frequency> SpanType;
56 
57  // configuration
58  ConfigurableChannelMaskConfig<NumericalRep> config;
59  config.policy_name() = "";
60  config.flagged_channels().insert(SpanType(data::DimensionIndex<data::Frequency>(1), data::DimensionSize<data::Frequency>(1)));
61 
62  // data
63  DataType data(data::DimensionSize<data::Frequency>(10)
64  , data::DimensionSize<data::Time>(6));
65  std::fill(data.begin(), data.end(), std::numeric_limits<NumericalRep>::min());
66 
67  ConfigurableChannelMask<NumericalRep> mask(config);
68  mask(data);
69  for(auto const& sample : data) {
70  ASSERT_EQ(std::numeric_limits<NumericalRep>::min(), sample);
71  }
72 }
73 
74 TEST_F(ConfigurableChannelMaskTest, test_mask_replace_constant_type)
75 {
76  typedef uint8_t NumericalRep;
77  typedef data::TimeFrequency<Cpu, uint8_t> DataType;
78  typedef data::DimensionSpan<data::Frequency> SpanType;
79 
80  // configuration
81  ConfigurableChannelMaskConfig<NumericalRep> config;
82  config.policy_name() = "replace_constant";
83 
84  config.flagged_channels().insert(SpanType(data::DimensionIndex<data::Frequency>(1), data::DimensionSize<data::Frequency>(1)));
85 
86  // data
87  DataType data(data::DimensionSize<data::Frequency>(10)
88  , data::DimensionSize<data::Time>(6));
89  std::fill(data.begin(), data.end(), std::numeric_limits<NumericalRep>::min());
90 
91  ConfigurableChannelMask<NumericalRep> mask(config);
92  mask(data);
93  for(auto const& sample : data.channel(0)) {
94  ASSERT_EQ(std::numeric_limits<NumericalRep>::min(), sample);
95  }
96  for(auto const& sample : data.channel(1)) {
97  ASSERT_NE(std::numeric_limits<NumericalRep>::min(), sample);
98  }
99 }
100 
101 } // namespace test
102 } // namespace channel_mask
103 } // namespace cheetah
104 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35