astrotypes  0.0
FileReaderTest.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  */
24 #include "../FileReaderTest.h"
25 #include "../SigProcTestFile.h"
28 
29 
30 namespace pss {
31 namespace astrotypes {
32 namespace sigproc {
33 namespace test {
34 
35 
37  : ::testing::Test()
38 {
39 }
40 
42 {
43 }
44 
46 {
47 }
48 
50 {
51 }
52 
53 TEST_F(FileReaderTest, test_filterbank_file_tf_data)
54 {
55  SigProcFilterBankTestFile test_file;
56  TimeFrequency<uint8_t> tf_data;
57  sigproc::FileReader<> reader(test_file.file());
58  ASSERT_EQ(test_file.number_of_ifs(), reader.header().number_of_ifs());
59  reader >> ResizeAdapter<units::Time, units::Frequency>() >> tf_data;
60 
61  ASSERT_EQ(test_file.number_of_channels(), tf_data.dimension<astrotypes::units::Frequency>());
62  ASSERT_EQ(test_file.number_of_spectra(), tf_data.dimension<astrotypes::units::Time>());
63 }
64 
65 TEST_F(FileReaderTest, test_filterbank_file_ft_data)
66 {
67  SigProcFilterBankTestFile test_file;
68  FrequencyTime<uint8_t> ft_data;
69  sigproc::FileReader<> reader(test_file.file());
70  ASSERT_EQ(test_file.number_of_ifs(), reader.header().number_of_ifs());
71 
72  reader >> ResizeAdapter<units::Time, units::Frequency>() >> ft_data;
73  ASSERT_EQ(test_file.number_of_channels(), ft_data.dimension<astrotypes::units::Frequency>());
74  ASSERT_EQ(test_file.number_of_spectra(), ft_data.dimension<astrotypes::units::Time>());
75 }
76 
77 TEST_F(FileReaderTest, test_filterbank_file_resize_time_tf_data)
78 {
79  SigProcFilterBankTestFile test_file;
81  sigproc::FileReader<> reader(test_file.file());
82  reader >> ResizeAdapter<units::Time>() >> tf_data;
83 
84  ASSERT_EQ(0U, tf_data.dimension<astrotypes::units::Frequency>());
85  ASSERT_EQ(test_file.number_of_spectra(), tf_data.dimension<astrotypes::units::Time>());
86 }
87 
88 TEST_F(FileReaderTest, test_filterbank_file_resize_frequency_tf_data)
89 {
90  SigProcFilterBankTestFile test_file;
92  sigproc::FileReader<> reader(test_file.file());
93  reader >> ResizeAdapter<units::Frequency>() >> tf_data;
94 
95  ASSERT_EQ(test_file.number_of_spectra(), tf_data.dimension<astrotypes::units::Time>()); // doesn't get overwritten
96  ASSERT_EQ(test_file.number_of_channels(), tf_data.dimension<astrotypes::units::Frequency>());
97 }
98 
99 } // namespace test
100 } // namespace sigproc
101 } // namespace astrotypes
102 } // namespace pss
TEST_F(FileReaderTest, test_filterbank_file_tf_data)
boost::units::time_dimension Time
Definition: Time.h:42
Read in a sigproc file.
Definition: FileReader.h:41
DimensionSize< units::Frequency > number_of_channels() const
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...
DimensionSize< units::Time > number_of_spectra() const
std::enable_if< std::is_same< Dim, units::Time >::value, DimensionSize< units::Time > >::type dimension() const
boost::units::frequency_dimension Frequency
Definition: Frequency.h:45