From 3784d039cd19c2e024e3b4b61ebc27dd64a54645 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Sun, 15 Mar 2020 13:13:50 -0400 Subject: [PATCH] Add input iterator tests --- test/static_string.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/test/static_string.cpp b/test/static_string.cpp index dba9b79..98506ba 100644 --- a/test/static_string.cpp +++ b/test/static_string.cpp @@ -1010,7 +1010,15 @@ testInsert() BOOST_TEST_THROWS(static_string<4>{"abc"}.insert(4, T{}), std::out_of_range); BOOST_TEST_THROWS(static_string<3>{"abc"}.insert(1, T{}), std::length_error); } - + // insert(const_iterator, InputIterator, InputIterator) + { + std::stringstream a("defghi"); + static_string<30> b = "abcjklmnop"; + b.insert(b.begin() + 3, + std::istream_iterator(a), + std::istream_iterator()); + BOOST_TEST(b == "abcdefghijklmnop"); + } //--- { @@ -5904,6 +5912,15 @@ testReplace() static_string<20> fs1 = "helloworld"; BOOST_TEST(fs1.replace(fs1.begin(), fs1.end(), {'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd'}) == "helloworld"); } + // replace(const_iterator, const_iterator, InputIterator, InputIterator) + { + std::stringstream a("defghi"); + static_string<30> b = "abcabcdefjklmnop"; + BOOST_TEST(b.replace(b.begin() + 3, b.begin() + 9, + std::istream_iterator(a), + std::istream_iterator()) == + "abcdefghijklmnop"); + } using S = static_string<400>; S s_short = "123/"; @@ -7063,9 +7080,11 @@ void testStream() { std::stringstream a; - static_string<10> b; + static_string<10> b = "abcdefghij"; a << b; + static_string<10> c(std::istream_iterator{a}, std::istream_iterator{}); BOOST_TEST(a.str() == b.subview()); + BOOST_TEST(b == c); } void