mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-04-13 06:13:17 +00:00
Cleaning tests
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@143 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
parent
0d598a7188
commit
3b5189075b
@ -1,3 +1,36 @@
|
||||
/*!
|
||||
* \file cordic.cc
|
||||
* \brief Implementation of the CORDIC (COordinate Rotation DIgital Computer) algorithm
|
||||
* \author Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es
|
||||
*
|
||||
* This is a modified implementation of the one found at
|
||||
* http://www.dspguru.com/dsp/faqs/cordic
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* GNSS-SDR is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* GNSS-SDR is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "cordic.h"
|
||||
@ -13,9 +46,8 @@ Cordic::Cordic(int max_L)
|
||||
{
|
||||
double K, dummy;
|
||||
int L;
|
||||
|
||||
//CORDIC_TABLE *mp_cordic_table = NULL;
|
||||
mp_cordic_table = (CORDIC_TABLE *) calloc(max_L + 1, sizeof(CORDIC_TABLE));
|
||||
//mp_cordic_table = (CORDIC_TABLE *) calloc(max_L + 1, sizeof(CORDIC_TABLE));
|
||||
mp_cordic_table = (CORDIC_TABLE *) malloc((max_L + 1) * sizeof(CORDIC_TABLE));
|
||||
if (!mp_cordic_table)
|
||||
{
|
||||
/* failed to calloc table */
|
||||
@ -43,7 +75,6 @@ Cordic::Cordic(int max_L)
|
||||
Cordic::~Cordic ()
|
||||
{
|
||||
free(mp_cordic_table);
|
||||
//mp_cordic_table = ((void *) 0); // nullptr
|
||||
m_max_L = INVALID_K;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
@ -34,92 +34,124 @@
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
StringConverter::StringConverter() {
|
||||
}
|
||||
StringConverter::StringConverter()
|
||||
{}
|
||||
|
||||
StringConverter::~StringConverter() {
|
||||
}
|
||||
StringConverter::~StringConverter()
|
||||
{}
|
||||
|
||||
bool StringConverter::convert(std::string value, bool default_value) {
|
||||
|
||||
if(value.compare("true") == 0) {
|
||||
bool StringConverter::convert(std::string value, bool default_value)
|
||||
{
|
||||
if(value.compare("true") == 0)
|
||||
{
|
||||
return true;
|
||||
} else if(value.compare("false") == 0) {
|
||||
}
|
||||
else if(value.compare("false") == 0)
|
||||
{
|
||||
return false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return default_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
long StringConverter::convert(std::string value, long default_value) {
|
||||
|
||||
long StringConverter::convert(std::string value, long default_value)
|
||||
{
|
||||
std::stringstream stream(value);
|
||||
|
||||
long result;
|
||||
stream >> result;
|
||||
|
||||
if(stream.fail()) {
|
||||
if(stream.fail())
|
||||
{
|
||||
return default_value;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int StringConverter::convert(std::string value, int default_value) {
|
||||
|
||||
int StringConverter::convert(std::string value, int default_value)
|
||||
{
|
||||
|
||||
std::stringstream stream(value);
|
||||
|
||||
int result;
|
||||
stream >> result;
|
||||
|
||||
if(stream.fail()) {
|
||||
if(stream.fail())
|
||||
{
|
||||
return default_value;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int StringConverter::convert(std::string value, unsigned int default_value) {
|
||||
|
||||
|
||||
unsigned int StringConverter::convert(std::string value, unsigned int default_value)
|
||||
{
|
||||
std::stringstream stream(value);
|
||||
|
||||
unsigned int result;
|
||||
stream >> result;
|
||||
|
||||
if(stream.fail()) {
|
||||
if(stream.fail())
|
||||
{
|
||||
return default_value;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float StringConverter::convert(std::string value, float default_value) {
|
||||
|
||||
|
||||
|
||||
float StringConverter::convert(std::string value, float default_value)
|
||||
{
|
||||
|
||||
std::stringstream stream(value);
|
||||
|
||||
float result;
|
||||
stream >> result;
|
||||
|
||||
if(stream.fail()) {
|
||||
if(stream.fail())
|
||||
{
|
||||
return default_value;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double StringConverter::convert(std::string value, double default_value) {
|
||||
|
||||
|
||||
|
||||
double StringConverter::convert(std::string value, double default_value)
|
||||
{
|
||||
|
||||
std::stringstream stream(value);
|
||||
|
||||
double result;
|
||||
stream >> result;
|
||||
|
||||
if(stream.fail()) {
|
||||
if(stream.fail())
|
||||
{
|
||||
return default_value;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors)
|
||||
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
@ -35,8 +35,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
class StringConverter {
|
||||
|
||||
class StringConverter
|
||||
{
|
||||
public:
|
||||
StringConverter();
|
||||
virtual ~StringConverter();
|
||||
|
@ -1,17 +1,51 @@
|
||||
/*!
|
||||
* \file cordic_test.cc
|
||||
* \brief Test of the CORDIC (COordinate Rotation DIgital Computer) algorithm
|
||||
* \author Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es
|
||||
*
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*
|
||||
* Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
|
||||
*
|
||||
* GNSS-SDR is a software defined Global Navigation
|
||||
* Satellite Systems receiver
|
||||
*
|
||||
* This file is part of GNSS-SDR.
|
||||
*
|
||||
* GNSS-SDR is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* GNSS-SDR is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* -------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include "cordic.h"
|
||||
#include <sys/time.h>
|
||||
#include <algorithm>
|
||||
#include <cstdlib> // for RAND_MAX
|
||||
|
||||
|
||||
TEST(Cordic_Test, StandardCIsFasterThanCordic)
|
||||
{
|
||||
int largest_k = 0;
|
||||
int largest_k = 10;
|
||||
Cordic* cordicPtr;
|
||||
cordicPtr = new Cordic(largest_k);
|
||||
double phase = 0.1;
|
||||
double phase = rand();
|
||||
phase = (phase/RAND_MAX) * 3.141592;
|
||||
double cos_phase1 = 0;
|
||||
double sin_phase1 = 0;
|
||||
double cos_phase2 = 0;
|
||||
@ -42,10 +76,8 @@ TEST(Cordic_Test, StandardCIsFasterThanCordic)
|
||||
gettimeofday(&tv, NULL);
|
||||
long long int end2 = tv.tv_sec *1000000 + tv.tv_usec;
|
||||
|
||||
std::cout << "CORDIC sin =" << sin_phase2 << " computed in " << (end1-begin1) << " microseconds" << std::endl;
|
||||
std::cout << "STD sin =" << sin(phase) << " computed in " << (end2-begin2) << " microseconds" << std::endl;
|
||||
std::cout << "CORDIC sin =" << sin_phase1 << " computed " << niter << " times in " << (end1-begin1) << " microseconds" << std::endl;
|
||||
std::cout << "STD sin =" << sin_phase2 << " computed " << niter << " times in " << (end2-begin2) << " microseconds" << std::endl;
|
||||
|
||||
EXPECT_TRUE((end2-begin2) < (end1-begin1));
|
||||
|
||||
|
||||
}
|
||||
|
@ -45,8 +45,9 @@ TEST(Control_Message_Factory_Test, GetQueueMessage)
|
||||
gr_message_sptr queue_message = factory->GetQueueMessage(0, 0);
|
||||
ControlMessage *control_message = (ControlMessage*)queue_message->msg();
|
||||
|
||||
EXPECT_EQ(0, control_message->who);
|
||||
EXPECT_EQ(0, control_message->what);
|
||||
unsigned int expected0 = 0;
|
||||
EXPECT_EQ(expected0, control_message->who);
|
||||
EXPECT_EQ(expected0, control_message->what);
|
||||
EXPECT_EQ(sizeof(ControlMessage), queue_message->length());
|
||||
|
||||
delete factory;
|
||||
@ -67,9 +68,11 @@ TEST(Control_Message_Factory_Test, GetControlMessages)
|
||||
memcpy(queue_message->msg(), control_message, sizeof(ControlMessage));
|
||||
std::vector<ControlMessage*> *control_messages = factory->GetControlMessages(queue_message);
|
||||
|
||||
EXPECT_EQ(1, control_messages->size());
|
||||
EXPECT_EQ(1, control_messages->at(0)->who);
|
||||
EXPECT_EQ(4, control_messages->at(0)->what);
|
||||
unsigned int expected1 = 1;
|
||||
unsigned int expected4 = 4;
|
||||
EXPECT_EQ(expected1, control_messages->size());
|
||||
EXPECT_EQ(expected1, control_messages->at(0)->who);
|
||||
EXPECT_EQ(expected4, control_messages->at(0)->what);
|
||||
|
||||
delete control_message;
|
||||
delete control_messages;
|
||||
@ -93,7 +96,8 @@ TEST(Control_Message_Factory_Test, GetControlMessagesWrongSize)
|
||||
memcpy(queue_message->msg() + sizeof(ControlMessage), &another_int, sizeof(int));
|
||||
std::vector<ControlMessage*> *control_messages = factory->GetControlMessages(queue_message);
|
||||
|
||||
EXPECT_EQ(0, control_messages->size());
|
||||
unsigned int expected0 = 0;
|
||||
EXPECT_EQ(expected0, control_messages->size());
|
||||
|
||||
delete control_message;
|
||||
delete control_messages;
|
||||
|
@ -32,8 +32,6 @@
|
||||
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <gr_block.h>
|
||||
#include <stdexcept>
|
||||
#include "pass_through.h"
|
||||
#include "in_memory_configuration.h"
|
||||
|
||||
@ -42,14 +40,13 @@
|
||||
TEST(Pass_Through_Test, Instantiate)
|
||||
{
|
||||
InMemoryConfiguration* config = new InMemoryConfiguration();
|
||||
|
||||
config->set_property("Test.item_type", "gr_complex");
|
||||
config->set_property("Test.vector_size", "2");
|
||||
|
||||
Pass_Through *signal_conditioner = new Pass_Through(config, "Test", 1, 1);
|
||||
|
||||
EXPECT_STREQ("gr_complex", signal_conditioner->item_type().c_str());
|
||||
EXPECT_EQ(2, signal_conditioner->vector_size());
|
||||
unsigned int expected2 = 2;
|
||||
EXPECT_EQ(expected2, signal_conditioner->vector_size());
|
||||
|
||||
delete signal_conditioner;
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
|
||||
/**
|
||||
* Copyright notice
|
||||
*/
|
||||
|
||||
/**
|
||||
* Author: Carlos Avilés, 2010. carlos.avilesr(at)googlemail.com
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class implements unit tests for a the valve custom block.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <gnuradio/gr_top_block.h>
|
||||
#include <gr_sig_source_f.h>
|
||||
#include <gr_null_sink.h>
|
||||
#include <gr_msg_queue.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "gnss_sdr_valve.h"
|
||||
|
||||
#include <glog/log_severity.h>
|
||||
#include <glog/logging.h>
|
||||
|
||||
using google::LogMessage;
|
||||
|
||||
TEST(GNSS_SDR_VALVE, CheckEventSentAfter100Samples) {
|
||||
|
||||
gr_msg_queue_sptr queue = gr_make_msg_queue(0);
|
||||
|
||||
gr_top_block_sptr top_block = gr_make_top_block("gnss_sdr_valve_test");
|
||||
gr_block_sptr valve = gnss_sdr_make_valve(sizeof(float), 100, queue);
|
||||
gr_sig_source_f_sptr source = gr_make_sig_source_f(100, GR_CONST_WAVE, 100, 1, 0);
|
||||
gr_block_sptr sink = gr_make_null_sink(sizeof(float));
|
||||
|
||||
LOG_AT_LEVEL(INFO) << "Queue count is " << queue->count();
|
||||
EXPECT_EQ(0, queue->count());
|
||||
|
||||
top_block->connect(source, 0, valve, 0);
|
||||
top_block->connect(valve, 0, sink, 0);
|
||||
|
||||
top_block->run();
|
||||
top_block->stop();
|
||||
|
||||
LOG_AT_LEVEL(INFO) << "Queue count is " << queue->count();
|
||||
EXPECT_EQ(1, queue->count());
|
||||
|
||||
}
|
@ -37,10 +37,6 @@
|
||||
#include <gr_null_sink.h>
|
||||
#include <gr_msg_queue.h>
|
||||
#include "gnss_sdr_valve.h"
|
||||
//#include <glog/log_severity.h>
|
||||
//#include <glog/logging.h>
|
||||
|
||||
//using google::LogMessage;
|
||||
|
||||
TEST(Valve_Test, CheckEventSentAfter100Samples)
|
||||
{
|
||||
@ -51,8 +47,8 @@ TEST(Valve_Test, CheckEventSentAfter100Samples)
|
||||
gr_sig_source_f_sptr source = gr_make_sig_source_f(100, GR_CONST_WAVE, 100, 1, 0);
|
||||
gr_block_sptr sink = gr_make_null_sink(sizeof(float));
|
||||
|
||||
//LOG_AT_LEVEL(INFO) << "Queue count is " << queue->count();
|
||||
EXPECT_EQ(0, queue->count());
|
||||
unsigned int expected0 = 0;
|
||||
EXPECT_EQ(expected0, queue->count());
|
||||
|
||||
top_block->connect(source, 0, valve, 0);
|
||||
top_block->connect(valve, 0, sink, 0);
|
||||
@ -60,6 +56,6 @@ TEST(Valve_Test, CheckEventSentAfter100Samples)
|
||||
top_block->run();
|
||||
top_block->stop();
|
||||
|
||||
//LOG_AT_LEVEL(INFO) << "Queue count is " << queue->count();
|
||||
EXPECT_EQ(1, queue->count());
|
||||
unsigned int expected1 = 1;
|
||||
EXPECT_EQ(expected1, queue->count());
|
||||
}
|
||||
|
@ -37,20 +37,21 @@
|
||||
|
||||
TEST(String_Converter_Test, StringToBool)
|
||||
{
|
||||
StringConverter *converter = new StringConverter();
|
||||
StringConverter* converter;
|
||||
converter = new StringConverter();
|
||||
bool conversion_result = converter->convert("false", true);
|
||||
EXPECT_EQ(false, conversion_result);
|
||||
delete converter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TEST(String_Converter_Test, StringToSizeT)
|
||||
{
|
||||
StringConverter *converter = new StringConverter();
|
||||
StringConverter* converter;
|
||||
converter = new StringConverter();
|
||||
size_t conversion_result = converter->convert("8", 1);
|
||||
EXPECT_EQ(8, conversion_result);
|
||||
unsigned int expected = 8;
|
||||
EXPECT_EQ(expected, conversion_result);
|
||||
delete converter;
|
||||
}
|
||||
|
||||
@ -59,7 +60,8 @@ TEST(String_Converter_Test, StringToSizeT)
|
||||
|
||||
TEST(String_Converter_Test, StringToBoolFail)
|
||||
{
|
||||
StringConverter *converter = new StringConverter();
|
||||
StringConverter* converter;
|
||||
converter = new StringConverter();
|
||||
bool conversion_result = converter->convert("lse", true);
|
||||
EXPECT_EQ(true, conversion_result);
|
||||
delete converter;
|
||||
@ -70,8 +72,10 @@ TEST(String_Converter_Test, StringToBoolFail)
|
||||
|
||||
TEST(String_Converter_Test, StringToSizeTFail)
|
||||
{
|
||||
StringConverter *converter = new StringConverter();
|
||||
StringConverter* converter;
|
||||
converter = new StringConverter();
|
||||
size_t conversion_result = converter->convert("false", 1);
|
||||
EXPECT_EQ(1, conversion_result);
|
||||
unsigned int expected1 = 1;
|
||||
EXPECT_EQ(expected1, conversion_result);
|
||||
delete converter;
|
||||
}
|
||||
|
@ -46,12 +46,12 @@
|
||||
#include "control_thread.h"
|
||||
|
||||
|
||||
//#include "control_thread/control_message_factory_test.cc"
|
||||
#include "control_thread/control_message_factory_test.cc"
|
||||
//#include "control_thread/control_thread_test.cc"
|
||||
#include "configuration/file_configuration_test.cc"
|
||||
//#include "flowgraph/file_output_filter_test.cc"
|
||||
//#include "flowgraph/file_signal_source_test.cc"
|
||||
//#include "flowgraph/pass_through_test.cc"
|
||||
#include "flowgraph/pass_through_test.cc"
|
||||
//#include "flowgraph/gnss_flowgraph_test.cc"
|
||||
//#include "gnss_block/file_output_filter_test.cc"
|
||||
//#include "gnss_block/gnss_block_factory_test.cc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user