From: stephan b. <sg...@us...> - 2004-12-26 12:17:04
|
Update of /cvsroot/pclasses/pclasses2/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12300/test Modified Files: StringToolTest.cpp Log Message: added an (un)escaping test. Index: StringToolTest.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/test/StringToolTest.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- StringToolTest.cpp 26 Dec 2004 11:13:01 -0000 1.1 +++ StringToolTest.cpp 26 Dec 2004 12:16:53 -0000 1.2 @@ -23,11 +23,31 @@ map["foo"] = "FOOFOO"; map["bar"] = "BARBAR"; - std::string ins = "this is a ${foo} input ${bar}."; + std::string v1 = "this $bar is a ${foo} input ${bar}. $UNMAPPED_VAR, \\ \\ \\\\ ${} $ \\$ escaped \\${foo}."; + std::string v2 = v1; - CERR << "string: ["<<ins<<"]\n" - << "Expanded: [" << expandVars( map, ins ) << "]\n"; + CERR << "string: ["<<v1<<"]\n" + << "expanded: [" << expandDollarRefs( map, v1 ) << "]\n"; + + escapeString( v2, "$", "\\" ); + CERR << "escaped string: ["<<v2<<"]\n" + << "pre-escaped, expanded: [" << expandDollarRefs( map, v2 ) << "]\n"; + + EntityMap mymap; + mymap["<"] = "<"; + mymap[">"] = ">"; + mymap["\""] = """; + mymap["'"] = "'"; + mymap["$GOODGRIEF"] = "excellent"; + + size_t num = 0; + std::string q1 = "this is a '<\"test string\">'. $GOODGRIEF!"; + CERR << "reference string=["<<q1<<"]\n"; + num = translateEntities( q1, mymap ); + CERR << num << " translated: [" << q1 << "]\n"; + translateEntities( q1, mymap, true ); + CERR << num << " reverse translated: [" << q1 << "]\n"; return 0; |