Commit 71691352 authored by Pavel Vainerman's avatar Pavel Vainerman

Корректировка по результатам прогона valgrind

и мелкие исправления форматирования
parent 4bd9e8d9
...@@ -44,7 +44,6 @@ opCheckPause(50) ...@@ -44,7 +44,6 @@ opCheckPause(50)
SQLiteInterface::~SQLiteInterface() SQLiteInterface::~SQLiteInterface()
{ {
close(); close();
delete db;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
...@@ -261,7 +260,7 @@ SQLiteResult::SQLiteResult( sqlite3_stmt* s, bool finalize ) ...@@ -261,7 +260,7 @@ SQLiteResult::SQLiteResult( sqlite3_stmt* s, bool finalize )
COL c; COL c;
for( unsigned int i=0; i<n; i++ ) for( int i=0; i<n; i++ )
{ {
char* p = (char*)sqlite3_column_text(s,i); char* p = (char*)sqlite3_column_text(s,i);
if( p ) if( p )
......
...@@ -72,15 +72,15 @@ static UniSetUDP::UDPMessage receive( unsigned int pnum = 0, timeout_t tout = 20 ...@@ -72,15 +72,15 @@ static UniSetUDP::UDPMessage receive( unsigned int pnum = 0, timeout_t tout = 20
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void send( UniSetUDP::UDPMessage& pack, int tout=2000 ) void send( UniSetUDP::UDPMessage& pack, int tout=2000 )
{ {
CHECK( udp_s->isPending(ost::Socket::pendingOutput,tout) ); CHECK( udp_s->isPending(ost::Socket::pendingOutput,tout) );
pack.nodeID = s_nodeID; pack.nodeID = s_nodeID;
pack.procID = s_procID; pack.procID = s_procID;
pack.num = s_numpack++; pack.num = s_numpack++;
UniSetUDP::UDPPacket s_buf; UniSetUDP::UDPPacket s_buf;
pack.transport_msg(s_buf); pack.transport_msg(s_buf);
size_t ret = udp_s->send((char*)&s_buf.data, s_buf.len); size_t ret = udp_s->send((char*)&s_buf.data, s_buf.len);
REQUIRE( ret == s_buf.len ); REQUIRE( ret == s_buf.len );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -216,45 +216,45 @@ TEST_CASE("[UNetUDP]: check receiver","[unetudp][receiver]") ...@@ -216,45 +216,45 @@ TEST_CASE("[UNetUDP]: check receiver","[unetudp][receiver]")
SECTION("Test: send data pack...") SECTION("Test: send data pack...")
{ {
REQUIRE( ui->getValue(node2_respond_s) == 0 ); REQUIRE( ui->getValue(node2_respond_s) == 0 );
UniSetUDP::UDPMessage pack; UniSetUDP::UDPMessage pack;
pack.addAData(8,100); pack.addAData(8,100);
pack.addAData(9,-100); pack.addAData(9,-100);
pack.addDData(10,true); pack.addDData(10,true);
pack.addDData(11,false); pack.addDData(11,false);
REQUIRE( ui->getValue(8) == 0 ); REQUIRE( ui->getValue(8) == 0 );
REQUIRE( ui->getValue(9) == 0 ); REQUIRE( ui->getValue(9) == 0 );
REQUIRE( ui->getValue(10) == 0 ); REQUIRE( ui->getValue(10) == 0 );
REQUIRE( ui->getValue(11) == 0 ); REQUIRE( ui->getValue(11) == 0 );
send(pack); send(pack);
msleep(120); msleep(120);
REQUIRE( ui->getValue(8) == 100 ); REQUIRE( ui->getValue(8) == 100 );
REQUIRE( ui->getValue(9) == -100 ); REQUIRE( ui->getValue(9) == -100 );
REQUIRE( ui->getValue(10) == 1 ); REQUIRE( ui->getValue(10) == 1 );
REQUIRE( ui->getValue(11) == 0 ); REQUIRE( ui->getValue(11) == 0 );
msleep(1000); msleep(1500);
REQUIRE( ui->getValue(node2_respond_s) == 1 ); REQUIRE( ui->getValue(node2_respond_s) == 1 );
} }
SECTION("Test: send data pack2..") SECTION("Test: send data pack2..")
{ {
UniSetUDP::UDPMessage pack; UniSetUDP::UDPMessage pack;
pack.addAData(8,10); pack.addAData(8,10);
pack.addAData(9,-10); pack.addAData(9,-10);
pack.addDData(10,false); pack.addDData(10,false);
pack.addDData(11,true); pack.addDData(11,true);
send(pack); send(pack);
msleep(120); msleep(120);
REQUIRE( ui->getValue(8) == 10 ); REQUIRE( ui->getValue(8) == 10 );
REQUIRE( ui->getValue(9) == -10 ); REQUIRE( ui->getValue(9) == -10 );
REQUIRE( ui->getValue(10) == 0 ); REQUIRE( ui->getValue(10) == 0 );
REQUIRE( ui->getValue(11) == 1 ); REQUIRE( ui->getValue(11) == 1 );
REQUIRE( ui->getValue(node2_respond_s) == 1 ); REQUIRE( ui->getValue(node2_respond_s) == 1 );
msleep(3000); // в запускающем файле стоит --unet-recv-timeout 2000 msleep(2000); // в запускающем файле стоит --unet-recv-timeout 2000
REQUIRE( ui->getValue(node2_respond_s) == 0 ); REQUIRE( ui->getValue(node2_respond_s) == 0 );
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -25,6 +25,7 @@ struct IOBase ...@@ -25,6 +25,7 @@ struct IOBase
IOBase( IOBase&& r ) = default; IOBase( IOBase&& r ) = default;
IOBase& operator=(IOBase&& r) = default; IOBase& operator=(IOBase&& r) = default;
~IOBase();
IOBase(): IOBase():
stype(UniversalIO::UnknownIOType), stype(UniversalIO::UnknownIOType),
cdiagram(nullptr), cdiagram(nullptr),
......
#include "Configuration.h" #include "Configuration.h"
#include "Extensions.h" #include "Extensions.h"
#include "IOBase.h" #include "IOBase.h"
...@@ -11,6 +12,11 @@ std::ostream& operator<<( std::ostream& os, IOBase& inf ) ...@@ -11,6 +12,11 @@ std::ostream& operator<<( std::ostream& os, IOBase& inf )
<< " default=" << inf.defval << " safety=" << inf.safety; << " default=" << inf.defval << " safety=" << inf.safety;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
IOBase::~IOBase()
{
delete cdiagram;
}
// -----------------------------------------------------------------------------
bool IOBase::check_channel_break( long val ) bool IOBase::check_channel_break( long val )
{ {
// порог не задан... (проверка отключена) // порог не задан... (проверка отключена)
......
...@@ -62,4 +62,6 @@ TEST_CASE("Calibration","[calibration]") ...@@ -62,4 +62,6 @@ TEST_CASE("Calibration","[calibration]")
REQUIRE( cal->getLeftRaw() == -1000 ); REQUIRE( cal->getLeftRaw() == -1000 );
REQUIRE( cal->getRightRaw() == 1000 ); REQUIRE( cal->getRightRaw() == 1000 );
} }
delete cal;
} }
...@@ -129,8 +129,8 @@ namespace UniSetTypes ...@@ -129,8 +129,8 @@ namespace UniSetTypes
repName(0),textName(0),data(0){} repName(0),textName(0),data(0){}
ObjectId id; /*!< идентификатор */ ObjectId id; /*!< идентификатор */
char* repName; /*!< текстовое имя для регистрации в репозитории */ char* repName; /*!< текстовое имя для регистрации в репозитории */
char* textName; /*!< текстовое имя */ char* textName; /*!< текстовое имя */
void* data; void* data;
inline bool operator < ( const ObjectInfo& o ) const inline bool operator < ( const ObjectInfo& o ) const
...@@ -154,6 +154,8 @@ namespace UniSetTypes ...@@ -154,6 +154,8 @@ namespace UniSetTypes
return uni_atoi(str.c_str()); return uni_atoi(str.c_str());
} }
char* uni_strdup( const std::string& src );
std::string timeToString(time_t tm=time(0), const std::string& brk=":"); /*!< Преобразование времени в строку HH:MM:SS */ std::string timeToString(time_t tm=time(0), const std::string& brk=":"); /*!< Преобразование времени в строку HH:MM:SS */
std::string dateToString(time_t tm=time(0), const std::string& brk="/"); /*!< Преобразование даты в строку DD/MM/YYYY */ std::string dateToString(time_t tm=time(0), const std::string& brk="/"); /*!< Преобразование даты в строку DD/MM/YYYY */
......
...@@ -76,8 +76,8 @@ namespace ORepHelpers ...@@ -76,8 +76,8 @@ namespace ORepHelpers
CosNaming::NamingContext_var ctx; CosNaming::NamingContext_var ctx;
try try
{ {
CORBA::Object_var o = rootC->resolve(ctxName); CORBA::Object_var o = rootC->resolve( ctxName.in() );
ctx = CosNaming::NamingContext::_narrow(o); ctx = CosNaming::NamingContext::_narrow(o.in());
if( CORBA::is_nil(ctx) ) if( CORBA::is_nil(ctx) )
{ {
const string err("OREPHELPER(getContext): не смог получить ссылку на контекст(is_nil) "+cname); const string err("OREPHELPER(getContext): не смог получить ссылку на контекст(is_nil) "+cname);
......
...@@ -48,6 +48,11 @@ omap(minSize) ...@@ -48,6 +48,11 @@ omap(minSize)
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
ObjectIndex_XML::~ObjectIndex_XML() ObjectIndex_XML::~ObjectIndex_XML()
{ {
for( auto& it: omap )
{
delete[] it.repName;
delete[] it.textName;
}
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
ObjectId ObjectIndex_XML::getIdByName( const string& name ) ObjectId ObjectIndex_XML::getIdByName( const string& name )
...@@ -173,7 +178,9 @@ unsigned int ObjectIndex_XML::read_section( const std::shared_ptr<UniXML>& xml, ...@@ -173,7 +178,9 @@ unsigned int ObjectIndex_XML::read_section( const std::shared_ptr<UniXML>& xml,
omap[ind].id = ind; omap[ind].id = ind;
// name // name
const string name(secname + xml->getProp(it,"name")); ostringstream n;
n << secname << xml->getProp(it,"name");
const string name(n.str());
delete[] omap[ind].repName; delete[] omap[ind].repName;
omap[ind].repName = new char[name.size()+1]; omap[ind].repName = new char[name.size()+1];
strcpy( omap[ind].repName, name.c_str() ); strcpy( omap[ind].repName, name.c_str() );
......
...@@ -26,6 +26,11 @@ ObjectIndex_idXML::ObjectIndex_idXML( const shared_ptr<UniXML>& xml ) ...@@ -26,6 +26,11 @@ ObjectIndex_idXML::ObjectIndex_idXML( const shared_ptr<UniXML>& xml )
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
ObjectIndex_idXML::~ObjectIndex_idXML() ObjectIndex_idXML::~ObjectIndex_idXML()
{ {
for( auto& it: omap )
{
delete[] it.second.repName;
delete[] it.second.textName;
}
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
ObjectId ObjectIndex_idXML::getIdByName( const string& name ) ObjectId ObjectIndex_idXML::getIdByName( const string& name )
...@@ -142,7 +147,9 @@ void ObjectIndex_idXML::read_section( const std::shared_ptr<UniXML>& xml, const ...@@ -142,7 +147,9 @@ void ObjectIndex_idXML::read_section( const std::shared_ptr<UniXML>& xml, const
} }
// name // name
string name( secname+it.getProp("name") ); ostringstream n;
n << secname << it.getProp("name");
string name(n.str());
inf.repName = new char[name.size()+1]; inf.repName = new char[name.size()+1];
strcpy( inf.repName, name.c_str() ); strcpy( inf.repName, name.c_str() );
......
...@@ -401,3 +401,12 @@ int UniSetTypes::uni_atoi( const char* str ) ...@@ -401,3 +401,12 @@ int UniSetTypes::uni_atoi( const char* str )
return n; return n;
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
char* UniSetTypes::uni_strdup( const string& src )
{
const char* s = src.c_str();
size_t len = strlen(s);
char* d = new char[len+1];
memcpy(d,s,len+1);
return d;
}
// -------------------------------------------------------------------------
...@@ -70,7 +70,7 @@ uxml(0) ...@@ -70,7 +70,7 @@ uxml(0)
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
NCRestorer_XML::~NCRestorer_XML() NCRestorer_XML::~NCRestorer_XML()
{ {
if( uxml) if( uxml )
{ {
uxml->close(); uxml->close();
uxml.reset(); uxml.reset();
......
...@@ -71,8 +71,6 @@ ostream& UniSetTypes::Configuration::help(ostream& os) ...@@ -71,8 +71,6 @@ ostream& UniSetTypes::Configuration::help(ostream& os)
<< "--ulog-add-levels level1,info,system,warn --ulog-log-in-file myprogrpam.log\n\n"; << "--ulog-add-levels level1,info,system,warn --ulog-log-in-file myprogrpam.log\n\n";
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
namespace UniSetTypes namespace UniSetTypes
{ {
DebugStream ulog; DebugStream ulog;
...@@ -105,6 +103,10 @@ Configuration::Configuration(): ...@@ -105,6 +103,10 @@ Configuration::Configuration():
Configuration::~Configuration() Configuration::~Configuration()
{ {
for( int i=0; i<_argc; i++ )
delete[] _argv[i];
delete[] _argv;
} }
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
...@@ -258,8 +260,6 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -258,8 +260,6 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
setLocalNode(lnode); setLocalNode(lnode);
initParameters(); initParameters();
initRepSections(); initRepSections();
// localIOR // localIOR
...@@ -285,12 +285,12 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -285,12 +285,12 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
// +N --> -ORBIniRef NodeName= // +N --> -ORBIniRef NodeName=
// +2 --> -ORBIniRef NameService= // +2 --> -ORBIniRef NameService=
_argc = argc+2*lnodes.size()+2; _argc = argc+2*lnodes.size()+2;
const char** new_argv = new const char*[_argc]; const char** new_argv = new const char*[_argc];
int i = 0; int i = 0;
// перегоняем старые параметры // перегоняем старые параметры
for( ; i < argc; i++ ) for( ; i < argc; i++ )
new_argv[i] = strdup(argv[i]); new_argv[i] = uni_strdup(argv[i]);
// формируем новые, используя i в качестве индекса // формируем новые, используя i в качестве индекса
for( auto &it: lnodes ) for( auto &it: lnodes )
...@@ -302,12 +302,13 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -302,12 +302,13 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
param << this << name; param << this << name;
name = param.str(); name = param.str();
param << "=corbaname::" << it.host << ":" << it.port; param << "=corbaname::" << it.host << ":" << it.port;
new_argv[i+1] = strdup(param.str().c_str()); const string sparam(param.str());
new_argv[i+1] = uni_strdup(sparam);
uinfo << "(Configuration): внесли параметр " << param.str() << endl; uinfo << "(Configuration): внесли параметр " << sparam << endl;
i+=2; i+=2;
ostringstream uri; ostringstream uri;
uri << "corbaname::" << it.host << ":" << it.port; uri << "corbaname::" << it.host << ":" << it.port;
if( !omni::omniInitialReferences::setFromArgs(name.c_str(), uri.str().c_str()) ) if( !omni::omniInitialReferences::setFromArgs(name.c_str(), uri.str().c_str()) )
cerr << "**********************!!!! FAILED ADD name=" << name << " uri=" << uri.str() << endl; cerr << "**********************!!!! FAILED ADD name=" << name << " uri=" << uri.str() << endl;
...@@ -324,20 +325,21 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -324,20 +325,21 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
if( !nsnode ) if( !nsnode )
{ {
uwarn << "(Configuration): не нашли раздела 'NameService' \n"; uwarn << "(Configuration): не нашли раздела 'NameService' \n";
new_argv[i] = ""; new_argv[i] = "";
new_argv[i+1] = ""; new_argv[i+1] = "";
} }
else else
{ {
new_argv[i] = "-ORBInitRef"; new_argv[i] = "-ORBInitRef";
new_argv[i+1] = ""; // сперва инициализиуем пустой строкой (т.к. будет вызываться getArgParam) new_argv[i+1] = ""; // сперва инициализиуем пустой строкой (т.к. будет вызываться getArgParam)
string defPort( getPort( getProp(nsnode,"port") ) ); // здесь вызывается getArgParam! проходящий по _argv string defPort( getPort( getProp(nsnode,"port") ) ); // здесь вызывается getArgParam! проходящий по _argv
ostringstream param; ostringstream param;
param << this << "NameService=corbaname::" << getProp(nsnode,"host") << ":" << defPort; param << this << "NameService=corbaname::" << getProp(nsnode,"host") << ":" << defPort;
new_argv[i+1] = strdup(param.str().c_str()); const string sparam(param.str());
uinfo << "(Configuration): внесли параметр " << param.str() << endl; new_argv[i+1] = uni_strdup(sparam);
uinfo << "(Configuration): внесли параметр " << sparam << endl;
{ {
ostringstream ns_name; ostringstream ns_name;
...@@ -345,12 +347,12 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -345,12 +347,12 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
ostringstream uri; ostringstream uri;
uri << "corbaname::" << getProp(nsnode,"host") << ":" << defPort; uri << "corbaname::" << getProp(nsnode,"host") << ":" << defPort;
if( !omni::omniInitialReferences::setFromArgs(ns_name.str().c_str(), uri.str().c_str()) ) if( !omni::omniInitialReferences::setFromArgs(ns_name.str().c_str(), uri.str().c_str()) )
cerr << "**********************!!!! FAILED ADD name=" <<ns_name << " uri=" << uri.str() << endl; cerr << "**********************!!!! FAILED ADD name=" << ns_name << " uri=" << uri.str() << endl;
} }
} }
_argv = new_argv; _argv = new_argv;
// ------------- CORBA INIT ------------- // ------------- CORBA INIT -------------
// orb init // orb init
orb = CORBA::ORB_init(_argc,(char**)_argv); orb = CORBA::ORB_init(_argc,(char**)_argv);
// create policy // create policy
...@@ -373,10 +375,10 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -373,10 +375,10 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
pl[1] = root_poa->create_servant_retention_policy(PortableServer::RETAIN); pl[1] = root_poa->create_servant_retention_policy(PortableServer::RETAIN);
pl[2] = root_poa->create_request_processing_policy(PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY); pl[2] = root_poa->create_request_processing_policy(PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY);
// pl[3] = root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL); // pl[3] = root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL);
} }
policyList = pl; policyList = pl;
// --------------------------------------- // ---------------------------------------
} }
catch( Exception& ex ) catch( Exception& ex )
...@@ -772,6 +774,13 @@ xmlNode* Configuration::initDebug( DebugStream& deb, const string& _debname ) ...@@ -772,6 +774,13 @@ xmlNode* Configuration::initDebug( DebugStream& deb, const string& _debname )
return dnode; return dnode;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
static std::string makeSecName( const std::string& sec, const std::string& name )
{
ostringstream n;
n << sec << "/" << name;
return std::move(n.str());
}
// -------------------------------------------------------------------------
void Configuration::initRepSections() void Configuration::initRepSections()
{ {
// Реализация под жёсткую структуру репозитория // Реализация под жёсткую структуру репозитория
...@@ -784,13 +793,13 @@ void Configuration::initRepSections() ...@@ -784,13 +793,13 @@ void Configuration::initRepSections()
throw SystemError(msg.str()); throw SystemError(msg.str());
} }
secRoot = unixml->getProp(node,"name"); secRoot = unixml->getProp(node,"name");
secSensors = secRoot + "/" + getRepSectionName("sensors",xmlSensorsSec); secSensors = makeSecName(secRoot, getRepSectionName("sensors",xmlSensorsSec));
secObjects = secRoot + "/" + getRepSectionName("objects",xmlObjectsSec); secObjects = makeSecName(secRoot, getRepSectionName("objects",xmlObjectsSec));
secControlles = secRoot + "/" + getRepSectionName("controllers",xmlControllersSec); secControlles = makeSecName(secRoot, getRepSectionName("controllers",xmlControllersSec));
secServices = secRoot + "/" + getRepSectionName("services",xmlServicesSec); secServices = makeSecName(secRoot, getRepSectionName("services",xmlServicesSec));
} }
// -------------------------------------------------------------------------
string Configuration::getRepSectionName( const string& sec, xmlNode* secnode ) string Configuration::getRepSectionName( const string& sec, xmlNode* secnode )
{ {
xmlNode* node = unixml->findNode(unixml->getFirstNode(),sec); xmlNode* node = unixml->findNode(unixml->getFirstNode(),sec);
...@@ -808,7 +817,7 @@ string Configuration::getRepSectionName( const string& sec, xmlNode* secnode ) ...@@ -808,7 +817,7 @@ string Configuration::getRepSectionName( const string& sec, xmlNode* secnode )
if( ret.empty() ) if( ret.empty() )
ret = unixml->getProp(node,"name"); ret = unixml->getProp(node,"name");
return ret; return std::move(ret);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void Configuration::setConfFileName( const string& fn ) void Configuration::setConfFileName( const string& fn )
......
...@@ -43,34 +43,34 @@ TEST_CASE("CallbackTimer", "[CallbackTimer]" ) ...@@ -43,34 +43,34 @@ TEST_CASE("CallbackTimer", "[CallbackTimer]" )
tmr.run(); tmr.run();
msleep(60); msleep(60);
REQUIRE( tc.getNum1() == 1 ); REQUIRE( tc.getNum1() >= 1 );
REQUIRE( tc.getNum2() == 0 ); REQUIRE( tc.getNum2() == 0 );
REQUIRE( tc.getNum3() == 0 ); REQUIRE( tc.getNum3() == 0 );
msleep(110); msleep(110);
REQUIRE( tc.getNum1() == 3 ); REQUIRE( tc.getNum1() >= 3 );
REQUIRE( tc.getNum2() == 1 ); REQUIRE( tc.getNum2() >= 1 );
REQUIRE( tc.getNum3() == 0 ); REQUIRE( tc.getNum3() == 0 );
msleep(210); msleep(210);
REQUIRE( tc.getNum1() == 7 ); REQUIRE( tc.getNum1() >= 7 );
REQUIRE( tc.getNum2() == 2 ); REQUIRE( tc.getNum2() >= 2 );
REQUIRE( tc.getNum3() == 1 ); REQUIRE( tc.getNum3() == 1 );
tmr.remove(1); tmr.remove(1);
msleep(60); msleep(60);
REQUIRE( tc.getNum1() == 7 ); REQUIRE( tc.getNum1() >= 7 );
tmr.terminate(); tmr.terminate();
REQUIRE( tc.getNum2() == 2 ); REQUIRE( tc.getNum2() >= 2 );
REQUIRE( tc.getNum3() == 1 ); REQUIRE( tc.getNum3() >= 1 );
} }
SECTION("other tests") SECTION("other tests")
{ {
MyTestClass tc; MyTestClass tc;
CallbackTimer<MyTestClass> tmr(&tc,&MyTestClass::Time); CallbackTimer<MyTestClass> tmr(&tc,&MyTestClass::Time);
int i=0; unsigned int i = 0;
for( ;i<tmr.MAXCallbackTimer; i++ ) for( ;i<tmr.MAXCallbackTimer; i++ )
tmr.add(i,100 ); tmr.add(i,100 );
......
#include <catch.hpp> #include <catch.hpp>
// -----------------------------------------------------------------------------
#include <sstream> #include <sstream>
#include <limits> #include <limits>
#include "UniSetTypes.h" #include "UniSetTypes.h"
// -----------------------------------------------------------------------------
using namespace std; using namespace std;
using namespace UniSetTypes; using namespace UniSetTypes;
// -----------------------------------------------------------------------------
TEST_CASE("UniSetTypes: uni_atoi", "[utypes][uni_atoi]" ) TEST_CASE("UniSetTypes: uni_atoi", "[utypes][uni_atoi]" )
{ {
SECTION("int") SECTION("int")
...@@ -52,4 +53,24 @@ TEST_CASE("UniSetTypes: uni_atoi", "[utypes][uni_atoi]" ) ...@@ -52,4 +53,24 @@ TEST_CASE("UniSetTypes: uni_atoi", "[utypes][uni_atoi]" )
WARN("Tests for 'UniSetTypes' incomplete..."); WARN("Tests for 'UniSetTypes' incomplete...");
} }
// -----------------------------------------------------------------------------
TEST_CASE("UniSetTypes: uni_strdup", "[utypes][uni_strdup]" )
{
SECTION("uni_strdup string")
{
string str("Test string");
const char* cp = uni_strdup(str);
string str2(cp);
REQUIRE( str == str2 );
delete[] cp;
}
SECTION("uni_strdup char*")
{
const char* str = "Test string";
char* str2 = uni_strdup(str);
REQUIRE( !strcmp(str,str2) );
delete[] str2;
}
}
// -----------------------------------------------------------------------------
{
sed
Memcheck:Leak
...
obj:/bin/sed
}
{
ps
Memcheck:Leak
...
obj:/bin/ps
}
{
bash
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:xmalloc
fun:make_if_command
fun:yyparse
fun:parse_command
fun:read_command
fun:reader_loop
}
{
omniORB
Memcheck:Leak
...
obj:/usr/lib/libomniORB4.so.*
}
{
omniNames
Memcheck:Leak
...
obj:/usr/bin/omniNames
}
{
libxml2
Memcheck:Leak
...
obj:/usr/lib/libxml2.so.*
}
#{
# libstdc++
# Memcheck:Leak
# ...
# /usr/lib/libstdc++.so.*
#}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment