Skip to content

Commit

Permalink
option -> optional
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-huntington committed Feb 19, 2023
1 parent 1e19a17 commit 6d426a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/fmt/std.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct formatter<std::optional<T>, Char,
std::enable_if_t<is_formattable<T>::value>> {
formatter<T, Char> underlying_;
static constexpr basic_string_view<Char> OPTION =
detail::string_literal<Char, 'o', 'p', 't', 'i', 'o', 'n', '('>{};
detail::string_literal<Char, 'o', 'p', 't', 'i', 'o', 'n', 'a', 'l', '('>{};
static constexpr basic_string_view<Char> EMPTY =
detail::string_literal<Char, 'n', 'o', 'n', 'e'>{};

Expand Down
16 changes: 8 additions & 8 deletions test/std-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ TEST(std_test, optional) {
EXPECT_EQ(fmt::format(L"{}", std::optional<int>{}), L"none");
EXPECT_EQ(fmt::format("{}", std::vector{std::optional{1}, std::optional{2},
std::optional{3}}),
"[option(1), option(2), option(3)]");
"[optional(1), optional(2), optional(3)]");
EXPECT_EQ(
fmt::format("{:#x}", std::optional<std::optional<int>>{std::optional{1}}),
"option(option(0x1))");
"optional(optional(0x1))");
EXPECT_EQ(
fmt::format("{::d}", std::optional{std::vector{'h', 'e', 'l', 'l', 'o'}}),
"option([104, 101, 108, 108, 111])");
"optional([104, 101, 108, 108, 111])");
EXPECT_EQ(fmt::format("{}", std::optional{std::string{"string"}}),
"option(\"string\")");
EXPECT_EQ(fmt::format("{}", std::optional{'C'}), "option(\'C\')");
EXPECT_EQ(fmt::format("{:.{}f}", std::optional{3.14}, 1), "option(3.1)");
"optional(\"string\")");
EXPECT_EQ(fmt::format("{}", std::optional{'C'}), "optional(\'C\')");
EXPECT_EQ(fmt::format("{:.{}f}", std::optional{3.14}, 1), "optional(3.1)");
EXPECT_EQ(fmt::format("int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}",
std::optional{42}),
"int: option(42); hex: option(2a); oct: option(52); bin: "
"option(101010)");
"int: optional(42); hex: optional(2a); oct: optional(52); bin: "
"optional(101010)");

struct unformattable {};
EXPECT_FALSE((fmt::is_formattable<unformattable>::value));
Expand Down

0 comments on commit 6d426a7

Please sign in to comment.