1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-07 07:50:32 +00:00

replacing raw pointers by smart pointers

This commit is contained in:
Carles Fernandez 2014-04-26 00:01:33 +02:00
parent 656864b769
commit a8f85dbbfc
4 changed files with 33 additions and 59 deletions

View File

@ -131,8 +131,7 @@ void GpsL1CaPcpsAcquisitionTest::stop_queue()
TEST_F(GpsL1CaPcpsAcquisitionTest, Instantiate) TEST_F(GpsL1CaPcpsAcquisitionTest, Instantiate)
{ {
init(); init();
GpsL1CaPcpsAcquisition *acquisition = new GpsL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 1, queue); std::shared_ptr<GpsL1CaPcpsAcquisition> acquisition = std::make_shared<GpsL1CaPcpsAcquisition>(config.get(), "Acquisition", 1, 1, queue);
delete acquisition;
} }
TEST_F(GpsL1CaPcpsAcquisitionTest, ConnectAndRun) TEST_F(GpsL1CaPcpsAcquisitionTest, ConnectAndRun)
@ -144,7 +143,7 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ConnectAndRun)
long long int end = 0; long long int end = 0;
init(); init();
GpsL1CaPcpsAcquisition *acquisition = new GpsL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 1, queue); std::shared_ptr<GpsL1CaPcpsAcquisition> acquisition = std::make_shared<GpsL1CaPcpsAcquisition>(config.get(), "Acquisition", 1, 1, queue);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->connect(top_block); acquisition->connect(top_block);
@ -162,9 +161,7 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ConnectAndRun)
end = tv.tv_sec *1000000 + tv.tv_usec; end = tv.tv_sec *1000000 + tv.tv_usec;
}) << "Failure running the top_block." << std::endl; }) << "Failure running the top_block." << std::endl;
delete acquisition;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl; std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
} }
TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults) TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults)
@ -175,7 +172,7 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults)
double expected_delay_samples = 127; double expected_delay_samples = 127;
double expected_doppler_hz = -2400; double expected_doppler_hz = -2400;
init(); init();
GpsL1CaPcpsAcquisition *acquisition = new GpsL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 1, queue); std::shared_ptr<GpsL1CaPcpsAcquisition> acquisition = std::make_shared<GpsL1CaPcpsAcquisition>(config.get(), "Acquisition", 1, 1, queue);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_channel(1); acquisition->set_channel(1);
@ -242,7 +239,4 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults)
EXPECT_LE(doppler_error_hz, 333) << "Doppler error exceeds the expected value: 333 Hz = 2/(3*integration period)"; EXPECT_LE(doppler_error_hz, 333) << "Doppler error exceeds the expected value: 333 Hz = 2/(3*integration period)";
EXPECT_LT(delay_error_chips, 0.5) << "Delay error exceeds the expected value: 0.5 chips"; EXPECT_LT(delay_error_chips, 0.5) << "Delay error exceeds the expected value: 0.5 chips";
delete acquisition;
} }

View File

@ -83,7 +83,7 @@ protected:
gr::msg_queue::sptr queue; gr::msg_queue::sptr queue;
gr::top_block_sptr top_block; gr::top_block_sptr top_block;
GpsL1CaPcpsMultithreadAcquisition *acquisition; std::shared_ptr<GpsL1CaPcpsMultithreadAcquisition> acquisition;
std::shared_ptr<InMemoryConfiguration> config; std::shared_ptr<InMemoryConfiguration> config;
Gnss_Synchro gnss_synchro; Gnss_Synchro gnss_synchro;
size_t item_size; size_t item_size;
@ -365,8 +365,7 @@ void GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test::stop_queue()
TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, Instantiate) TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, Instantiate)
{ {
config_1(); config_1();
acquisition = new GpsL1CaPcpsMultithreadAcquisition(config.get(), "Acquisition", 1, 1, queue); acquisition = std::make_shared<GpsL1CaPcpsMultithreadAcquisition>(config.get(), "Acquisition", 1, 1, queue);
delete acquisition;
} }
TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ConnectAndRun) TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ConnectAndRun)
@ -377,7 +376,7 @@ TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ConnectAndRun)
long long int end = 0; long long int end = 0;
config_1(); config_1();
acquisition = new GpsL1CaPcpsMultithreadAcquisition(config.get(), "Acquisition", 1, 1, queue); acquisition = std::make_shared<GpsL1CaPcpsMultithreadAcquisition>(config.get(), "Acquisition", 1, 1, queue);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->connect(top_block); acquisition->connect(top_block);
@ -396,15 +395,13 @@ TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ConnectAndRun)
}) << "Failure running the top_block." << std::endl; }) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl; std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
delete acquisition;
} }
TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ValidationOfResults) TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ValidationOfResults)
{ {
config_1(); config_1();
acquisition = new GpsL1CaPcpsMultithreadAcquisition(config.get(), "Acquisition", 1, 1, queue); acquisition = std::make_shared<GpsL1CaPcpsMultithreadAcquisition>(config.get(), "Acquisition", 1, 1, queue);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_channel(1); acquisition->set_channel(1);
@ -482,16 +479,13 @@ TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ValidationOfResults)
EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL."; EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL.";
} }
} }
delete acquisition;
delete config;
} }
TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ValidationOfResultsProbabilities)
{ {
config_2(); config_2();
acquisition = new GpsL1CaPcpsMultithreadAcquisition(config.get(), "Acquisition", 1, 1, queue); acquisition = std::make_shared<GpsL1CaPcpsMultithreadAcquisition>(config.get(), "Acquisition", 1, 1, queue);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_channel(1); acquisition->set_channel(1);
@ -570,5 +564,4 @@ TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ValidationOfResultsProbabi
} }
} }
delete acquisition;
} }

View File

@ -77,7 +77,7 @@ protected:
gr::msg_queue::sptr queue; gr::msg_queue::sptr queue;
gr::top_block_sptr top_block; gr::top_block_sptr top_block;
GpsL1CaPcpsOpenClAcquisition *acquisition; std::shared_ptr<GpsL1CaPcpsOpenClAcquisition> acquisition;
std::shared_ptr<InMemoryConfiguration> config; std::shared_ptr<InMemoryConfiguration> config;
Gnss_Synchro gnss_synchro; Gnss_Synchro gnss_synchro;
size_t item_size; size_t item_size;
@ -359,8 +359,7 @@ void GpsL1CaPcpsOpenClAcquisitionGSoC2013Test::stop_queue()
TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, Instantiate) TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, Instantiate)
{ {
config_1(); config_1();
acquisition = new GpsL1CaPcpsOpenClAcquisition(config.get(), "Acquisition", 1, 1, queue); acquisition = std::make_shared<GpsL1CaPcpsOpenClAcquisition>(config.get(), "Acquisition", 1, 1, queue);
delete acquisition;
} }
TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ConnectAndRun) TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ConnectAndRun)
@ -371,7 +370,7 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ConnectAndRun)
long long int end = 0; long long int end = 0;
config_1(); config_1();
acquisition = new GpsL1CaPcpsOpenClAcquisition(config.get(), "Acquisition", 1, 1, queue); acquisition = std::make_shared<GpsL1CaPcpsOpenClAcquisition>(config.get(), "Acquisition", 1, 1, queue);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->connect(top_block); acquisition->connect(top_block);
@ -390,15 +389,13 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ConnectAndRun)
}) << "Failure running the top_block." << std::endl; }) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl; std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
delete acquisition;
} }
TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResults) TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResults)
{ {
config_1(); config_1();
acquisition = new GpsL1CaPcpsOpenClAcquisition(config.get(), "Acquisition", 1, 1, queue); acquisition = std::make_shared<GpsL1CaPcpsOpenClAcquisition>(config.get(), "Acquisition", 1, 1, queue);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_channel(1); acquisition->set_channel(1);
@ -476,15 +473,13 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResults)
EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL."; EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL.";
} }
} }
delete acquisition;
} }
TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResultsProbabilities)
{ {
config_2(); config_2();
acquisition = new GpsL1CaPcpsOpenClAcquisition(config.get(), "Acquisition", 1, 1, queue); acquisition = std::make_shared<GpsL1CaPcpsOpenClAcquisition>(config.get(), "Acquisition", 1, 1, queue);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_channel(1); acquisition->set_channel(1);
@ -562,6 +557,4 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResultsProbabilitie
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl;
} }
} }
delete acquisition;
} }

View File

@ -80,7 +80,7 @@ protected:
gr::msg_queue::sptr queue; gr::msg_queue::sptr queue;
gr::top_block_sptr top_block; gr::top_block_sptr top_block;
GpsL1CaPcpsTongAcquisition *acquisition; std::shared_ptr<GpsL1CaPcpsTongAcquisition> acquisition;
std::shared_ptr<InMemoryConfiguration> config; std::shared_ptr<InMemoryConfiguration> config;
Gnss_Synchro gnss_synchro; Gnss_Synchro gnss_synchro;
size_t item_size; size_t item_size;
@ -362,8 +362,7 @@ void GpsL1CaPcpsTongAcquisitionGSoC2013Test::stop_queue()
TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, Instantiate) TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, Instantiate)
{ {
config_1(); config_1();
acquisition = new GpsL1CaPcpsTongAcquisition(config.get(), "Acquisition", 1, 1, queue); acquisition = std::make_shared<GpsL1CaPcpsTongAcquisition>(config.get(), "Acquisition", 1, 1, queue);
delete acquisition;
} }
TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ConnectAndRun) TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ConnectAndRun)
@ -374,7 +373,7 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ConnectAndRun)
long long int end = 0; long long int end = 0;
config_1(); config_1();
acquisition = new GpsL1CaPcpsTongAcquisition(config.get(), "Acquisition", 1, 1, queue); acquisition = std::make_shared<GpsL1CaPcpsTongAcquisition>(config.get(), "Acquisition", 1, 1, queue);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->connect(top_block); acquisition->connect(top_block);
@ -393,38 +392,37 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ConnectAndRun)
}) << "Failure running the top_block." << std::endl; }) << "Failure running the top_block." << std::endl;
std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl; std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl;
delete acquisition;
} }
TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResults) TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResults)
{ {
config_1(); config_1();
acquisition = new GpsL1CaPcpsTongAcquisition(config.get(), "Acquisition", 1, 1, queue); acquisition = std::make_shared<GpsL1CaPcpsTongAcquisition>(config.get(), "Acquisition", 1, 1, queue);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_channel(1); acquisition->set_channel(1);
}) << "Failure setting channel."<< std::endl; }) << "Failure setting channel." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_gnss_synchro(&gnss_synchro);
}) << "Failure setting gnss_synchro."<< std::endl; }) << "Failure setting gnss_synchro." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_channel_queue(&channel_internal_queue); acquisition->set_channel_queue(&channel_internal_queue);
}) << "Failure setting channel_internal_queue."<< std::endl; }) << "Failure setting channel_internal_queue." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 10000)); acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 10000));
}) << "Failure setting doppler_max."<< std::endl; }) << "Failure setting doppler_max." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 500)); acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 500));
}) << "Failure setting doppler_step."<< std::endl; }) << "Failure setting doppler_step." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_threshold(config->property("Acquisition.threshold", 0.0)); acquisition->set_threshold(config->property("Acquisition.threshold", 0.0));
}) << "Failure setting threshold."<< std::endl; }) << "Failure setting threshold." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->connect(top_block); acquisition->connect(top_block);
@ -462,7 +460,7 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResults)
EXPECT_NO_THROW( { EXPECT_NO_THROW( {
top_block->run(); // Start threads and wait top_block->run(); // Start threads and wait
}) << "Failure running the top_block."<< std::endl; }) << "Failure running the top_block." << std::endl;
if (i == 0) if (i == 0)
{ {
@ -478,43 +476,41 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResults)
EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL."; EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL.";
} }
} }
delete acquisition;
} }
TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResultsProbabilities)
{ {
config_2(); config_2();
acquisition = new GpsL1CaPcpsTongAcquisition(config.get(), "Acquisition", 1, 1, queue); acquisition = std::make_shared<GpsL1CaPcpsTongAcquisition>(config.get(), "Acquisition", 1, 1, queue);
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_channel(1); acquisition->set_channel(1);
}) << "Failure setting channel."<< std::endl; }) << "Failure setting channel." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_gnss_synchro(&gnss_synchro); acquisition->set_gnss_synchro(&gnss_synchro);
}) << "Failure setting gnss_synchro."<< std::endl; }) << "Failure setting gnss_synchro." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_channel_queue(&channel_internal_queue); acquisition->set_channel_queue(&channel_internal_queue);
}) << "Failure setting channel_internal_queue."<< std::endl; }) << "Failure setting channel_internal_queue." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 10000)); acquisition->set_doppler_max(config->property("Acquisition.doppler_max", 10000));
}) << "Failure setting doppler_max."<< std::endl; }) << "Failure setting doppler_max." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 500)); acquisition->set_doppler_step(config->property("Acquisition.doppler_step", 500));
}) << "Failure setting doppler_step."<< std::endl; }) << "Failure setting doppler_step." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->set_threshold(config->property("Acquisition.threshold", 0.0)); acquisition->set_threshold(config->property("Acquisition.threshold", 0.0));
}) << "Failure setting threshold."<< std::endl; }) << "Failure setting threshold." << std::endl;
ASSERT_NO_THROW( { ASSERT_NO_THROW( {
acquisition->connect(top_block); acquisition->connect(top_block);
}) << "Failure connecting acquisition to the top_block."<< std::endl; }) << "Failure connecting acquisition to the top_block." << std::endl;
acquisition->init(); acquisition->init();
@ -550,7 +546,7 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResultsProbabilities)
EXPECT_NO_THROW( { EXPECT_NO_THROW( {
top_block->run(); // Start threads and wait top_block->run(); // Start threads and wait
}) << "Failure running the top_block."<< std::endl; }) << "Failure running the top_block." << std::endl;
if (i == 0) if (i == 0)
{ {
@ -564,6 +560,4 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResultsProbabilities)
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl;
} }
} }
delete acquisition;
} }