Fix test
This commit is contained in:
parent
dda47c9466
commit
847abb6f8f
@ -1144,10 +1144,7 @@ struct align_spec {
|
||||
wchar_t fill_;
|
||||
alignment align_;
|
||||
|
||||
FMT_CONSTEXPR align_spec(
|
||||
unsigned width, wchar_t fill, alignment align = ALIGN_DEFAULT)
|
||||
: width_(width), fill_(fill), align_(align) {}
|
||||
|
||||
FMT_CONSTEXPR align_spec() : width_(0), fill_(' '), align_(ALIGN_DEFAULT) {}
|
||||
FMT_CONSTEXPR unsigned width() const { return width_; }
|
||||
FMT_CONSTEXPR wchar_t fill() const { return fill_; }
|
||||
FMT_CONSTEXPR alignment align() const { return align_; }
|
||||
@ -1158,19 +1155,14 @@ struct core_format_specs {
|
||||
uint_least8_t flags;
|
||||
char type;
|
||||
|
||||
FMT_CONSTEXPR core_format_specs() : precision(-1), flags(0), type(0) {}
|
||||
FMT_CONSTEXPR bool has(unsigned f) const { return (flags & f) != 0; }
|
||||
};
|
||||
|
||||
// Format specifiers.
|
||||
template <typename Char>
|
||||
struct basic_format_specs : align_spec, core_format_specs {
|
||||
FMT_CONSTEXPR basic_format_specs(
|
||||
unsigned width = 0, char type_ = 0, wchar_t fill = ' ')
|
||||
: align_spec(width, fill) {
|
||||
precision = -1;
|
||||
flags = 0;
|
||||
type = type_;
|
||||
}
|
||||
FMT_CONSTEXPR basic_format_specs() {}
|
||||
};
|
||||
|
||||
typedef basic_format_specs<char> format_specs;
|
||||
|
@ -2182,20 +2182,20 @@ FMT_CONSTEXPR fmt::format_specs parse_specs(const char *s) {
|
||||
}
|
||||
|
||||
TEST(FormatTest, ConstexprSpecsHandler) {
|
||||
static_assert(parse_specs("<").align == fmt::ALIGN_LEFT, "");
|
||||
static_assert(parse_specs("<").align() == fmt::ALIGN_LEFT, "");
|
||||
static_assert(parse_specs("*^").fill() == '*', "");
|
||||
static_assert(parse_specs("+").has(fmt::PLUS_FLAG), "");
|
||||
static_assert(parse_specs("-").has(fmt::MINUS_FLAG), "");
|
||||
static_assert(parse_specs(" ").has(fmt::SIGN_FLAG), "");
|
||||
static_assert(parse_specs("#").has(fmt::HASH_FLAG), "");
|
||||
static_assert(parse_specs("0").align == fmt::ALIGN_NUMERIC, "");
|
||||
static_assert(parse_specs("0").align() == fmt::ALIGN_NUMERIC, "");
|
||||
static_assert(parse_specs("42").width() == 42, "");
|
||||
static_assert(parse_specs("{}").width() == 11, "");
|
||||
static_assert(parse_specs("{0}").width() == 22, "");
|
||||
static_assert(parse_specs(".42").precision == 42, "");
|
||||
static_assert(parse_specs(".{}").precision == 11, "");
|
||||
static_assert(parse_specs(".{0}").precision == 22, "");
|
||||
static_assert(parse_specs("d").type() == 'd', "");
|
||||
static_assert(parse_specs("d").type == 'd', "");
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR fmt::internal::dynamic_format_specs<char>
|
||||
@ -2208,20 +2208,20 @@ FMT_CONSTEXPR fmt::internal::dynamic_format_specs<char>
|
||||
}
|
||||
|
||||
TEST(FormatTest, ConstexprDynamicSpecsHandler) {
|
||||
static_assert(parse_dynamic_specs("<").align == fmt::ALIGN_LEFT, "");
|
||||
static_assert(parse_dynamic_specs("<").align() == fmt::ALIGN_LEFT, "");
|
||||
static_assert(parse_dynamic_specs("*^").fill() == '*', "");
|
||||
static_assert(parse_dynamic_specs("+").has(fmt::PLUS_FLAG), "");
|
||||
static_assert(parse_dynamic_specs("-").has(fmt::MINUS_FLAG), "");
|
||||
static_assert(parse_dynamic_specs(" ").has(fmt::SIGN_FLAG), "");
|
||||
static_assert(parse_dynamic_specs("#").has(fmt::HASH_FLAG), "");
|
||||
static_assert(parse_dynamic_specs("0").align == fmt::ALIGN_NUMERIC, "");
|
||||
static_assert(parse_dynamic_specs("0").align() == fmt::ALIGN_NUMERIC, "");
|
||||
static_assert(parse_dynamic_specs("42").width() == 42, "");
|
||||
static_assert(parse_dynamic_specs("{}").width_ref.index == 33, "");
|
||||
static_assert(parse_dynamic_specs("{42}").width_ref.index == 42, "");
|
||||
static_assert(parse_dynamic_specs(".42").precision == 42, "");
|
||||
static_assert(parse_dynamic_specs(".{}").precision_ref.index == 33, "");
|
||||
static_assert(parse_dynamic_specs(".{42}").precision_ref.index == 42, "");
|
||||
static_assert(parse_dynamic_specs("d").type() == 'd', "");
|
||||
static_assert(parse_dynamic_specs("d").type == 'd', "");
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR test_format_specs_handler check_specs(const char *s) {
|
||||
|
Loading…
Reference in New Issue
Block a user