#include #include #include #include #include #include "quote.hpp" #include "unquote.hpp" int main() try { using namespace boost::algorithm; // verify basic behavior 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 behavior with specific delimiter and escape characters b = quote(a, ' ', '%'); BOOST_ASSERT(" simple% test " == b); b = unquote(b, ' ', '%'); BOOST_ASSERT(a == b); // verify behavior 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 behavior 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); } catch (std::exception const & e) { std::cout << "Caught exception: " << e.what() << std::endl; }