diff --git a/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_test.cc b/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_test.cc index 74219866d..003ab77bf 100644 --- a/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_test.cc +++ b/src/tests/gnss_block/gps_l1_ca_pcps_acquisition_test.cc @@ -131,8 +131,7 @@ void GpsL1CaPcpsAcquisitionTest::stop_queue() TEST_F(GpsL1CaPcpsAcquisitionTest, Instantiate) { init(); - GpsL1CaPcpsAcquisition *acquisition = new GpsL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 1, queue); - delete acquisition; + std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); } TEST_F(GpsL1CaPcpsAcquisitionTest, ConnectAndRun) @@ -144,7 +143,7 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ConnectAndRun) long long int end = 0; init(); - GpsL1CaPcpsAcquisition *acquisition = new GpsL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 1, queue); + std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); ASSERT_NO_THROW( { acquisition->connect(top_block); @@ -162,9 +161,7 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ConnectAndRun) end = tv.tv_sec *1000000 + tv.tv_usec; }) << "Failure running the top_block." << std::endl; - delete acquisition; std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl; - } TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults) @@ -175,7 +172,7 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults) double expected_delay_samples = 127; double expected_doppler_hz = -2400; init(); - GpsL1CaPcpsAcquisition *acquisition = new GpsL1CaPcpsAcquisition(config.get(), "Acquisition", 1, 1, queue); + std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); ASSERT_NO_THROW( { 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_LT(delay_error_chips, 0.5) << "Delay error exceeds the expected value: 0.5 chips"; - - delete acquisition; - } diff --git a/src/tests/gnss_block/gps_l1_ca_pcps_multithread_acquisition_gsoc2013_test.cc b/src/tests/gnss_block/gps_l1_ca_pcps_multithread_acquisition_gsoc2013_test.cc index 5abcf315d..97647b48d 100644 --- a/src/tests/gnss_block/gps_l1_ca_pcps_multithread_acquisition_gsoc2013_test.cc +++ b/src/tests/gnss_block/gps_l1_ca_pcps_multithread_acquisition_gsoc2013_test.cc @@ -83,7 +83,7 @@ protected: gr::msg_queue::sptr queue; gr::top_block_sptr top_block; - GpsL1CaPcpsMultithreadAcquisition *acquisition; + std::shared_ptr acquisition; std::shared_ptr config; Gnss_Synchro gnss_synchro; size_t item_size; @@ -365,8 +365,7 @@ void GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test::stop_queue() TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, Instantiate) { config_1(); - acquisition = new GpsL1CaPcpsMultithreadAcquisition(config.get(), "Acquisition", 1, 1, queue); - delete acquisition; + acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); } TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ConnectAndRun) @@ -377,7 +376,7 @@ TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ConnectAndRun) long long int end = 0; config_1(); - acquisition = new GpsL1CaPcpsMultithreadAcquisition(config.get(), "Acquisition", 1, 1, queue); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); ASSERT_NO_THROW( { acquisition->connect(top_block); @@ -396,15 +395,13 @@ TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ConnectAndRun) }) << "Failure running the top_block." << std::endl; std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl; - - delete acquisition; } TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ValidationOfResults) { config_1(); - acquisition = new GpsL1CaPcpsMultithreadAcquisition(config.get(), "Acquisition", 1, 1, queue); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); ASSERT_NO_THROW( { acquisition->set_channel(1); @@ -482,16 +479,13 @@ TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ValidationOfResults) EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL."; } } - - delete acquisition; - delete config; } TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) { config_2(); - acquisition = new GpsL1CaPcpsMultithreadAcquisition(config.get(), "Acquisition", 1, 1, queue); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); ASSERT_NO_THROW( { acquisition->set_channel(1); @@ -570,5 +564,4 @@ TEST_F(GpsL1CaPcpsMultithreadAcquisitionGSoC2013Test, ValidationOfResultsProbabi } } - delete acquisition; } diff --git a/src/tests/gnss_block/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc b/src/tests/gnss_block/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc index 9b6c88739..19608c8fe 100644 --- a/src/tests/gnss_block/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc +++ b/src/tests/gnss_block/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc @@ -77,7 +77,7 @@ protected: gr::msg_queue::sptr queue; gr::top_block_sptr top_block; - GpsL1CaPcpsOpenClAcquisition *acquisition; + std::shared_ptr acquisition; std::shared_ptr config; Gnss_Synchro gnss_synchro; size_t item_size; @@ -359,8 +359,7 @@ void GpsL1CaPcpsOpenClAcquisitionGSoC2013Test::stop_queue() TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, Instantiate) { config_1(); - acquisition = new GpsL1CaPcpsOpenClAcquisition(config.get(), "Acquisition", 1, 1, queue); - delete acquisition; + acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); } TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ConnectAndRun) @@ -371,7 +370,7 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ConnectAndRun) long long int end = 0; config_1(); - acquisition = new GpsL1CaPcpsOpenClAcquisition(config.get(), "Acquisition", 1, 1, queue); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); ASSERT_NO_THROW( { acquisition->connect(top_block); @@ -390,15 +389,13 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ConnectAndRun) }) << "Failure running the top_block." << std::endl; std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl; - - delete acquisition; } TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResults) { config_1(); - acquisition = new GpsL1CaPcpsOpenClAcquisition(config.get(), "Acquisition", 1, 1, queue); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); ASSERT_NO_THROW( { acquisition->set_channel(1); @@ -476,15 +473,13 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResults) EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL."; } } - - delete acquisition; } TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) { config_2(); - acquisition = new GpsL1CaPcpsOpenClAcquisition(config.get(), "Acquisition", 1, 1, queue); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); ASSERT_NO_THROW( { acquisition->set_channel(1); @@ -562,6 +557,4 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResultsProbabilitie std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; } } - - delete acquisition; } diff --git a/src/tests/gnss_block/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc b/src/tests/gnss_block/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc index b0e8dde78..f8055722e 100644 --- a/src/tests/gnss_block/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc +++ b/src/tests/gnss_block/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc @@ -80,7 +80,7 @@ protected: gr::msg_queue::sptr queue; gr::top_block_sptr top_block; - GpsL1CaPcpsTongAcquisition *acquisition; + std::shared_ptr acquisition; std::shared_ptr config; Gnss_Synchro gnss_synchro; size_t item_size; @@ -362,8 +362,7 @@ void GpsL1CaPcpsTongAcquisitionGSoC2013Test::stop_queue() TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, Instantiate) { config_1(); - acquisition = new GpsL1CaPcpsTongAcquisition(config.get(), "Acquisition", 1, 1, queue); - delete acquisition; + acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); } TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ConnectAndRun) @@ -374,7 +373,7 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ConnectAndRun) long long int end = 0; config_1(); - acquisition = new GpsL1CaPcpsTongAcquisition(config.get(), "Acquisition", 1, 1, queue); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); ASSERT_NO_THROW( { acquisition->connect(top_block); @@ -393,38 +392,37 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ConnectAndRun) }) << "Failure running the top_block." << std::endl; std::cout << "Processed " << nsamples << " samples in " << (end - begin) << " microseconds" << std::endl; - delete acquisition; } TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResults) { config_1(); - acquisition = new GpsL1CaPcpsTongAcquisition(config.get(), "Acquisition", 1, 1, queue); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); ASSERT_NO_THROW( { acquisition->set_channel(1); - }) << "Failure setting channel."<< std::endl; + }) << "Failure setting channel." << std::endl; ASSERT_NO_THROW( { acquisition->set_gnss_synchro(&gnss_synchro); - }) << "Failure setting gnss_synchro."<< std::endl; + }) << "Failure setting gnss_synchro." << std::endl; ASSERT_NO_THROW( { acquisition->set_channel_queue(&channel_internal_queue); - }) << "Failure setting channel_internal_queue."<< std::endl; + }) << "Failure setting channel_internal_queue." << std::endl; ASSERT_NO_THROW( { 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( { 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( { acquisition->set_threshold(config->property("Acquisition.threshold", 0.0)); - }) << "Failure setting threshold."<< std::endl; + }) << "Failure setting threshold." << std::endl; ASSERT_NO_THROW( { acquisition->connect(top_block); @@ -462,7 +460,7 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResults) EXPECT_NO_THROW( { top_block->run(); // Start threads and wait - }) << "Failure running the top_block."<< std::endl; + }) << "Failure running the top_block." << std::endl; if (i == 0) { @@ -478,43 +476,41 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResults) EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL."; } } - - delete acquisition; } TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) { config_2(); - acquisition = new GpsL1CaPcpsTongAcquisition(config.get(), "Acquisition", 1, 1, queue); + acquisition = std::make_shared(config.get(), "Acquisition", 1, 1, queue); ASSERT_NO_THROW( { acquisition->set_channel(1); - }) << "Failure setting channel."<< std::endl; + }) << "Failure setting channel." << std::endl; ASSERT_NO_THROW( { acquisition->set_gnss_synchro(&gnss_synchro); - }) << "Failure setting gnss_synchro."<< std::endl; + }) << "Failure setting gnss_synchro." << std::endl; ASSERT_NO_THROW( { acquisition->set_channel_queue(&channel_internal_queue); - }) << "Failure setting channel_internal_queue."<< std::endl; + }) << "Failure setting channel_internal_queue." << std::endl; ASSERT_NO_THROW( { 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( { 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( { acquisition->set_threshold(config->property("Acquisition.threshold", 0.0)); - }) << "Failure setting threshold."<< std::endl; + }) << "Failure setting threshold." << std::endl; ASSERT_NO_THROW( { acquisition->connect(top_block); - }) << "Failure connecting acquisition to the top_block."<< std::endl; + }) << "Failure connecting acquisition to the top_block." << std::endl; acquisition->init(); @@ -550,7 +546,7 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) EXPECT_NO_THROW( { top_block->run(); // Start threads and wait - }) << "Failure running the top_block."<< std::endl; + }) << "Failure running the top_block." << std::endl; if (i == 0) { @@ -564,6 +560,4 @@ TEST_F(GpsL1CaPcpsTongAcquisitionGSoC2013Test, ValidationOfResultsProbabilities) std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; } } - - delete acquisition; }