2017-07-10 21:59:18 +00:00
|
|
|
/*!
|
|
|
|
* \file adapter_test.cc
|
|
|
|
* \brief This file implements tests for the DataTypeAdapter block
|
|
|
|
* \author Carles Fernandez-Prades, 2017. cfernandez(at)cttc.es
|
|
|
|
*
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2017-07-10 21:59:18 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2017-07-10 21:59:18 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2017-07-10 21:59:18 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2017-07-10 21:59:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "byte_to_short.h"
|
|
|
|
#include "ibyte_to_cbyte.h"
|
|
|
|
#include "ibyte_to_complex.h"
|
|
|
|
#include "ibyte_to_cshort.h"
|
2018-12-09 21:00:09 +00:00
|
|
|
#include "in_memory_configuration.h"
|
2017-07-10 21:59:18 +00:00
|
|
|
#include "ishort_to_complex.h"
|
|
|
|
#include "ishort_to_cshort.h"
|
2018-12-09 21:00:09 +00:00
|
|
|
#include <gnuradio/blocks/file_source.h>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <volk_gnsssdr/volk_gnsssdr.h>
|
|
|
|
#include <algorithm>
|
2019-07-14 12:09:12 +00:00
|
|
|
#include <array>
|
2018-12-09 21:00:09 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <fstream>
|
|
|
|
#include <iterator>
|
|
|
|
#include <system_error>
|
|
|
|
#include <vector>
|
2017-07-10 21:59:18 +00:00
|
|
|
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
class DataTypeAdapter : public ::testing::Test
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DataTypeAdapter();
|
2020-12-30 20:49:29 +00:00
|
|
|
int run_byte_to_short_block() const;
|
|
|
|
int run_ibyte_to_cbyte_block() const;
|
|
|
|
int run_ibyte_to_complex_block() const;
|
|
|
|
int run_ibyte_to_cshort_block() const;
|
|
|
|
int run_ishort_to_complex_block() const;
|
|
|
|
int run_ishort_to_cshort_block() const;
|
2017-07-10 21:59:18 +00:00
|
|
|
std::string file_name_input;
|
|
|
|
std::string file_name_output;
|
|
|
|
std::vector<int8_t> input_data_bytes;
|
2018-12-08 17:49:31 +00:00
|
|
|
std::vector<int16_t> input_data_shorts;
|
2017-07-10 21:59:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
DataTypeAdapter::DataTypeAdapter()
|
2021-12-17 16:40:17 +00:00
|
|
|
: file_name_input("adapter_test_input.dat"),
|
|
|
|
file_name_output("adapter_test_output.dat")
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
2019-07-14 12:09:12 +00:00
|
|
|
std::array<int8_t, 6> input_bytes{2, 23, -1, 127, -127, 0};
|
|
|
|
std::array<int16_t, 8> input_shorts{2, 23, -1, 127, -127, 0, 255, 255};
|
2017-07-10 21:59:18 +00:00
|
|
|
|
2019-08-24 15:34:12 +00:00
|
|
|
const std::vector<int8_t> input_data_bytes_(input_bytes.data(), input_bytes.data() + input_bytes.size() / sizeof(int8_t));
|
2017-07-10 21:59:18 +00:00
|
|
|
input_data_bytes = input_data_bytes_;
|
|
|
|
|
2019-08-24 15:34:12 +00:00
|
|
|
const std::vector<int16_t> input_data_shorts_(input_shorts.data(), input_shorts.data() + input_shorts.size() / sizeof(int16_t));
|
2017-07-10 21:59:18 +00:00
|
|
|
input_data_shorts = input_data_shorts_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-30 20:49:29 +00:00
|
|
|
int DataTypeAdapter::run_ishort_to_cshort_block() const
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ConfigurationInterface> config = std::make_shared<InMemoryConfiguration>();
|
|
|
|
config->set_property("Test.implementation", "Ishort_To_Cshort");
|
|
|
|
std::shared_ptr<IshortToCshort> ishort_to_cshort = std::make_shared<IshortToCshort>(config.get(), "Test", 1, 1);
|
|
|
|
std::string expected_implementation = "Ishort_To_Cshort";
|
|
|
|
EXPECT_EQ(expected_implementation, ishort_to_cshort->implementation());
|
|
|
|
|
|
|
|
std::ofstream ofs(file_name_input.c_str(), std::ofstream::binary);
|
2018-12-08 17:49:31 +00:00
|
|
|
for (int16_t aux : input_data_shorts)
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
2018-12-08 17:49:31 +00:00
|
|
|
ofs.write(reinterpret_cast<const char*>(&aux), sizeof(int16_t));
|
2017-07-10 21:59:18 +00:00
|
|
|
}
|
|
|
|
ofs.close();
|
|
|
|
|
|
|
|
auto top_block = gr::make_top_block("Ishort_To_Cshort test");
|
2018-12-08 17:49:31 +00:00
|
|
|
auto file_source = gr::blocks::file_source::make(sizeof(int16_t), file_name_input.c_str());
|
2017-07-10 21:59:18 +00:00
|
|
|
auto sink = gr::blocks::file_sink::make(sizeof(lv_16sc_t), file_name_output.c_str(), false);
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_NO_THROW({
|
2017-07-10 21:59:18 +00:00
|
|
|
top_block->connect(file_source, 0, ishort_to_cshort->get_left_block(), 0);
|
|
|
|
top_block->connect(ishort_to_cshort->get_right_block(), 0, sink, 0);
|
|
|
|
top_block->run();
|
|
|
|
});
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-30 20:49:29 +00:00
|
|
|
int DataTypeAdapter::run_ishort_to_complex_block() const
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ConfigurationInterface> config = std::make_shared<InMemoryConfiguration>();
|
|
|
|
config->set_property("Test.implementation", "Ishort_To_Complex");
|
|
|
|
std::shared_ptr<IshortToComplex> ishort_to_complex = std::make_shared<IshortToComplex>(config.get(), "Test", 1, 1);
|
|
|
|
std::string expected_implementation = "Ishort_To_Complex";
|
|
|
|
EXPECT_EQ(expected_implementation, ishort_to_complex->implementation());
|
|
|
|
|
|
|
|
std::ofstream ofs(file_name_input.c_str(), std::ofstream::binary);
|
2018-12-08 17:49:31 +00:00
|
|
|
for (int16_t aux : input_data_shorts)
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
2018-12-08 17:49:31 +00:00
|
|
|
ofs.write(reinterpret_cast<const char*>(&aux), sizeof(int16_t));
|
2017-07-10 21:59:18 +00:00
|
|
|
}
|
|
|
|
ofs.close();
|
|
|
|
|
|
|
|
auto top_block = gr::make_top_block("Ishort_To_Complex test");
|
2018-12-08 17:49:31 +00:00
|
|
|
auto file_source = gr::blocks::file_source::make(sizeof(int16_t), file_name_input.c_str());
|
2017-07-10 21:59:18 +00:00
|
|
|
auto sink = gr::blocks::file_sink::make(sizeof(gr_complex), file_name_output.c_str(), false);
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_NO_THROW({
|
2017-07-10 21:59:18 +00:00
|
|
|
top_block->connect(file_source, 0, ishort_to_complex->get_left_block(), 0);
|
|
|
|
top_block->connect(ishort_to_complex->get_right_block(), 0, sink, 0);
|
|
|
|
top_block->run();
|
|
|
|
});
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-30 20:49:29 +00:00
|
|
|
int DataTypeAdapter::run_ibyte_to_cshort_block() const
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ConfigurationInterface> config = std::make_shared<InMemoryConfiguration>();
|
|
|
|
config->set_property("Test.implementation", "Ibyte_To_Cshort");
|
|
|
|
std::shared_ptr<IbyteToCshort> ibyte_to_cshort = std::make_shared<IbyteToCshort>(config.get(), "Test", 1, 1);
|
|
|
|
std::string expected_implementation = "Ibyte_To_Cshort";
|
|
|
|
EXPECT_EQ(expected_implementation, ibyte_to_cshort->implementation());
|
|
|
|
|
|
|
|
std::ofstream ofs(file_name_input.c_str());
|
2018-12-03 17:03:25 +00:00
|
|
|
for (signed char input_data_byte : input_data_bytes)
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
2018-12-03 17:03:25 +00:00
|
|
|
ofs << input_data_byte;
|
2017-07-10 21:59:18 +00:00
|
|
|
}
|
|
|
|
ofs.close();
|
|
|
|
|
|
|
|
auto top_block = gr::make_top_block("Ibyte_To_Cshort test");
|
|
|
|
auto file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name_input.c_str());
|
|
|
|
auto sink = gr::blocks::file_sink::make(sizeof(lv_16sc_t), file_name_output.c_str(), false);
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_NO_THROW({
|
2017-07-10 21:59:18 +00:00
|
|
|
top_block->connect(file_source, 0, ibyte_to_cshort->get_left_block(), 0);
|
|
|
|
top_block->connect(ibyte_to_cshort->get_right_block(), 0, sink, 0);
|
|
|
|
top_block->run();
|
|
|
|
});
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-30 20:49:29 +00:00
|
|
|
int DataTypeAdapter::run_ibyte_to_complex_block() const
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ConfigurationInterface> config = std::make_shared<InMemoryConfiguration>();
|
|
|
|
config->set_property("Test.implementation", "Ibyte_To_Complex");
|
|
|
|
std::shared_ptr<IbyteToComplex> ibyte_to_complex = std::make_shared<IbyteToComplex>(config.get(), "Test", 1, 1);
|
|
|
|
std::string expected_implementation = "Ibyte_To_Complex";
|
|
|
|
EXPECT_EQ(expected_implementation, ibyte_to_complex->implementation());
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
std::ofstream ofs(file_name_input.c_str());
|
2018-12-03 17:03:25 +00:00
|
|
|
for (signed char input_data_byte : input_data_bytes)
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
2018-12-03 17:03:25 +00:00
|
|
|
ofs << input_data_byte;
|
2017-07-10 21:59:18 +00:00
|
|
|
}
|
|
|
|
ofs.close();
|
|
|
|
|
|
|
|
auto top_block = gr::make_top_block("Ibyte_To_Complex test");
|
|
|
|
auto file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name_input.c_str());
|
|
|
|
auto sink = gr::blocks::file_sink::make(sizeof(gr_complex), file_name_output.c_str(), false);
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_NO_THROW({
|
2017-07-10 21:59:18 +00:00
|
|
|
top_block->connect(file_source, 0, ibyte_to_complex->get_left_block(), 0);
|
|
|
|
top_block->connect(ibyte_to_complex->get_right_block(), 0, sink, 0);
|
|
|
|
top_block->run();
|
|
|
|
});
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-30 20:49:29 +00:00
|
|
|
int DataTypeAdapter::run_ibyte_to_cbyte_block() const
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ConfigurationInterface> config = std::make_shared<InMemoryConfiguration>();
|
|
|
|
config->set_property("Test.implementation", "Ibyte_To_Cbyte");
|
|
|
|
std::shared_ptr<IbyteToCbyte> ibyte_to_cbyte = std::make_shared<IbyteToCbyte>(config.get(), "Test", 1, 1);
|
|
|
|
std::string expected_implementation = "Ibyte_To_Cbyte";
|
|
|
|
EXPECT_EQ(expected_implementation, ibyte_to_cbyte->implementation());
|
|
|
|
|
|
|
|
std::ofstream ofs(file_name_input.c_str());
|
2018-12-03 17:03:25 +00:00
|
|
|
for (signed char input_data_byte : input_data_bytes)
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
2018-12-03 17:03:25 +00:00
|
|
|
ofs << input_data_byte;
|
2017-07-10 21:59:18 +00:00
|
|
|
}
|
|
|
|
ofs.close();
|
|
|
|
|
|
|
|
auto top_block = gr::make_top_block("Ibyte_To_Cbyte test");
|
|
|
|
auto file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name_input.c_str());
|
2018-12-08 17:49:31 +00:00
|
|
|
auto sink = gr::blocks::file_sink::make(sizeof(int16_t), file_name_output.c_str(), false);
|
2017-07-10 21:59:18 +00:00
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_NO_THROW({
|
2017-07-10 21:59:18 +00:00
|
|
|
top_block->connect(file_source, 0, ibyte_to_cbyte->get_left_block(), 0);
|
|
|
|
top_block->connect(ibyte_to_cbyte->get_right_block(), 0, sink, 0);
|
|
|
|
top_block->run();
|
|
|
|
});
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-30 20:49:29 +00:00
|
|
|
int DataTypeAdapter::run_byte_to_short_block() const
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
|
|
|
std::shared_ptr<ConfigurationInterface> config = std::make_shared<InMemoryConfiguration>();
|
|
|
|
config->set_property("Test.implementation", "Byte_To_Short");
|
|
|
|
std::shared_ptr<ByteToShort> byte_to_short = std::make_shared<ByteToShort>(config.get(), "Test", 1, 1);
|
|
|
|
std::string expected_implementation = "Byte_To_Short";
|
|
|
|
EXPECT_EQ(expected_implementation, byte_to_short->implementation());
|
|
|
|
|
|
|
|
std::ofstream ofs(file_name_input.c_str());
|
2018-12-03 17:03:25 +00:00
|
|
|
for (signed char input_data_byte : input_data_bytes)
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
2018-12-03 17:03:25 +00:00
|
|
|
ofs << input_data_byte;
|
2017-07-10 21:59:18 +00:00
|
|
|
}
|
|
|
|
ofs.close();
|
|
|
|
|
|
|
|
auto top_block = gr::make_top_block("Byte_To_Short test");
|
|
|
|
auto file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name_input.c_str());
|
|
|
|
auto sink = gr::blocks::file_sink::make(sizeof(int16_t), file_name_output.c_str(), false);
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_NO_THROW({
|
2017-07-10 21:59:18 +00:00
|
|
|
top_block->connect(file_source, 0, byte_to_short->get_left_block(), 0);
|
|
|
|
top_block->connect(byte_to_short->get_right_block(), 0, sink, 0);
|
|
|
|
top_block->run();
|
|
|
|
});
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(DataTypeAdapter, ByteToShortValidationOfResults)
|
|
|
|
{
|
|
|
|
run_byte_to_short_block();
|
2018-03-03 01:03:39 +00:00
|
|
|
std::ifstream ifs(file_name_output.data(), std::ifstream::binary | std::ifstream::in);
|
2017-07-10 21:59:18 +00:00
|
|
|
|
|
|
|
int16_t iSample;
|
|
|
|
int i = 0;
|
|
|
|
try
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
|
|
|
while (ifs.read(reinterpret_cast<char*>(&iSample), sizeof(int16_t)))
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_EQ(input_data_bytes.at(i), static_cast<int8_t>(iSample / 256)); // Scale down!
|
2017-07-10 21:59:18 +00:00
|
|
|
i++;
|
|
|
|
}
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
|
|
|
catch (std::system_error& e)
|
|
|
|
{
|
2020-07-07 16:53:50 +00:00
|
|
|
std::cerr << e.code().message() << '\n';
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
2017-07-10 21:59:18 +00:00
|
|
|
ifs.close();
|
2017-07-12 19:01:46 +00:00
|
|
|
ASSERT_EQ(remove(file_name_input.c_str()), 0) << "Problem deleting temporary file";
|
|
|
|
ASSERT_EQ(remove(file_name_output.c_str()), 0) << "Problem deleting temporary file";
|
2017-07-10 21:59:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(DataTypeAdapter, IbyteToCbyteValidationOfResults)
|
|
|
|
{
|
|
|
|
run_ibyte_to_cbyte_block();
|
2018-03-03 01:03:39 +00:00
|
|
|
std::ifstream ifs(file_name_output.data(), std::ifstream::binary | std::ifstream::in);
|
2017-07-10 21:59:18 +00:00
|
|
|
lv_8sc_t iSample;
|
|
|
|
int i = 0;
|
|
|
|
try
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
|
|
|
while (ifs.read(reinterpret_cast<char*>(&iSample), sizeof(lv_8sc_t)))
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
|
|
|
EXPECT_EQ(input_data_bytes.at(i), iSample.real());
|
|
|
|
i++;
|
|
|
|
EXPECT_EQ(input_data_bytes.at(i), iSample.imag());
|
|
|
|
i++;
|
|
|
|
}
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
|
|
|
catch (std::system_error& e)
|
|
|
|
{
|
2020-07-07 16:53:50 +00:00
|
|
|
std::cerr << e.code().message() << '\n';
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
2017-07-10 21:59:18 +00:00
|
|
|
ifs.close();
|
2017-07-12 18:02:34 +00:00
|
|
|
ASSERT_EQ(remove(file_name_input.c_str()), 0) << "Problem deleting temporary file";
|
|
|
|
ASSERT_EQ(remove(file_name_output.c_str()), 0) << "Problem deleting temporary file";
|
2017-07-10 21:59:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(DataTypeAdapter, IbyteToComplexValidationOfResults)
|
|
|
|
{
|
|
|
|
run_ibyte_to_cbyte_block();
|
2018-03-03 01:03:39 +00:00
|
|
|
std::ifstream ifs(file_name_output.data(), std::ifstream::binary | std::ifstream::in);
|
2017-07-10 21:59:18 +00:00
|
|
|
gr_complex iSample;
|
|
|
|
int i = 0;
|
|
|
|
try
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
|
|
|
while (ifs.read(reinterpret_cast<char*>(&iSample), sizeof(gr_complex)))
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
|
|
|
EXPECT_EQ(input_data_bytes.at(i), static_cast<int8_t>(iSample.real()));
|
|
|
|
i++;
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_EQ(input_data_bytes.at(i), static_cast<int8_t>(iSample.imag()));
|
2017-07-10 21:59:18 +00:00
|
|
|
i++;
|
|
|
|
}
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
|
|
|
catch (std::system_error& e)
|
|
|
|
{
|
2020-07-07 16:53:50 +00:00
|
|
|
std::cerr << e.code().message() << '\n';
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
2017-07-10 21:59:18 +00:00
|
|
|
ifs.close();
|
2017-07-12 18:02:34 +00:00
|
|
|
ASSERT_EQ(remove(file_name_input.c_str()), 0) << "Problem deleting temporary file";
|
|
|
|
ASSERT_EQ(remove(file_name_output.c_str()), 0) << "Problem deleting temporary file";
|
2017-07-10 21:59:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(DataTypeAdapter, IbyteToCshortValidationOfResults)
|
|
|
|
{
|
|
|
|
run_ibyte_to_cshort_block();
|
2018-03-03 01:03:39 +00:00
|
|
|
std::ifstream ifs(file_name_output.data(), std::ifstream::binary | std::ifstream::in);
|
2017-07-10 21:59:18 +00:00
|
|
|
lv_16sc_t iSample;
|
|
|
|
int i = 0;
|
|
|
|
try
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
|
|
|
while (ifs.read(reinterpret_cast<char*>(&iSample), sizeof(lv_16sc_t)))
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
|
|
|
EXPECT_EQ(input_data_bytes.at(i), static_cast<int8_t>(iSample.real()));
|
|
|
|
i++;
|
2018-03-03 01:03:39 +00:00
|
|
|
EXPECT_EQ(input_data_bytes.at(i), static_cast<int8_t>(iSample.imag()));
|
2017-07-10 21:59:18 +00:00
|
|
|
i++;
|
|
|
|
}
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
|
|
|
catch (std::system_error& e)
|
|
|
|
{
|
2020-07-07 16:53:50 +00:00
|
|
|
std::cerr << e.code().message() << '\n';
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
2017-07-10 21:59:18 +00:00
|
|
|
ifs.close();
|
2017-07-12 18:02:34 +00:00
|
|
|
ASSERT_EQ(remove(file_name_input.c_str()), 0) << "Problem deleting temporary file";
|
|
|
|
ASSERT_EQ(remove(file_name_output.c_str()), 0) << "Problem deleting temporary file";
|
2017-07-10 21:59:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(DataTypeAdapter, IshortToComplexValidationOfResults)
|
|
|
|
{
|
|
|
|
run_ishort_to_complex_block();
|
2018-03-03 01:03:39 +00:00
|
|
|
std::ifstream ifs(file_name_output.data(), std::ifstream::binary | std::ifstream::in);
|
2017-07-10 21:59:18 +00:00
|
|
|
gr_complex iSample;
|
|
|
|
int i = 0;
|
|
|
|
try
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
|
|
|
while (ifs.read(reinterpret_cast<char*>(&iSample), sizeof(gr_complex)))
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
2023-11-15 13:21:07 +00:00
|
|
|
EXPECT_EQ(input_data_shorts.at(i), iSample.real());
|
2017-07-10 21:59:18 +00:00
|
|
|
i++;
|
2023-11-15 13:21:07 +00:00
|
|
|
EXPECT_EQ(input_data_shorts.at(i), iSample.imag());
|
2017-07-10 21:59:18 +00:00
|
|
|
i++;
|
|
|
|
}
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
|
|
|
catch (std::system_error& e)
|
|
|
|
{
|
2020-07-07 16:53:50 +00:00
|
|
|
std::cerr << e.code().message() << '\n';
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
2017-07-10 21:59:18 +00:00
|
|
|
ifs.close();
|
2017-07-12 18:02:34 +00:00
|
|
|
ASSERT_EQ(remove(file_name_input.c_str()), 0) << "Problem deleting temporary file";
|
|
|
|
ASSERT_EQ(remove(file_name_output.c_str()), 0) << "Problem deleting temporary file";
|
2017-07-10 21:59:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(DataTypeAdapter, IshortToCshortValidationOfResults)
|
|
|
|
{
|
|
|
|
run_ishort_to_cshort_block();
|
2018-03-03 01:03:39 +00:00
|
|
|
std::ifstream ifs(file_name_output.data(), std::ifstream::binary | std::ifstream::in);
|
2017-07-10 21:59:18 +00:00
|
|
|
lv_16sc_t iSample;
|
|
|
|
int i = 0;
|
|
|
|
try
|
2018-03-03 01:03:39 +00:00
|
|
|
{
|
|
|
|
while (ifs.read(reinterpret_cast<char*>(&iSample), sizeof(lv_16sc_t)))
|
2017-07-10 21:59:18 +00:00
|
|
|
{
|
2023-11-15 13:23:30 +00:00
|
|
|
EXPECT_EQ(input_data_shorts.at(i), iSample.real());
|
2017-07-10 21:59:18 +00:00
|
|
|
i++;
|
2023-11-15 13:23:30 +00:00
|
|
|
EXPECT_EQ(input_data_shorts.at(i), iSample.imag());
|
2017-07-10 21:59:18 +00:00
|
|
|
i++;
|
|
|
|
}
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
|
|
|
catch (std::system_error& e)
|
|
|
|
{
|
2020-07-07 16:53:50 +00:00
|
|
|
std::cerr << e.code().message() << '\n';
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
2017-07-10 21:59:18 +00:00
|
|
|
ifs.close();
|
2017-07-12 18:02:34 +00:00
|
|
|
ASSERT_EQ(remove(file_name_input.c_str()), 0) << "Problem deleting temporary file";
|
|
|
|
ASSERT_EQ(remove(file_name_output.c_str()), 0) << "Problem deleting temporary file";
|
2017-07-10 21:59:18 +00:00
|
|
|
}
|