void TestWorkshareActions::TestAddQuotes() { CStdString s = _T( "Hello World" ); AddQuotes( s ); assertTest( s == _T( "\"Hello World\"" ) ); AddQuotes( s ); assertMessage( s == _T( "\"Hello World\"" ), _T( "Quotes should only be added the first time" ) ); s = _T( "Hello World\"" ); AddQuotes( s ); assertMessage( s == _T( "\"Hello World\"" ), _T( "Quotes should have been added to the start of the string" ) ); s = _T( "\"Hello World" ); AddQuotes( s ); assertMessage( s == _T( "\"Hello World\"" ), _T( "Quotes should have been added to the end of the string" ) ); }
/*! * @param[in] arg The string that needs to be quoted. * @param[in] whitespace The set of characters that are considered whitespace. */ QUOTE_ARGUMENT_MS_BASE(const STRING &arg, const T *whitespace) { // Quoting is only necessary if the argument contains whitespace or a quote ("). // _quoted = arg; if (_quoted.find_first_of(whitespace) != STRING::npos || _quoted.find_first_of('"') != STRING::npos) { EscapeBackSlashes(); EscapeQuotes(); AddQuotes(whitespace); } }