Skip to content

Commit

Permalink
Declare the size of RESET_COLOR.
Browse files Browse the repository at this point in the history
This is so that the format with a text_tyle will compile even if
header-only mode isn't enabled. Addresses #1063.
  • Loading branch information
mwinterb authored and vitaut committed Mar 6, 2019
1 parent 8f7780a commit d8434ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,8 @@ template <typename T = void> struct FMT_API basic_data {
static const char DIGITS[];
static const char FOREGROUND_COLOR[];
static const char BACKGROUND_COLOR[];
static const char RESET_COLOR[];
static const wchar_t WRESET_COLOR[];
static const char RESET_COLOR[5];
static const wchar_t WRESET_COLOR[5];
};

#if FMT_USE_EXTERN_TEMPLATES
Expand Down
7 changes: 7 additions & 0 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#endif

#include "fmt/format.h"
#include "fmt/color.h"
#include "gmock.h"
#include "gtest-extra.h"
#include "mock-allocator.h"
Expand Down Expand Up @@ -2492,3 +2493,9 @@ TEST(FormatTest, U8StringViewLiteral) {
TEST(FormatTest, FormatU8String) {
EXPECT_EQ(format(fmt::u8string_view("{}"), 42), fmt::u8string_view("42"));
}

TEST(FormatTest, EmphasisNonHeaderOnly) {
// ensure this compiles even if FMT_HEADER_ONLY is not defined.
EXPECT_EQ(fmt::format(fmt::emphasis::bold, "bold error"),
"\x1b[1mbold error\x1b[0m");
}

0 comments on commit d8434ba

Please sign in to comment.