Skip to content

Commit

Permalink
Add test for non-default-constructible iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
randomnetcat committed Mar 1, 2021
1 parent a715b99 commit 78a09ff
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,27 @@ TEST(IteratorTest, TruncatingIteratorDefaultConstruct) {
EXPECT_EQ(std::size_t{0}, it.count());
}

TEST(IteratorTest, TruncatingIteratorDeletedDefaultConstruct) {
struct non_default_constructible_iterator {
using iterator_category = std::output_iterator_tag;
using value_type = void;
using difference_type = std::ptrdiff_t;
using pointer = void;
using reference = void;

non_default_constructible_iterator() = delete;

non_default_constructible_iterator& operator++();
non_default_constructible_iterator operator++(int);
char& operator*();
};

static_assert(
!std::is_default_constructible<fmt::detail::truncating_iterator<
non_default_constructible_iterator>>::value,
"");
}

#ifdef __cpp_lib_ranges
TEST(IteratorTest, TruncatingIteratorOutputIterator) {
static_assert(std::output_iterator<fmt::detail::truncating_iterator<char*>,
Expand Down

0 comments on commit 78a09ff

Please sign in to comment.