This source file includes following definitions.
- TEST
#include "testing/gtest/include/gtest/gtest.h"
#include "tools/gn/escape.h"
TEST(Escape, UsedQuotes) {
EscapeOptions shell_options;
shell_options.mode = ESCAPE_SHELL;
EscapeOptions ninja_options;
ninja_options.mode = ESCAPE_NINJA;
EscapeOptions ninja_shell_options;
ninja_shell_options.mode = ESCAPE_NINJA_SHELL;
bool used_quotes = false;
shell_options.inhibit_quoting = true;
EXPECT_EQ("foo bar", EscapeString("foo bar", shell_options, &used_quotes));
EXPECT_TRUE(used_quotes);
used_quotes = false;
shell_options.inhibit_quoting = false;
EXPECT_EQ("\"foo bar\"",
EscapeString("foo bar", shell_options, &used_quotes));
EXPECT_TRUE(used_quotes);
used_quotes = false;
EXPECT_EQ("\"foo$ bar\"",
EscapeString("foo bar", ninja_shell_options, &used_quotes));
EXPECT_TRUE(used_quotes);
used_quotes = false;
EXPECT_EQ("foo$ bar", EscapeString("foo bar", ninja_options, &used_quotes));
EXPECT_FALSE(used_quotes);
used_quotes = true;
EscapeString("foo", ninja_options, &used_quotes);
EXPECT_TRUE(used_quotes);
}