test text section of custom number format

This commit is contained in:
Thomas Fussell 2016-06-18 10:06:02 +01:00
parent 0cd96b0494
commit d8eda2aeb4
2 changed files with 13 additions and 3 deletions

View File

@ -815,7 +815,7 @@ std::string format_section(const std::string &text, const section &format)
if (!s.empty())
{
if (s.front() != '"' || s.back() != '"') return false;
s = s.substr(0, s.size() - 2);
s = s.substr(1, s.size() - 2);
}
return true;

View File

@ -14,9 +14,19 @@ public:
auto date = xlnt::date(2016, 6, 18);
auto date_number = date.to_number(xlnt::calendar::windows_1900);
xlnt::number_format ns = xlnt::number_format::date_ddmmyyyy();
auto formatted = ns.format(date_number, xlnt::calendar::windows_1900);
xlnt::number_format nf = xlnt::number_format::date_ddmmyyyy();
auto formatted = nf.format(date_number, xlnt::calendar::windows_1900);
TS_ASSERT_EQUALS(formatted, "18/06/16");
}
void test_text_section_string()
{
xlnt::number_format nf;
nf.set_format_string("General;General;General;[Magenta]\"a\"@\"b\"");
auto formatted = nf.format("text");
TS_ASSERT_EQUALS(formatted, "atextb");
}
};