astrotypes  0.0
SigProcFormatTest.cpp
Go to the documentation of this file.
1 /*
2  * MIT License
3  *
4  * Copyright (c) 2018 PulsarSearchSoft
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  */
26 #include <algorithm>
27 
28 
29 namespace pss {
30 namespace astrotypes {
31 namespace sigproc {
32 namespace test {
33 
34 
36  : ::testing::Test()
37 {
38 }
39 
41 {
42 }
43 
45 {
46 }
47 
49 {
50 }
51 
52 TEST_F(SigProcFormatTest, test_time_frequency_tf_data)
53 {
55  TestType formatter;
57  uint8_t n = 0;
58  std::generate(time_frequency.begin(), time_frequency.end(), [&]() { return ++n;} );
59 
60  // write out the data to the strea,
61  std::stringstream ss;
62  ss << formatter << time_frequency;
63 
64  // read in the data from the stream
66  ss >> TestType() >> time_frequency_2;
67 
68  ASSERT_EQ(time_frequency, time_frequency_2);
69 }
70 
71 TEST_F(SigProcFormatTest, test_time_frequency_ft_data)
72 {
74  TestType formatter;
76  uint8_t n = 0;
77  std::generate(frequency_time.begin(), frequency_time.end(), [&]() { return ++n;} );
78 
79  // write out the data to the strea,
80  std::stringstream ss;
81  ss << formatter << frequency_time;
82  // should also be able to handle Slices
83  auto slice = frequency_time.channel(10);
84  ss << formatter << slice << frequency_time.spectrum(6);
85 
86  // read in the data from the stream
87 
89  ss >> TestType() >> frequency_time_2;
90 
91  ASSERT_EQ(frequency_time, frequency_time_2);
92 }
93 
94 TEST_F(SigProcFormatTest, test_frequency_time_tf_data)
95 {
97  TestType formatter;
99  uint8_t n = 0;
100  std::generate(time_frequency.begin(), time_frequency.end(), [&]() { return n + 1;} );
101 
102  // write out the data to the strea,
103  std::stringstream ss;
104  ss << formatter << time_frequency;
105 
106  // read in the data from the stream
108  ss >> TestType() >> time_frequency_2;
109 
110  ASSERT_EQ(time_frequency, time_frequency_2);
111 }
112 
113 TEST_F(SigProcFormatTest, test_frequency_time_ft_data)
114 {
116  TestType formatter;
118  uint8_t n = 0;
119  std::generate(frequency_time.begin(), frequency_time.end(), [&]() { return n + 1;} );
120 
121  // write out the data to the strea,
122  std::stringstream ss;
123  ss << formatter << frequency_time;
124 
126  ss >> TestType() >> frequency_time_2;
127 
128  ASSERT_EQ(frequency_time, frequency_time_2);
129 }
130 
131 } // namespace test
132 } // namespace sigproc
133 } // namespace astrotypes
134 } // namespace pss
TEST_F(FileReaderTest, test_filterbank_file_tf_data)
A template class representing values associated with a time and frequecny such as Stokes values or vo...
A template class representing values associated with a time and frequecny such as Stokes values or vo...
iterator begin()
iterators acting over he entire data structure
Channel channel(std::size_t channel_number)
retrun a single channel across all time samples