mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-16 01:37:58 +00:00
Compare commits
4 Commits
0a14e491ab
...
34244656a6
Author | SHA1 | Date | |
---|---|---|---|
|
34244656a6 | ||
|
619849c793 | ||
|
927b2b3942 | ||
|
76389e057f |
@ -73,7 +73,18 @@ inline void pad_uint(T n, unsigned int width, memory_buf_t &dest)
|
||||
template<typename T>
|
||||
inline void pad3(T n, memory_buf_t &dest)
|
||||
{
|
||||
pad_uint(n, 3, dest);
|
||||
static_assert(std::is_unsigned<T>::value, "pad3 must get unsigned T");
|
||||
if(n < 1000)
|
||||
{
|
||||
dest.push_back(static_cast<char>(n / 100 + '0'));
|
||||
n = n % 100;
|
||||
dest.push_back(static_cast<char>((n / 10) + '0'));
|
||||
dest.push_back(static_cast<char>((n % 10) + '0'));
|
||||
}
|
||||
else
|
||||
{
|
||||
append_int(n, dest);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -36,7 +36,10 @@ TEST_CASE("pad2", "[fmt_helper]")
|
||||
{
|
||||
test_pad2(0, "00");
|
||||
test_pad2(3, "03");
|
||||
test_pad2(10, "10");
|
||||
test_pad2(23, "23");
|
||||
test_pad2(99, "99");
|
||||
test_pad2(100, "100");
|
||||
test_pad2(123, "123");
|
||||
test_pad2(1234, "1234");
|
||||
test_pad2(-5, "-5");
|
||||
@ -46,8 +49,13 @@ TEST_CASE("pad3", "[fmt_helper]")
|
||||
{
|
||||
test_pad3(0, "000");
|
||||
test_pad3(3, "003");
|
||||
test_pad3(10, "010");
|
||||
test_pad3(23, "023");
|
||||
test_pad3(99, "099");
|
||||
test_pad3(100, "100");
|
||||
test_pad3(123, "123");
|
||||
test_pad3(999, "999");
|
||||
test_pad3(1000, "1000");
|
||||
test_pad3(1234, "1234");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user