Skip to content

Commit

Permalink
fixed #13606 - fixed precision of float values in ValueFlow XML debug…
Browse files Browse the repository at this point in the history
… output
  • Loading branch information
firewave committed Feb 6, 2025
1 parent f327920 commit f19ddb1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "astutils.h"
#include "errortypes.h"
#include "library.h"
#include "mathlib.h"
#include "settings.h"
#include "simplecpp.h"
#include "symboldatabase.h"
Expand Down Expand Up @@ -1801,7 +1802,7 @@ void Token::printValueFlow(bool xml, std::ostream &out) const
break;
case ValueFlow::Value::ValueType::FLOAT:
outs += "floatvalue=\"";
outs += std::to_string(value.floatValue); // TODO: should this be MathLib::toString()?
outs += MathLib::toString(value.floatValue);
outs += '\"';
break;
case ValueFlow::Value::ValueType::MOVED:
Expand Down Expand Up @@ -1875,7 +1876,6 @@ void Token::printValueFlow(bool xml, std::ostream &out) const

outs += "/>\n";
}

else {
if (&value != &values->front())
outs += ",";
Expand Down
6 changes: 3 additions & 3 deletions test/cli/other_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3129,8 +3129,8 @@ def test_debug_valueflow_xml(tmp_path): # #13606
value_elem = valueflow_elem[0].findall('values/value')
assert len(value_elem) == 3
assert 'floatvalue' in value_elem[0].attrib
assert value_elem[0].attrib['floatvalue'] == '0.000000'
assert value_elem[0].attrib['floatvalue'] == '1e-07'
assert 'floatvalue' in value_elem[1].attrib
assert value_elem[1].attrib['floatvalue'] == '0.000000'
assert value_elem[1].attrib['floatvalue'] == '1e-07'
assert 'floatvalue' in value_elem[2].attrib
assert value_elem[2].attrib['floatvalue'] == '0.000000'
assert value_elem[2].attrib['floatvalue'] == '1e-07'

0 comments on commit f19ddb1

Please sign in to comment.