spdlog
Loading...
Searching...
No Matches
test_fmt_helper.cpp
Go to the documentation of this file.
1
2#include "includes.h"
4
6
7void test_pad2(int n, const char *expected)
8{
9 memory_buf_t buf;
11 REQUIRE(fmt::to_string(buf) == expected);
12}
13
14void test_pad3(uint32_t n, const char *expected)
15{
16 memory_buf_t buf;
18 REQUIRE(fmt::to_string(buf) == expected);
19}
20
21void test_pad6(std::size_t n, const char *expected)
22{
23 memory_buf_t buf;
25 REQUIRE(fmt::to_string(buf) == expected);
26}
27
28void test_pad9(std::size_t n, const char *expected)
29{
30 memory_buf_t buf;
32 REQUIRE(fmt::to_string(buf) == expected);
33}
34
35TEST_CASE("pad2", "[fmt_helper]")
36{
37 test_pad2(0, "00");
38 test_pad2(3, "03");
39 test_pad2(10, "10");
40 test_pad2(23, "23");
41 test_pad2(99, "99");
42 test_pad2(100, "100");
43 test_pad2(123, "123");
44 test_pad2(1234, "1234");
45 test_pad2(-5, "-5");
46}
47
48TEST_CASE("pad3", "[fmt_helper]")
49{
50 test_pad3(0, "000");
51 test_pad3(3, "003");
52 test_pad3(10, "010");
53 test_pad3(23, "023");
54 test_pad3(99, "099");
55 test_pad3(100, "100");
56 test_pad3(123, "123");
57 test_pad3(999, "999");
58 test_pad3(1000, "1000");
59 test_pad3(1234, "1234");
60}
61
62TEST_CASE("pad6", "[fmt_helper]")
63{
64 test_pad6(0, "000000");
65 test_pad6(3, "000003");
66 test_pad6(23, "000023");
67 test_pad6(123, "000123");
68 test_pad6(1234, "001234");
69 test_pad6(12345, "012345");
70 test_pad6(123456, "123456");
71}
72
73TEST_CASE("pad9", "[fmt_helper]")
74{
75 test_pad9(0, "000000000");
76 test_pad9(3, "000000003");
77 test_pad9(23, "000000023");
78 test_pad9(123, "000000123");
79 test_pad9(1234, "000001234");
80 test_pad9(12345, "000012345");
81 test_pad9(123456, "000123456");
82 test_pad9(1234567, "001234567");
83 test_pad9(12345678, "012345678");
84 test_pad9(123456789, "123456789");
85 test_pad9(1234567891, "1234567891");
86}
#define TEST_CASE(...)
Definition catch.hpp:15119
#define REQUIRE(...)
Definition catch.hpp:15083
void pad6(T n, memory_buf_t &dest)
Definition fmt_helper.h:91
void pad3(T n, memory_buf_t &dest)
Definition fmt_helper.h:74
void pad9(T n, memory_buf_t &dest)
Definition fmt_helper.h:97
void pad2(int n, memory_buf_t &dest)
Definition fmt_helper.h:49
fmt::basic_memory_buffer< char, 250 > memory_buf_t
Definition common.h:116
void test_pad3(uint32_t n, const char *expected)
void test_pad9(std::size_t n, const char *expected)
void test_pad6(std::size_t n, const char *expected)
void test_pad2(int n, const char *expected)