mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
parent
297b331435
commit
33dd551598
|
@ -176,7 +176,8 @@ public:
|
||||||
}
|
}
|
||||||
char buf[30];
|
char buf[30];
|
||||||
assert(s.size() < sizeof(buf));
|
assert(s.size() < sizeof(buf));
|
||||||
auto copy_end = std::copy(s.begin(), s.end(), buf);
|
const char *cstr = s.c_str();
|
||||||
|
auto copy_end = std::copy(cstr, cstr + s.size() + 1, buf);
|
||||||
convert_pt_to_comma(buf, static_cast<size_t>(copy_end - buf));
|
convert_pt_to_comma(buf, static_cast<size_t>(copy_end - buf));
|
||||||
double d = strtod(buf, &end_of_convert);
|
double d = strtod(buf, &end_of_convert);
|
||||||
*len_converted = end_of_convert - buf;
|
*len_converted = end_of_convert - buf;
|
||||||
|
|
BIN
tests/data/Issue714_local_comma.xlsx
Normal file
BIN
tests/data/Issue714_local_comma.xlsx
Normal file
Binary file not shown.
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <xlnt/utils/numeric.hpp>
|
#include <xlnt/utils/numeric.hpp>
|
||||||
#include <helpers/test_suite.hpp>
|
#include <helpers/test_suite.hpp>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
class numeric_test_suite : public test_suite
|
class numeric_test_suite : public test_suite
|
||||||
{
|
{
|
||||||
|
@ -36,6 +37,7 @@ public:
|
||||||
register_test(test_min);
|
register_test(test_min);
|
||||||
register_test(test_max);
|
register_test(test_max);
|
||||||
register_test(test_abs);
|
register_test(test_abs);
|
||||||
|
register_test(test_locale_comma);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_serialise_number()
|
void test_serialise_number()
|
||||||
|
@ -219,5 +221,18 @@ public:
|
||||||
|
|
||||||
static_assert(xlnt::detail::abs(-1.23) == 1.23, "constexpr");
|
static_assert(xlnt::detail::abs(-1.23) == 1.23, "constexpr");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_locale_comma ()
|
||||||
|
{
|
||||||
|
struct SetLocale
|
||||||
|
{
|
||||||
|
SetLocale() {xlnt_assert(setlocale(LC_ALL, "de_DE") != nullptr);} // If failed, please install de_DE locale to correctly run this test.
|
||||||
|
~SetLocale() {setlocale(LC_ALL, "C");}
|
||||||
|
} setLocale;
|
||||||
|
|
||||||
|
xlnt::detail::number_serialiser serialiser;
|
||||||
|
xlnt_assert(serialiser.deserialise("1.99999999") == 1.99999999);
|
||||||
|
xlnt_assert(serialiser.deserialise("1.1") == 1.1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
static numeric_test_suite x;
|
static numeric_test_suite x;
|
||||||
|
|
|
@ -73,6 +73,7 @@ public:
|
||||||
register_test(test_Issue503_external_link_load);
|
register_test(test_Issue503_external_link_load);
|
||||||
register_test(test_formatting);
|
register_test(test_formatting);
|
||||||
register_test(test_active_sheet);
|
register_test(test_active_sheet);
|
||||||
|
register_test(test_locale_comma);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool workbook_matches_file(xlnt::workbook &wb, const xlnt::path &file)
|
bool workbook_matches_file(xlnt::workbook &wb, const xlnt::path &file)
|
||||||
|
@ -808,6 +809,21 @@ public:
|
||||||
wb.load(path_helper::test_file("20_active_sheet.xlsx"));
|
wb.load(path_helper::test_file("20_active_sheet.xlsx"));
|
||||||
xlnt_assert_equals(wb.active_sheet(), wb[2]);
|
xlnt_assert_equals(wb.active_sheet(), wb[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_locale_comma ()
|
||||||
|
{
|
||||||
|
struct SetLocale
|
||||||
|
{
|
||||||
|
SetLocale() {xlnt_assert(setlocale(LC_ALL, "de_DE") != nullptr);} // If failed, please install de_DE locale to correctly run this test.
|
||||||
|
~SetLocale() {setlocale(LC_ALL, "C");}
|
||||||
|
} setLocale;
|
||||||
|
|
||||||
|
xlnt::workbook wb;
|
||||||
|
wb.load(path_helper::test_file("Issue714_local_comma.xlsx"));
|
||||||
|
auto ws = wb.active_sheet();
|
||||||
|
xlnt_assert_equals(ws.cell("A1").value<double>(), 1.9999999999);
|
||||||
|
xlnt_assert_equals(ws.cell("A2").value<double>(), 1.1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static serialization_test_suite x;
|
static serialization_test_suite x;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user