#include #include #include #include #include #include "quote.hpp" #include "unquote.hpp" int main() try { using namespace boost::algorithm; // verify using defaults std::string a("simple test"); std::string b(quote(a)); BOOST_ASSERT("\"simple test\"" == b); b = unquote(b); BOOST_ASSERT(a == b); // verify with specific delimiter and escape characters b = quote(a, ' ', '%'); BOOST_ASSERT(" simple% test " == b); b = unquote(b, ' ', '%'); BOOST_ASSERT(a == b); // verify with specific delimiter on string with embedded escape character a = "simple\\ test"; b = quote(a, '%'); BOOST_ASSERT("%simple\\\\ test%" == b); b = unquote(b, '%'); BOOST_ASSERT(a == b); // verify on string with embedded delimiter a = "embedded "; b = quote(a); b += "quotation mark\""; BOOST_ASSERT("\"embedded \"quotation mark\"" == b); b = unquote(b); BOOST_ASSERT(a == b); // verify with distinct start and end delimiters a = "some {test} text"; b = quote(a, '{', '}', '\\'); BOOST_ASSERT("{some \\{test\\} text}" == b); b = unquote(b, '{', '}', '\\'); BOOST_ASSERT(a == b); } catch (std::exception const & e) { std::cout << "Caught exception: " << e.what() << std::endl; }