38 snprintf(cfgline, 2048,
"%s", s);
41 strncpy(cfgparam, cfgline,
sizeof(cfgparam)-1);
42 cfgparam[
sizeof(cfgparam)-1] =
'\0';
48 const bool interpOk = (unEscaped.
cmp(expectInterp) == 0);
50 printf(
"%25s: %s\n%25s: %s\n%25s: %s\n",
51 "Raw configuration", cfgparam,
52 "Expected interpretation", expectInterp,
53 "Actual interpretation", unEscaped.
termedBuf());
57 bool quotedOk = (strcmp(cfgparam, quoted)==0);
59 printf(
"%25s: %s\n%25s: %s\n%25s: %s\n",
60 "Raw configuration", cfgparam,
61 "Parsed and quoted", quoted,
62 "parsed value was", unEscaped.
termedBuf());
65 return quotedOk && interpOk ;
74 CPPUNIT_ASSERT_EQUAL(
true,
doParseQuotedTest(
"\"This is a quoted \\\"string\\\" by me\"",
75 "This is a quoted \"string\" by me"));
78 CPPUNIT_ASSERT_EQUAL(
true,
doParseQuotedTest(
"\"escape sequence test: \\\\\\\\\\\"\\\\\\\"\\\\\\\\\\\"\"",
79 "escape sequence test: \\\\\"\\\"\\\\\""));
82 CPPUNIT_ASSERT_EQUAL(
true,
doParseQuotedTest(
"\"\\\\beginning and end test\\\"\"",
83 "\\beginning and end test\""));
93main(
int argc,
char *argv[])
static void SetCfgLine(char *line)
Set the configuration file line to parse.
static char * NextToken()
static const char * QuoteString(const String &var)
int cmp(char const *) const
char const * termedBuf() const
bool doParseQuotedTest(const char *, const char *)
CPPUNIT_TEST(testParseQuoted)
CPPUNIT_TEST_SUITE(TestConfigParser)
implements test program's main() function while enabling customization
int run(int argc, char *argv[])
CPPUNIT_TEST_SUITE_REGISTRATION(TestConfigParser)