MCPcopy Create free account
hub / github.com/boostorg/json / testIterators

Method testIterators

test/object.cpp:756–881  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

754 }
755
756 void
757 testIterators()
758 {
759 object o({
760 {"a", 1},
761 {"b", true},
762 {"c", "hello"}});
763 auto const& co = o;
764 object no;
765 auto const& cno = no;
766
767 // empty container
768 {
769 BOOST_TEST(no.begin() == no.end());
770 BOOST_TEST(cno.begin() == cno.end());
771 BOOST_TEST(no.cbegin() == no.cend());
772 }
773
774 // begin()
775 {
776 auto it = o.begin();
777 BOOST_TEST(it->key() == "a"); ++it;
778 BOOST_TEST(it->key() == "b"); it++;
779 BOOST_TEST(it->key() == "c"); ++it;
780 BOOST_TEST(it == o.end());
781 }
782
783 // begin() const
784 {
785 auto it = co.begin();
786 BOOST_TEST(it->key() == "a"); ++it;
787 BOOST_TEST(it->key() == "b"); it++;
788 BOOST_TEST(it->key() == "c"); ++it;
789 BOOST_TEST(it == co.end());
790 }
791
792 // cbegin()
793 {
794 auto it = o.cbegin();
795 BOOST_TEST(it->key() == "a"); ++it;
796 BOOST_TEST(it->key() == "b"); it++;
797 BOOST_TEST(it->key() == "c"); ++it;
798 BOOST_TEST(it == o.cend());
799 }
800
801 // end()
802 {
803 auto it = o.end();
804 --it; BOOST_TEST(it->key() == "c");
805 it--; BOOST_TEST(it->key() == "b");
806 --it; BOOST_TEST(it->key() == "a");
807 BOOST_TEST(it == o.begin());
808 }
809
810 // end() const
811 {
812 auto it = co.end();
813 --it; BOOST_TEST(it->key() == "c");

Callers

nothing calls this directly

Calls 9

cbeginMethod · 0.80
cendMethod · 0.80
keyMethod · 0.80
rbeginMethod · 0.80
rendMethod · 0.80
crbeginMethod · 0.80
crendMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected