Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
ReplaceConstantPolicyTest.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/ReplaceConstantPolicyTest.h"
25 #include "cheetah/channel_mask/ReplaceConstantPolicy.h"
26 #include "cheetah/channel_mask/ReplaceConstantPolicyConfig.h"
27 #include "cheetah/data/TimeFrequency.h"
28 
29 
30 namespace ska {
31 namespace cheetah {
32 namespace channel_mask {
33 namespace test {
34 
35 
36 ReplaceConstantPolicyTest::ReplaceConstantPolicyTest()
37  : ::testing::Test()
38 {
39 }
40 
41 ReplaceConstantPolicyTest::~ReplaceConstantPolicyTest()
42 {
43 }
44 
45 void ReplaceConstantPolicyTest::SetUp()
46 {
47 }
48 
49 void ReplaceConstantPolicyTest::TearDown()
50 {
51 }
52 
53 template<typename NumericalRep>
54 void test_policy() {
55  typedef data::TimeFrequency<Cpu, NumericalRep> DataType;
56  ReplaceConstantPolicyConfig<uint8_t> config;
57  ReplaceConstantPolicy<uint8_t> policy(config);
58 
59  {
60  // entire chunk
61  DataType data( data::DimensionSize<data::Frequency>(10)
62  , data::DimensionSize<data::Time>(6));
63  std::fill(data.begin(), data.end(), 0);
64  policy(data);
65  for(auto const& sample : data) {
66  ASSERT_EQ(sample, config.value());
67  }
68  }
69 
70  {
71  // single channel
72  DataType data(data::DimensionSize<data::Frequency>(10)
73  , data::DimensionSize<data::Time>(6));
74  std::fill(data.begin(), data.end(), 0);
75 
76  auto channel=data.channel(1);
77  for(auto const& sample : channel)
78  {
79  ASSERT_NE(sample, config.value());
80  }
81  policy(channel);
82  for(auto const& sample : channel)
83  {
84  ASSERT_EQ(sample, config.value());
85  }
86  }
87 
88  {
89  // a slice within the chunk
90  DataType data(data::DimensionSize<data::Frequency>(10)
91  , data::DimensionSize<data::Time>(6));
92  std::fill(data.begin(), data.end(), 0);
93 
94  auto slice=data.slice(data::DimensionSpan<data::Frequency>(data::DimensionIndex<data::Frequency>(2), data::DimensionIndex<data::Frequency>(4)));
95  for(auto const& sample : slice)
96  {
97  ASSERT_NE(sample, config.value());
98  }
99  policy(slice);
100  for(auto const& sample : slice)
101  {
102  ASSERT_EQ(sample, config.value());
103  }
104  }
105 }
106 
107 TEST_F(ReplaceConstantPolicyTest, test_policy_uint8_t)
108 {
109  test_policy<uint8_t>();
110 }
111 
112 } // namespace test
113 } // namespace channel_mask
114 } // namespace cheetah
115 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35