41 for (
size_t i=0; i<m_str.length(); i++) {
76 if (m_str.size() < 2 || m_str[0] !=
'"' 77 || m_str[m_str.size() - 1] !=
'"')
83 for (i = 1; i < m_str.length() - 1; i++) {
89 char ch2 = m_str[++i];
110 if (i == m_str.length() - 1)
122 static void Test_EscapedString_Generate()
126 "\"hello world 123\"");
134 "\"hi\\nworld\\ragain\"");
138 "\"hi'123\\\"456\\\"789\"");
142 "\"Hello\\\\world\"");
145 static void Test_EscapedString_Decode()
147 bool success =
false;
179 static void Test_EscapedString_Decode_WithoutQuotes()
191 UNITTEST(Test_EscapedString_Generate);
192 UNITTEST(Test_EscapedString_Decode);
193 UNITTEST(Test_EscapedString_Decode_WithoutQuotes);
string Generate() const
Generates an escaped string, from the original string.
#define UNITTESTS(class)
Helper for unit test case execution.
string Decode(bool &success) const
Decodes an escaped string, from the original string.
A helper class for escaping strings using C-style escapes.
static void Assert(const string &strFailMessage, bool condition)
Asserts that a boolean condition is correct.
EscapedString(const string &str)
Constructs an EscapedString helper.
#define UNITTEST(functionname)
Helper for unit test case execution.