2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file bash_utils.cpp
18 * @author Iwanek Tomasz
21 #include <dpl/test/test_runner.h>
22 #include <dpl/utils/bash_utils.h>
23 #include <dpl/log/log.h>
25 using namespace BashUtils;
27 RUNNER_TEST_GROUP_INIT(DPL_BASH_UTILS)
29 RUNNER_TEST(Bash_Utils_escape_arg)
31 RUNNER_ASSERT_MSG(escape_arg(std::string("valid")) == "\"valid\"", "Valid argument failed");
32 LogDebug("\"val\\!d\"" << " " << escape_arg(std::string("val!d")));
33 RUNNER_ASSERT_MSG(escape_arg(std::string("val!d")) == "\"val\\!d\"", "Single escaped character in argument failed");
34 LogDebug("\"v\\$l\\$\\$\"" << " " << escape_arg(std::string("v$l$$")));
35 RUNNER_ASSERT_MSG(escape_arg(std::string("v$l$$")) == "\"v\\$l\\$\\$\"", "Multiple occurences of single special character in argument failed");
36 LogDebug("\"v\\`\\$\\\"\\!d\\`\"" << " " << escape_arg(std::string("v`$\"!d`")));
37 RUNNER_ASSERT_MSG(escape_arg(std::string("v`$\"!d`")) == "\"v\\`\\$\\\"\\!d\\`\"", "Multiple occurences of multiple special character in argument failed");