Added tests for negative int formatting

This commit is contained in:
2021-11-22 12:46:33 +01:00
parent ba86cc40a5
commit 040dae6bf3
3 changed files with 26 additions and 6 deletions

View File

@@ -27,10 +27,27 @@ TEST(Format, positive_int) {
EXPECT_EQ(control4, formatted4);
}
//TEST(Format, negative_int) {
// // TODO
// EXPECT_EQ(true, false);
//}
TEST(Format, negative_int) {
constexpr std::array<char, 8> control1 = {'-', '0', '0', '0',
'0', '0', '0', '2'};
constexpr std::array<char, 8> formatted1 = format<"{:08}">(-2);
constexpr std::array<char, 8> control2 = {' ', ' ', '-', '2',
'2', '2', '2', '2'};
constexpr std::array<char, 8> formatted2 = format<"{:8}">(-22222);
constexpr std::array<char, 8> control3 = {'-', '0', '0', '1',
'2', '3', '4', '5'};
constexpr std::array<char, 8> formatted3 = format<"{:08.4}">(-12345);
constexpr std::array<char, 5> control4 = {'-', '6', '7', '8', '9'};
constexpr std::array<char, 5> formatted4 = format<"{:5}">(-6789);
EXPECT_EQ(control1, formatted1);
EXPECT_EQ(control2, formatted2);
EXPECT_EQ(control3, formatted3);
EXPECT_EQ(control4, formatted4);
}
//
//TEST(Format, positive_float) {
// // TODO