New tests
This commit is contained in:
committed by
Victor Zverovich
parent
7911d8d3f5
commit
d3d30a46f0
@@ -8,6 +8,8 @@
|
||||
#include "fmt/xchar.h"
|
||||
|
||||
#include <complex>
|
||||
#include <cwchar>
|
||||
#include <vector>
|
||||
|
||||
#include "fmt/chrono.h"
|
||||
#include "fmt/color.h"
|
||||
@@ -265,6 +267,30 @@ TEST(xchar_test, chrono) {
|
||||
EXPECT_EQ(fmt::format(L"{:%T}", tm), L"11:22:33");
|
||||
}
|
||||
|
||||
TEST(chrono_test, time_point) {
|
||||
auto t1 = std::chrono::system_clock::now();
|
||||
|
||||
std::vector<std::wstring> spec_list = {
|
||||
L"%%", L"%n", L"%t", L"%Y", L"%EY", L"%y", L"%Oy", L"%Ey",
|
||||
L"%C", L"%EC", L"%G", L"%g", L"%b", L"%h", L"%B", L"%m",
|
||||
L"%Om", L"%U", L"%OU", L"%W", L"%OW", L"%V", L"%OV", L"%j",
|
||||
L"%d", L"%Od", L"%e", L"%Oe", L"%a", L"%A", L"%w", L"%Ow",
|
||||
L"%u", L"%Ou", L"%H", L"%OH", L"%I", L"%OI", L"%M", L"%OM",
|
||||
L"%S", L"%OS", L"%c", L"%Ec", L"%x", L"%Ex", L"%X", L"%EX",
|
||||
L"%D", L"%F", L"%r", L"%R", L"%T", L"%p", L"%z", L"%Z"};
|
||||
spec_list.push_back(L"%Y-%m-%d %H:%M:%S");
|
||||
for (const auto& spec : spec_list) {
|
||||
auto t = std::chrono::system_clock::to_time_t(t1);
|
||||
auto tm = *std::localtime(&t);
|
||||
wchar_t output[1024] = {};
|
||||
std::wcsftime(output, sizeof(output) / sizeof(wchar_t), spec.c_str(), &tm);
|
||||
|
||||
auto fmt_spec = std::wstring(L"{:").append(spec).append(L"}");
|
||||
EXPECT_EQ(output, fmt::format(fmt_spec, t1));
|
||||
EXPECT_EQ(output, fmt::format(fmt_spec, tm));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(xchar_test, color) {
|
||||
EXPECT_EQ(fmt::format(fg(fmt::rgb(255, 20, 30)), L"rgb(255,20,30) wide"),
|
||||
L"\x1b[38;2;255;020;030mrgb(255,20,30) wide\x1b[0m");
|
||||
|
||||
Reference in New Issue
Block a user