Skip to content

Commit

Permalink
Test nondeterministic conversion to format string
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Sep 28, 2024
1 parent cacc310 commit 1c5883b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/base-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -868,3 +868,17 @@ TEST(base_test, format_to_custom_container) {
auto c = custom_container();
fmt::format_to(std::back_inserter(c), "");
}

struct nondeterministic_format_string {
mutable int i = 0;
FMT_CONSTEXPR operator string_view() const {
return string_view("{}", i++ != 0 ? 2 : 0);
}
};

TEST(base_test, no_repeated_format_string_conversions) {
#if !FMT_GCC_VERSION
char buf[10];
fmt::format_to(buf, nondeterministic_format_string());
#endif
}

0 comments on commit 1c5883b

Please sign in to comment.