Some unit test warnings addressed. (#515)

* Removed purple warnings from unit test compilation.

* "Fixed const corectness bug. Added more warning fixes."

* Fixed warning issue.

* Removed null checking and (char*) casting.

* Changed sizeof parameter to variable from data structure.
This commit is contained in:
Christopher LaChance 2017-11-29 15:35:16 -06:00 committed by GitHub
parent 0b9fbe1762
commit 6184aa6cd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 60 additions and 66 deletions

View File

@ -55,8 +55,8 @@ class ClassOfEverything {
float * fap[4] ; /* kg blah */
float ** fpp ; /* kg blah */
float f_rad ; /* r float test value */
double d_deg ; /* d blah */
float f_rad ; /* rad float test value */
double d_deg ; /* degree blah */
char c ; /* -- blah */
char ca[20] ; /* -- blah */

View File

@ -16,8 +16,8 @@ typedef struct {
float f[3] ; /* m/s2 -- */
double d[3] ; /* kg*m/s2 -- */
unsigned short us[3] ; /* N -- */
unsigned int ui[3] ; /* cnt -- */
unsigned long ul[3] ; /* v -- */
unsigned int ui[3] ; /* count -- */
unsigned long ul[3] ; /* V -- */
long long ll[3] ; /* K -- */
} STRUCT_1 ;

View File

@ -94,7 +94,7 @@ public:
* Get the next (X, Y) pair for the curve.
* @return 1 if data was returned in x_value and y_value, 0 if there is no more data.
*/
virtual int getXY(double *x_value, double *y_value) {
virtual int getXY(double *, double *) {
return 0;
}

View File

@ -30,7 +30,7 @@ public:
* @param product is a pointer to the instance of DPC_product, for which a
* representation is to be rendered.
*/
virtual DPV_pointer render_product(DPC_product* product) {
virtual DPV_pointer render_product( DPC_product* ) {
return ( (DPV_pointer)NULL);
};
@ -42,7 +42,7 @@ public:
* @param page is a pointer to the instance of DPC_page, for which a
* viewable representation is to be rendered.
*/
virtual DPV_pointer render_page( DPV_pointer parent_data, DPC_page* page) {
virtual DPV_pointer render_page( DPV_pointer, DPC_page* ) {
return ( (DPV_pointer)NULL);
};
@ -54,7 +54,7 @@ public:
* @param plot is a pointer to the instance of DPC_plot, for which a
* viewable representation is to be rendered.
*/
virtual DPV_pointer render_plot( DPV_pointer parent_data, DPC_plot* plot) {
virtual DPV_pointer render_plot( DPV_pointer, DPC_plot* ) {
return ( (DPV_pointer)NULL);
};
@ -66,7 +66,7 @@ public:
* @param plot is a pointer to the instance of DPC_table, for which a
* viewable representation is to be rendered.
*/
virtual DPV_pointer render_table( DPV_pointer parent_data, DPC_table *table) {
virtual DPV_pointer render_table( DPV_pointer, DPC_table* ) {
return ( (DPV_pointer)NULL);
};
@ -78,7 +78,7 @@ public:
* @param curve is a pointer to the instance of DPC_curve, for which
* a viewable representation is to be rendered.
*/
virtual DPV_pointer render_curve( DPV_pointer parent_data, DPC_curve* curve) {
virtual DPV_pointer render_curve( DPV_pointer, DPC_curve* ) {
return ( (DPV_pointer)NULL);
};
@ -86,29 +86,29 @@ public:
* Override this member function to perform product view processing after all of
* the subordinate page views have been rendered (by render_page).
*/
virtual void finalize_product_view( DPV_pointer product_view ) {};
virtual void finalize_product_view( DPV_pointer ) {};
/**
* Override this member function to perform page view processing after all of
* the subordinate plot views have been rendered (by render_plot_view).
*/
virtual void finalize_page_view( DPV_pointer page_view ) {};
virtual void finalize_page_view( DPV_pointer ) {};
/**
*/
virtual void finalize_table_view( DPV_pointer table_view ) {};
virtual void finalize_table_view( DPV_pointer ) {};
/**
* Override this member function to perform plot view processing after all of
* the subordinate curve views have been rendered (by render_curve_view).
*/
virtual void finalize_plot_view( DPV_pointer plot_view ) {};
virtual void finalize_plot_view( DPV_pointer ) {};
virtual void notify_product( DPV_pointer product_view, DPV_message msg) {};
virtual void notify_page( DPV_pointer page_view, DPV_message msg) {};
virtual void notify_table( DPV_pointer table_view, DPV_message msg) {};
virtual void notify_plot( DPV_pointer plot_view, DPV_message msg) {};
virtual void notify_curve( DPV_pointer curve_view, DPV_message msg) {};
virtual void notify_product( DPV_pointer, DPV_message ) {};
virtual void notify_page( DPV_pointer, DPV_message ) {};
virtual void notify_table( DPV_pointer, DPV_message ) {};
virtual void notify_plot( DPV_pointer, DPV_message ) {};
virtual void notify_curve( DPV_pointer, DPV_message ) {};
};
#endif

View File

@ -44,8 +44,8 @@ class DSTest : public :: testing::Test {
std::string run(char ch);
char* RUN_dir;
char* VarName;
const char* RUN_dir;
const char* VarName;
std::string output;
int result;
@ -342,8 +342,8 @@ TEST_F(DSTest, DataStream_Delta) {
RUN_dir = NULL;
char DeltaName[1000];
char* a = "sun_predictor.sun.solar_azimuth:../TEST_DATA/BUNCHORUNS/RUN1";
char* b = "sun_predictor.sun.solar_azimuth:../TEST_DATA/BUNCHORUNS/RUN2";
const char* a = "sun_predictor.sun.solar_azimuth:../TEST_DATA/BUNCHORUNS/RUN1";
const char* b = "sun_predictor.sun.solar_azimuth:../TEST_DATA/BUNCHORUNS/RUN2";
sprintf(DeltaName, "delta(%s, %s)", a, b);

View File

@ -28,7 +28,7 @@ DPV_pointer Test_view::render_product( DPC_product* product){
DPV_pointer Test_view::render_page( DPV_pointer parent_data, DPC_page* page) {
const char *temp_cstr;
(void)parent_data;
s << "PAGE VIEW:" << std::endl;
if ((temp_cstr = page->getTitle()) != NULL) {
s << "Page title: " << page->getTitle() << std::endl;
@ -70,7 +70,7 @@ DPV_pointer Test_view::render_page( DPV_pointer parent_data, DPC_page* page) {
DPV_pointer Test_view::render_plot( DPV_pointer parent_data, DPC_plot* plot) {
const char *temp_cstr;
(void)parent_data;
s << "PLOT VIEW:" << std::endl;
if ((temp_cstr = plot->getTitle()) != NULL) {
s << "Plot title: " << plot->getTitle() << std::endl;
@ -117,7 +117,8 @@ DPV_pointer Test_view::render_plot( DPV_pointer parent_data, DPC_plot* plot) {
}
DPV_pointer Test_view::render_table( DPV_pointer parent_data, DPC_table *table) {
const char *temp_cstr;
const char *temp_cstr;
(void)parent_data;
int n_columns, colix;
int i,j;
double time;
@ -189,7 +190,7 @@ DPV_pointer Test_view::render_table( DPV_pointer parent_data, DPC_table *table)
DPV_pointer Test_view::render_curve( DPV_pointer parent_data, DPC_curve* curve) {
int i;
const char *temp_cstr;
(void)parent_data;
s << "CURVE VIEW:" << std::endl;
s << "X Var Name: " << curve->getXVarName() << std::endl;
s << "X Units: " << curve->getXUnits() << std::endl;
@ -254,18 +255,21 @@ DPV_pointer Test_view::render_curve( DPV_pointer parent_data, DPC_curve* curve)
void Test_view::finalize_product_view( DPV_pointer product_view ) {
s << "FINALIZE PRODUCT VIEW." << std::endl;
(void)product_view;
}
void Test_view::finalize_page_view( DPV_pointer page_view ) {
s << "FINALIZE PAGE VIEW." << std::endl;
s << "FINALIZE PAGE VIEW." << std::endl;
(void)page_view;
}
void Test_view::finalize_plot_view( DPV_pointer plot_view ) {
s << "FINALIZE PLOT VIEW." << std::endl;
s << "FINALIZE PLOT VIEW." << std::endl;
(void)plot_view;
}
void Test_view::finalize_table_view( DPV_pointer table_view ) {
s << "FINALIZE TABLE VIEW." << std::endl;
s << "FINALIZE TABLE VIEW." << std::endl;
(void)table_view;
}

View File

@ -26,11 +26,11 @@ class Test_view: public DPV_view {
/**
* The following functions are unused from abstract class DPV_view
*/
void notify_product( DPV_pointer product_view, DPV_message msg) {};
void notify_page( DPV_pointer page_view, DPV_message msg) {};
void notify_table( DPV_pointer table_view, DPV_message msg) {};
void notify_plot( DPV_pointer plot_view, DPV_message msg) {};
void notify_curve( DPV_pointer curve_view, DPV_message msg) {};
void notify_product( DPV_pointer, DPV_message) {};
void notify_page( DPV_pointer, DPV_message) {};
void notify_table( DPV_pointer, DPV_message) {};
void notify_plot( DPV_pointer, DPV_message) {};
void notify_curve( DPV_pointer, DPV_message) {};
std::string getOutput();

View File

@ -22,7 +22,7 @@
#include "trick/JobData.hh"
// Stub for message_publish
extern "C" int message_publish(int level, const char * format_msg, ...) { return 0; }
extern "C" int message_publish(int level, const char * format_msg, ...) { (void)level; (void)format_msg; return 0; }
class BC635ClockTest : public ::testing::Test {

View File

@ -17,7 +17,7 @@
#define TICS_PER_SEC 1000000
// Stub for message_publish
extern "C" int message_publish(int level, const char * format_msg, ...) { return 0; }
extern "C" int message_publish(int level, const char * format_msg, ...) { (void)level; (void)format_msg; return 0; }
class GetTimeOfDayClockTest : public ::testing::Test {

View File

@ -26,7 +26,7 @@
// Stub for message_publish
extern "C" int message_publish(int level, const char * format_msg, ...) { return 0; }
extern "C" int message_publish(int level, const char * format_msg, ...) { (void)level; (void)format_msg; return 0; }
class TPROCTEClockTest : public ::testing::Test {

View File

@ -270,10 +270,10 @@ int Trick::DRHDF5::write_data(bool must_write) {
pthread_mutex_unlock(&buffer_mutex) ;
}
#else
(void)must_write;
#endif
return 0 ;
}
/**

View File

@ -8,14 +8,14 @@
-# ASYNC threads are ready to run if their complete flag is set and either they have
no cycle time or their previous frame just finished.
*/
bool Trick::Executive::isThreadReadyToRun( Trick::Threads * curr_thread , long long time_tics) {
bool Trick::Executive::isThreadReadyToRun( Trick::Threads * curr_thread , long long time_ticks) {
bool ret = false ;
switch ( curr_thread->process_type ) {
case Trick::PROCESS_TYPE_SCHEDULED:
ret = true ;
break ;
case Trick::PROCESS_TYPE_AMF_CHILD:
if ( curr_thread->amf_next_tics == time_tics ) {
if ( curr_thread->amf_next_tics == time_ticks ) {
ret = true ;
}
break ;
@ -24,7 +24,7 @@ bool Trick::Executive::isThreadReadyToRun( Trick::Threads * curr_thread , long l
if (curr_thread->amf_cycle_tics == 0 ) {
ret = true ;
} else {
if ( curr_thread->amf_next_tics == time_tics ) {
if ( curr_thread->amf_next_tics == time_ticks ) {
ret = true ;
}
}

View File

@ -391,9 +391,8 @@ TEST_F(ExecutiveTest , AddDepends) {
TEST_F(ExecutiveTest , UnhandledJobs) {
//req.add_requirement("r_exec_jobs");
//"The Executive Scheduler shall provide the capability to list jobs not handled by any scheduler."
Trick::JobData * curr_job ;
curr_job = so1.add_job(0, 100, "unhandled", NULL, 1, "unhandled_job", "") ;
so1.add_job(0, 100, "unhandled", NULL, 1, "unhandled_job", "") ;
exec_add_sim_object(&so1 , "so1") ;
EXPECT_EQ(exec.check_all_jobs_handled() , 1 ) ;
}

View File

@ -161,12 +161,11 @@ void deriv(BALL *B) {
B->acc[1] = 0;
}
void init(BALL *B, long *tick) {
void init(BALL *B) {
const double initial_speed = 50.0 ;
const double initial_angle = 30.0 ;
tick = 0;
B->pos[0] = 0.0;
B->pos[1] = 0.0;
B->vel[0] = initial_speed * sin(initial_angle * RAD_PER_DEG);
@ -176,11 +175,11 @@ void init(BALL *B, long *tick) {
BALL Ball_sim( Trick::Integrator *integrator) {
BALL ball;
long tick;
long tick = 0;
double sim_time;
// Initialization
init(&ball, &tick);
init(&ball);
// Simulation Loop
do {
@ -202,11 +201,11 @@ BALL Ball_sim( Trick::Integrator *integrator) {
BALL Ball_eulercromer_sim( Trick::Euler_Cromer_Integrator *integrator ) {
BALL ball;
long tick;
long tick = 0;
double sim_time;
// Initialization
init(&ball, &tick);
init(&ball);
// Simulation Loop
do {

View File

@ -24,12 +24,8 @@ Trick::JSONVariableServer::JSONVariableServer() :
}
Trick::JSONVariableServer::~JSONVariableServer() {
if ( listen_dev.hostname != NULL ) {
free(listen_dev.hostname) ;
}
if ( listen_dev.error_handler != NULL ) {
free(listen_dev.error_handler) ;
}
}
const char * Trick::JSONVariableServer::get_hostname() {

View File

@ -60,7 +60,7 @@ class UDT2 {
double A;
double B;
double C;
char* ss;
const char* ss;
UDT1 udt1;
UDT1* udt1_p;
};

View File

@ -26,7 +26,7 @@ Trick::MessageTCDeviceListenThread::MessageTCDeviceListenThread(MessageTCDevice
Trick::MessageTCDeviceListenThread::~MessageTCDeviceListenThread() {
free(listen_dev.error_handler) ;
if ( listen_dev.hostname ) {
free(listen_dev.hostname) ;
free((char*)listen_dev.hostname) ;
}
close(listen_dev.socket) ;
}

View File

@ -60,13 +60,12 @@ TEST_F(ITimerTest, TimerNotEnabled) {
//"The ITimer shall start if and only if the ITimer is enabled to do so.");
bool active_ch, enable_ch;
bool active_ch;
Trick::ITimer *iTim;
iTim = new Trick::ITimer;
active_ch = iTim->active;
enable_ch = iTim->get_enabled();
sec = 0.05;
iTim->init();

View File

@ -21,6 +21,7 @@ int Trick::UdUnits::read_default_xml() {
}
int Trick::UdUnits::read_user_xml(std::string file_name) {
(void)file_name;
return 0 ;
}

View File

@ -26,12 +26,8 @@ Trick::VariableServerListenThread::VariableServerListenThread() :
}
Trick::VariableServerListenThread::~VariableServerListenThread() {
if ( listen_dev.hostname != NULL ) {
free(listen_dev.hostname) ;
}
if ( listen_dev.error_handler != NULL ) {
free(listen_dev.error_handler) ;
}
}
const char * Trick::VariableServerListenThread::get_hostname() {

View File

@ -19,8 +19,8 @@ class TCConnectTest : public testing::Test {
/* device */
device = (TCDevice *) malloc(sizeof(TCDevice));
memset( (void *)device,'\0',sizeof(TCDevice) );
device->hostname = "127.0.0.1";
memset( (void *)device,'\0',sizeof(device) );
device->hostname = strdup("127.0.0.1");
device->disabled = TC_COMM_FALSE;
device->disable_handshaking = TC_COMM_DISABLED;
strcpy(device->client_tag, "<empty>");