1
2#include "includes.h"
3
4using spdlog::memory_buf_t;
5using spdlog::details::to_string_view;
6
7void test_pad2(int n, const char *expected)
8{
9 memory_buf_t buf;
10 spdlog::details::fmt_helper::pad2(n, buf);
11
12 REQUIRE(to_string_view(buf) == expected);
13}
14
15void test_pad3(uint32_t n, const char *expected)
16{
17 memory_buf_t buf;
18 spdlog::details::fmt_helper::pad3(n, buf);
19
20 REQUIRE(to_string_view(buf) == expected);
21}
22
23void test_pad6(std::size_t n, const char *expected)
24{
25 memory_buf_t buf;
26 spdlog::details::fmt_helper::pad6(n, buf);
27
28 REQUIRE(to_string_view(buf) == expected);
29}
30
31void test_pad9(std::size_t n, const char *expected)
32{
33 memory_buf_t buf;
34 spdlog::details::fmt_helper::pad9(n, buf);
35
36 REQUIRE(to_string_view(buf) == expected);
37}
38
39TEST_CASE("pad2", "[fmt_helper]")
40{
41 test_pad2(0, "00");
42 test_pad2(3, "03");
43 test_pad2(10, "10");
44 test_pad2(23, "23");
45 test_pad2(99, "99");
46 test_pad2(100, "100");
47 test_pad2(123, "123");
48 test_pad2(1234, "1234");
49 test_pad2(-5, "-5");
50}
51
52TEST_CASE("pad3", "[fmt_helper]")
53{
54 test_pad3(0, "000");
55 test_pad3(3, "003");
56 test_pad3(10, "010");
57 test_pad3(23, "023");
58 test_pad3(99, "099");
59 test_pad3(100, "100");
60 test_pad3(123, "123");
61 test_pad3(999, "999");
62 test_pad3(1000, "1000");
63 test_pad3(1234, "1234");
64}
65
66TEST_CASE("pad6", "[fmt_helper]")
67{
68 test_pad6(0, "000000");
69 test_pad6(3, "000003");
70 test_pad6(23, "000023");
71 test_pad6(123, "000123");
72 test_pad6(1234, "001234");
73 test_pad6(12345, "012345");
74 test_pad6(123456, "123456");
75}
76
77TEST_CASE("pad9", "[fmt_helper]")
78{
79 test_pad9(0, "000000000");
80 test_pad9(3, "000000003");
81 test_pad9(23, "000000023");
82 test_pad9(123, "000000123");
83 test_pad9(1234, "000001234");
84 test_pad9(12345, "000012345");
85 test_pad9(123456, "000123456");
86 test_pad9(1234567, "001234567");
87 test_pad9(12345678, "012345678");
88 test_pad9(123456789, "123456789");
89 test_pad9(1234567891, "1234567891");
90}
91