Commit 46690d9e authored by Murray Cumming's avatar Murray Cumming
Browse files

get_text_for_gda_value(): Use setprecision() on the stringstream.

To avoid losing precision when representing a GdaNumeric value as a string.

And check this in test_field_file_format(), though a direct test too would
be better.

This should fix bug #763229 (m.rick.mac)
parent 9898028b
......@@ -497,6 +497,9 @@ Glib::ustring Conversions::get_text_for_gda_value(Field::glom_field_type glom_ty
std::stringstream another_stream;
another_stream.imbue(locale); //Tell it to parse stuff as per this locale.
constexpr auto precision = std::numeric_limits<decltype(number)>::maxdigits10;
another_stream << std::setprecision(precision);
//Numeric formatting:
if(!iso_format)
{
......
......@@ -39,6 +39,7 @@ static bool test_value(Glom::Field::glom_field_type field_type, const Gnome::Gda
if(value != value_retrieved)
{
std::cerr << "Unexpected: value=" << value.to_string() << ", value_retrieved=" << value_retrieved.to_string() << std::endl;
std::cerr << " value_retrieved type=" << g_type_name(value_retrieved.get_value_type()) << ", value type=" << g_type_name(value.get_value_type()) << std::endl;
return false;
}
......@@ -87,6 +88,9 @@ int main()
if(!test_value(Glom::Field::glom_field_type::NUMERIC, Glom::Conversions::parse_value((double)3.91l)))
return EXIT_FAILURE;
if(!test_value(Glom::Field::glom_field_type::NUMERIC, Glom::Conversions::parse_value(1004914l)))
return EXIT_FAILURE;
//TODO: Image.
......
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