Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
BeamFormerPacketTest.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/rcpt_low/test/BeamFormerPacketTest.h"
25 #include "cheetah/rcpt_low/BeamFormerPacket.h"
26 
27 
28 namespace ska {
29 namespace cheetah {
30 namespace rcpt_low {
31 namespace test {
32 
33 
34 BeamFormerPacketTest::BeamFormerPacketTest()
35  : ::testing::Test()
36 {
37 }
38 
39 BeamFormerPacketTest::~BeamFormerPacketTest()
40 {
41 }
42 
43 void BeamFormerPacketTest::SetUp()
44 {
45 }
46 
47 void BeamFormerPacketTest::TearDown()
48 {
49 }
50 
51 TEST_F(BeamFormerPacketTest, test_number_of_samples)
52 {
53  typedef PacketSample<int8_t> Sample;
55 }
56 
57 TEST_F(BeamFormerPacketTest, test_packet_count)
58 {
59  BeamFormerPacketLow packet;
60 
61  // min
62  packet.packet_count(0);
63  ASSERT_EQ(0x0000000000000000U, packet.packet_count());
64 
65  packet.packet_count(1);
66  ASSERT_EQ(0x0000000000000001U, packet.packet_count());
67 
68  // max
69  packet.packet_count(0xFFFFFFFFFFFFFFFF);
70  ASSERT_EQ(0xFFFFFFFFFFFFFFFFU, packet.packet_count());
71 
72  // > 6 bytes
73  packet.packet_count(0x0001000000000000);
74  ASSERT_EQ(0x0001000000000000U, packet.packet_count());
75 
76  // low end range
77  for(uint64_t i=2; i<0xFFFF; ++i) {
78  packet.packet_count(i);
79  ASSERT_EQ(i, packet.packet_count());
80  }
81 }
82 
83 TEST_F(BeamFormerPacketTest, test_insert)
84 {
85  BeamFormerPacketLow packet;
86  typedef PacketSample<int8_t> Sample;
87  packet.packet_count(1);
88  for(std::size_t i=0; i< packet.number_of_samples(); ++i) {
89  packet.insert(i, Sample(i, 2*i));
90  Sample const& sample = packet.sample(i);
91  ASSERT_EQ(static_cast<int8_t>(i),sample.real());
92  ASSERT_EQ(static_cast<int8_t>(i*2),sample.imag());
93  // check we didn't overwrite the header
94  ASSERT_EQ(0x0000000000000001U, packet.packet_count()) << i;
95  }
96 }
97 
98 } // namespace test
99 } // namespace rcpt_low
100 } // namespace cheetah
101 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35
static constexpr std::size_t number_of_samples()
the total number of samples in the rcpt payload
static constexpr std::size_t data_size()
the total size in bytes of the channel rcpt