test_fmt_helper.cpp 1.15 KB
Newer Older
gabime's avatar
gabime committed
1 2 3

#include "includes.h"

gabime's avatar
gabime committed
4
void test_pad2(int n, const char *expected)
gabime's avatar
gabime committed
5 6 7 8 9 10
{
    fmt::memory_buffer buf;
    spdlog::details::fmt_helper::pad2(n, buf);
    REQUIRE(fmt::to_string(buf) == expected);
}

gabime's avatar
gabime committed
11
void test_pad3(int n, const char *expected)
gabime's avatar
gabime committed
12 13 14 15 16 17
{
    fmt::memory_buffer buf;
    spdlog::details::fmt_helper::pad3(n, buf);
    REQUIRE(fmt::to_string(buf) == expected);
}

gabime's avatar
gabime committed
18
void test_pad6(std::size_t n, const char *expected)
gabime's avatar
gabime committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
{
    fmt::memory_buffer buf;
    spdlog::details::fmt_helper::pad6(n, buf);
    REQUIRE(fmt::to_string(buf) == expected);
}

TEST_CASE("pad2", "[fmt_helper]")
{
    test_pad2(0, "00");
    test_pad2(3, "03");
    test_pad2(23, "23");
    test_pad2(123, "123");
    test_pad2(1234, "1234");
    test_pad2(-5, "-5");
}

TEST_CASE("pad3", "[fmt_helper]")
{
    test_pad3(0, "000");
    test_pad3(3, "003");
    test_pad3(23, "023");
    test_pad3(123, "123");
    test_pad3(1234, "1234");
    test_pad3(-5, "-05");
}

TEST_CASE("pad6", "[fmt_helper]")
{
    test_pad6(0, "000000");
    test_pad6(3, "000003");
    test_pad6(23, "000023");
    test_pad6(123, "000123");
    test_pad6(1234, "001234");
    test_pad6(12345, "012345");
    test_pad6(123456, "123456");
}