Commit fa795f3d authored by Pavel Vainerman's avatar Pavel Vainerman

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

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