Commit fa795f3d authored by Pavel Vainerman's avatar Pavel Vainerman

(UniXML): исправил ошибку в реализации фунции getPIntProp()

для отрицательных чисел и нуля.
parent f769de6a
......@@ -11,7 +11,7 @@
Name: libuniset2
Version: 2.0
Release: alt8
Release: alt9
Summary: UniSet - library for building distributed industrial control systems
......@@ -404,6 +404,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
%exclude %_pkgconfigdir/libUniSet2.pc
%changelog
* Mon Oct 20 2014 Pavel Vainerman <pv@altlinux.ru> 2.0-alt9
- fixed bug in UniXML::iterator getPIntProp() for prop<=0
* Wed Oct 08 2014 Pavel Vainerman <pv@altlinux.ru> 2.0-alt8
- added unit-tests (use "catch" test unit framework)
- added use autoconf testsuite
......
......@@ -134,7 +134,7 @@ int UniXML::getIntProp(const xmlNode* node, const string& name )
int UniXML::getPIntProp(const xmlNode* node, const string& name, int def )
{
string param = getProp(node,name);
string param( getProp(node,name) );
if( param.empty() )
return def;
......@@ -410,10 +410,11 @@ int UniXML_iterator::getIntProp( const string& name )
int UniXML_iterator::getPIntProp( const string& name, int def )
{
int i = getIntProp(name);
if (i <= 0)
string param( getProp(name) );
if( param.empty() )
return def;
return i;
return UniSetTypes::uni_atoi(param);
}
// -------------------------------------------------------------------------
......
......@@ -35,7 +35,7 @@
<LogServer name="smplus" port="3333" host="localhost" />
<settings>
<TestData x="10" y="100" text="text"/>
<TestData x="10" y="100" text="text" zero="0" negative="-10"/>
<TestNode name="TestNode1"/>
<TestNode name="TestNode2"/>
<TestNode name="TestNode3"/>
......
......@@ -103,6 +103,8 @@ TEST_CASE("UniXML", "[UniXML]" )
CHECK( it.getProp("text") == "text" );
CHECK( it.getIntProp("x") == 10 );
CHECK( it.getPIntProp("y",-20) == 100 );
CHECK( it.getPIntProp("zero",20) == 0 );
CHECK( it.getPIntProp("negative",20) == -10 );
CHECK( it.getPIntProp("unknown",20) == 20 );
}
}
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