Fix unit tests on Windows.

Fixes #5068
This commit is contained in:
Gunnar Beutner 2013-11-13 09:08:17 +01:00
parent d1d3c0e247
commit 6ccf4497f2
3 changed files with 8 additions and 6 deletions

View File

@ -499,7 +499,7 @@ String Utility::EscapeShellCmd(const String& s)
if (escape)
#ifdef _WIN32
result += '%';
result += '^';
#else /* _WIN32 */
result += '\\';
#endif /* _WIN32 */

View File

@ -27,6 +27,7 @@
#include "base/scriptfunction.h"
#include "base/utility.h"
#include "base/process.h"
#include "base/objectlock.h"
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/foreach.hpp>
@ -123,6 +124,8 @@ String PluginUtility::FormatPerfdata(const Value& perfdata)
Dictionary::Ptr dict = perfdata;
ObjectLock olock(dict);
String key;
Value value;
BOOST_FOREACH(boost::tie(key, value), dict) {

View File

@ -29,18 +29,17 @@ BOOST_AUTO_TEST_CASE(escape_basic)
{
#ifdef _WIN32
BOOST_CHECK(Utility::EscapeShellCmd("%PATH%") == "^%PATH^%");
#endif /* _WIN32 */
#else /* _WIN32 */
BOOST_CHECK(Utility::EscapeShellCmd("$PATH") == "\\$PATH");
BOOST_CHECK(Utility::EscapeShellCmd("\\$PATH") == "\\\\\\$PATH");
#endif /* _WIN32 */
}
BOOST_AUTO_TEST_CASE(escape_quoted)
{
#ifdef _WIN32
BOOST_CHECK(Utility::EscapeShellCmd("'hello'") == "\\'hello\\'");
BOOST_CHECK(Utility::EscapeShellCmd("\"hello\"") == "\\\"hello\\\"");
BOOST_CHECK(Utility::EscapeShellCmd("'hello'") == "^'hello^'");
BOOST_CHECK(Utility::EscapeShellCmd("\"hello\"") == "^\"hello^\"");
#else /* _WIN32 */
BOOST_CHECK(Utility::EscapeShellCmd("'hello'") == "'hello'");
BOOST_CHECK(Utility::EscapeShellCmd("'hello") == "\\'hello");