mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
test text section of custom number format
This commit is contained in:
parent
0cd96b0494
commit
d8eda2aeb4
|
@ -815,7 +815,7 @@ std::string format_section(const std::string &text, const section &format)
|
||||||
if (!s.empty())
|
if (!s.empty())
|
||||||
{
|
{
|
||||||
if (s.front() != '"' || s.back() != '"') return false;
|
if (s.front() != '"' || s.back() != '"') return false;
|
||||||
s = s.substr(0, s.size() - 2);
|
s = s.substr(1, s.size() - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -14,9 +14,19 @@ public:
|
||||||
auto date = xlnt::date(2016, 6, 18);
|
auto date = xlnt::date(2016, 6, 18);
|
||||||
auto date_number = date.to_number(xlnt::calendar::windows_1900);
|
auto date_number = date.to_number(xlnt::calendar::windows_1900);
|
||||||
|
|
||||||
xlnt::number_format ns = xlnt::number_format::date_ddmmyyyy();
|
xlnt::number_format nf = xlnt::number_format::date_ddmmyyyy();
|
||||||
auto formatted = ns.format(date_number, xlnt::calendar::windows_1900);
|
auto formatted = nf.format(date_number, xlnt::calendar::windows_1900);
|
||||||
|
|
||||||
TS_ASSERT_EQUALS(formatted, "18/06/16");
|
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");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user