Commit 5fde0507 by Maarten L. Hekkelman

debugging

parent a855f880
......@@ -90,12 +90,13 @@ std::string join(IterType b, IterType e, std::string_view sep)
for (;;)
{
s << *ai;
ai = ni;
ni = std::next(ai);
if (ni == e)
break;
ai = ni;
ni = std::next(ai);
s << sep;
}
}
......
......@@ -167,7 +167,10 @@ void toUpper(std::string &s)
void replace_all(std::string &s, std::string_view what, std::string_view with)
{
for (std::string::size_type p = s.find(what); p != std::string::npos; p = s.find(what, p))
{
s.replace(p, what.length(), with);
p += with.length();
}
}
bool icontains(std::string_view s, std::string_view q)
......
......@@ -29,8 +29,6 @@
#include <map>
#include <set>
#include <boost/format.hpp>
#include <cif++/AtomType.hpp>
#include <cif++/Compound.hpp>
#include <cif++/PDB2CifRemark3.hpp>
......
......@@ -2159,4 +2159,21 @@ BOOST_AUTO_TEST_CASE(split_test)
t = std::vector<std::string_view>{ "aap", "noot", "mies" };
BOOST_CHECK(v == t);
}
BOOST_AUTO_TEST_CASE(join_test)
{
BOOST_CHECK_EQUAL(cif::join(std::vector<std::string>{"aap"}, ", "), "aap");
BOOST_CHECK_EQUAL(cif::join(std::vector<std::string>{"aap", "noot"}, ", "), "aap, noot");
BOOST_CHECK_EQUAL(cif::join(std::vector<std::string>{"aap", "noot", "mies"}, ", "), "aap, noot, mies");
}
BOOST_AUTO_TEST_CASE(replace_all_test)
{
std::string s("aap, noot, mies");
cif::replace_all(s, ", ", ",");
BOOST_CHECK_EQUAL(s, "aap,noot,mies");
cif::replace_all(s, ",", ", ");
BOOST_CHECK_EQUAL(s, "aap, noot, mies");
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment