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/test/BeamFormerPacketTest.h"
25 #include "cheetah/rcpt/BeamFormerPacket.h"
26 
27 
28 namespace ska {
29 namespace cheetah {
30 namespace rcpt {
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  ASSERT_EQ(BeamFormerPacketMid::payload_size()/sizeof(Sample), BeamFormerPacketMid::number_of_samples());
54 }
55 
56 TEST_F(BeamFormerPacketTest, test_packet_count)
57 {
58  BeamFormerPacketMid packet;
59 
60  // min
61  packet.packet_count(0);
62  ASSERT_EQ(0x0000000000000000U, packet.packet_count());
63 
64  packet.packet_count(1);
65  ASSERT_EQ(0x0000000000000001U, packet.packet_count());
66 
67  // max
68  packet.packet_count(0xFFFFFFFFFFFFFFFF);
69  ASSERT_EQ(0xFFFFFFFFFFFFFFFFU, packet.packet_count());
70 
71  // > 6 bytes
72  packet.packet_count(0x0001000000000000);
73  ASSERT_EQ(0x0001000000000000U, packet.packet_count());
74 
75  // low end range
76  for(uint64_t i=2; i<0xFFFF; ++i) {
77  packet.packet_count(i);
78  ASSERT_EQ(i, packet.packet_count());
79  }
80 }
81 
82 TEST_F(BeamFormerPacketTest, test_insert)
83 {
84  BeamFormerPacketMid packet;
85  packet.packet_count(1);
86  for(std::size_t i=0; i< packet.number_of_samples(); ++i) {
87  packet.insert(i, Sample(i, 2*i, 3*i, 4*i));
88  Sample const& sample = packet.sample(i);
89  ASSERT_EQ(static_cast<short>(i),sample.xx());
90  ASSERT_EQ(static_cast<short>(i*2),sample.yy());
91  ASSERT_EQ(static_cast<short>(i*3),sample.xy().first);
92  ASSERT_EQ(static_cast<short>(i*4),sample.xy().second);
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
100 } // namespace cheetah
101 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35