MCPcopy Create free account
hub / github.com/apache/arrow / TestConstIterators

Function TestConstIterators

cpp/src/arrow/util/small_vector_test.cc:616–667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

614 }
615
616 void TestConstIterators() {
617 constexpr size_t N = Traits::TestSizeFor(5);
618 {
619 const IntVectorType<N> ints{};
620 ASSERT_EQ(ints.begin(), ints.end());
621 ASSERT_EQ(ints.rbegin(), ints.rend());
622 }
623 {
624 // Forward iterators
625 IntVectorType<N> underlying_ints = MakeVector<N>({5, 6, 7, 8, 42});
626 const IntVectorType<N>& ints = underlying_ints;
627
628 auto it = ints.begin();
629 ASSERT_NE(it, ints.end());
630 ASSERT_EQ(*it++, 5);
631 auto it2 = it++;
632 ASSERT_EQ(*it2, 6);
633 ASSERT_EQ(*it, 7);
634 ASSERT_NE(it, it2);
635 ASSERT_EQ(*++it2, 7);
636 ASSERT_EQ(it, it2);
637
638 // Conversion from non-const iterator
639 it = underlying_ints.begin() + 1;
640 ASSERT_NE(it, underlying_ints.end());
641 ASSERT_EQ(*it, 6);
642 it += underlying_ints.end() - it;
643 ASSERT_EQ(it, underlying_ints.end());
644 }
645 {
646 // Reverse iterators
647 IntVectorType<N> underlying_ints = MakeVector<N>({42, 8, 7, 6, 5});
648 const IntVectorType<N>& ints = underlying_ints;
649
650 auto it = ints.rbegin();
651 ASSERT_NE(it, ints.rend());
652 ASSERT_EQ(*it++, 5);
653 auto it2 = it++;
654 ASSERT_EQ(*it2, 6);
655 ASSERT_EQ(*it, 7);
656 ASSERT_NE(it, it2);
657 ASSERT_EQ(*++it2, 7);
658 ASSERT_EQ(it, it2);
659
660 // Conversion from non-const iterator
661 it = underlying_ints.rbegin() + 1;
662 ASSERT_NE(it, underlying_ints.rend());
663 ASSERT_EQ(*it, 6);
664 it += underlying_ints.rend() - it;
665 ASSERT_EQ(it, underlying_ints.rend());
666 }
667 }
668
669 void TestInsertIteratorPair() {
670 // insert(const_iterator, InputIt first, InputIt last)

Callers

nothing calls this directly

Calls 4

rbeginMethod · 0.80
rendMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected