fix test failures on windows

This commit is contained in:
Thomas Fussell 2015-10-16 19:05:21 -04:00
parent a63984969e
commit d08071a745
5 changed files with 15 additions and 11 deletions

View File

@ -364,11 +364,6 @@ bool is_date_format(const std::string &format_string)
return not_in == std::string::npos; return not_in == std::string::npos;
} }
const std::string PercentRegex("^\\-?(?P<number>[0-9]*\\.?[0-9]*\\s?)\%$");
const std::string TimeRegex("^(([0-1]{0,1}[0-9]{2}):([0-5][0-9]):?([0-5][0-9])?$)|"
"^(([0-5][0-9]):([0-5][0-9])?\\.(\\d{1,6}))");
const std::string NumberRegex("^-?([\\d]|[\\d]+\\.[\\d]*|\\.[\\d]+|[1-9][\\d]+\\.?[\\d]*)((E|e)[-+]?[\\d]+)?$");
} }
namespace xlnt { namespace xlnt {
@ -486,6 +481,7 @@ void cell::set_value(std::uint64_t i)
} }
#ifdef _WIN32 #ifdef _WIN32
template<>
void cell::set_value(unsigned long i) void cell::set_value(unsigned long i)
{ {
d_->is_date_ = false; d_->is_date_ = false;
@ -495,6 +491,7 @@ void cell::set_value(unsigned long i)
#endif #endif
#ifdef __linux__ #ifdef __linux__
template<>
void cell::set_value(long long i) void cell::set_value(long long i)
{ {
d_->is_date_ = false; d_->is_date_ = false;
@ -502,6 +499,7 @@ void cell::set_value(long long i)
d_->type_ = type::numeric; d_->type_ = type::numeric;
} }
template<>
void cell::set_value(unsigned long long i) void cell::set_value(unsigned long long i)
{ {
d_->is_date_ = false; d_->is_date_ = false;
@ -1068,6 +1066,8 @@ std::string cell::to_string() const
return format_text(get_value<std::string>(), number_format); return format_text(get_value<std::string>(), number_format);
case cell::type::boolean: case cell::type::boolean:
return get_value<long double>() == 0 ? "FALSE" : "TRUE"; return get_value<long double>() == 0 ? "FALSE" : "TRUE";
default:
return "";
} }
} }

View File

@ -124,9 +124,9 @@ time::time(const std::string &time_string) : hour(0), minute(0), second(0), micr
long double time::to_number() const long double time::to_number() const
{ {
std::size_t microseconds = static_cast<std::size_t>(microsecond); std::size_t microseconds = static_cast<std::size_t>(microsecond);
microseconds += second * 1e6; microseconds += static_cast<std::size_t>(second * 1e6);
microseconds += minute * 1e6 * 60; microseconds += static_cast<std::size_t>(minute * 1e6 * 60);
microseconds += hour * 1e6 * 60 * 60; microseconds += static_cast<std::size_t>(hour * 1e6 * 60 * 60);
auto number = microseconds / (24.0L * 60 * 60 * 1e6L); auto number = microseconds / (24.0L * 60 * 60 * 1e6L);
number = std::floor(number * 1e11L + 0.5L) / 1e11L; number = std::floor(number * 1e11L + 0.5L) / 1e11L;
return number; return number;

View File

@ -151,9 +151,11 @@ void read_worksheet_common(xlnt::worksheet ws, const pugi::xml_node &root_node,
if(has_style) if(has_style)
{ {
if(number_format_ids.size() > std::stoll(style)) auto style_index = static_cast<std::size_t>(std::stoll(style));
if(number_format_ids.size() > style_index)
{ {
auto number_format_id = number_format_ids.at(static_cast<std::size_t>(std::stoll(style))); auto number_format_id = number_format_ids.at(style_index);
auto format = xlnt::number_format::lookup_format(number_format_id); auto format = xlnt::number_format::lookup_format(number_format_id);
if(format == xlnt::number_format::format::unknown) if(format == xlnt::number_format::format::unknown)

View File

@ -1,3 +1,4 @@
#include <algorithm>
#include <sstream> #include <sstream>
#include <xlnt/cell/cell.hpp> #include <xlnt/cell/cell.hpp>
@ -252,7 +253,7 @@ std::string write_worksheet(worksheet ws, const std::vector<std::string> &string
else else
{ {
std::stringstream ss; std::stringstream ss;
ss.precision(20); ss.precision(17);
ss << cell.get_value<long double>(); ss << cell.get_value<long double>();
ss.str(); ss.str();
value_node.text().set(ss.str().c_str()); value_node.text().set(ss.str().c_str());

View File

@ -2,6 +2,7 @@
#include <cassert> #include <cassert>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>
#include <iterator>
#ifdef _WIN32 #ifdef _WIN32
#define NOMINMAX #define NOMINMAX