Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: tools/gn/escape_unittest.cc

Issue 247663006: Add more phony rules to GN build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/escape.cc ('k') | tools/gn/filesystem_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/escape.h" 6 #include "tools/gn/escape.h"
7 7
8 TEST(Escape, Ninja) {
9 EscapeOptions opts;
10 opts.mode = ESCAPE_NINJA;
11 std::string result = EscapeString("asdf: \"$\\bar", opts, NULL);
12 EXPECT_EQ("asdf$:$ \"$$\\bar", result);
13 }
14
15 TEST(Escape, Shell) {
16 EscapeOptions opts;
17 opts.mode = ESCAPE_SHELL;
18 std::string result = EscapeString("asdf: \"$\\bar", opts, NULL);
19 #if defined(OS_WIN)
20 // Windows shell doesn't escape backslashes.
21 EXPECT_EQ("\"asdf: \"$\\bar\"", result);
22 #else
23 EXPECT_EQ("\"asdf: \\\"$\\\\bar\"", result);
24 #endif
25 }
26
8 TEST(Escape, UsedQuotes) { 27 TEST(Escape, UsedQuotes) {
9 EscapeOptions shell_options; 28 EscapeOptions shell_options;
10 shell_options.mode = ESCAPE_SHELL; 29 shell_options.mode = ESCAPE_SHELL;
11 30
12 EscapeOptions ninja_options; 31 EscapeOptions ninja_options;
13 ninja_options.mode = ESCAPE_NINJA; 32 ninja_options.mode = ESCAPE_NINJA;
14 33
15 EscapeOptions ninja_shell_options; 34 EscapeOptions ninja_shell_options;
16 ninja_shell_options.mode = ESCAPE_NINJA_SHELL; 35 ninja_shell_options.mode = ESCAPE_NINJA_SHELL;
17 36
(...skipping 19 matching lines...) Expand all
37 // Ninja escaping shouldn't use quoting. 56 // Ninja escaping shouldn't use quoting.
38 used_quotes = false; 57 used_quotes = false;
39 EXPECT_EQ("foo$ bar", EscapeString("foo bar", ninja_options, &used_quotes)); 58 EXPECT_EQ("foo$ bar", EscapeString("foo bar", ninja_options, &used_quotes));
40 EXPECT_FALSE(used_quotes); 59 EXPECT_FALSE(used_quotes);
41 60
42 // Used quotes not reset if it's already true. 61 // Used quotes not reset if it's already true.
43 used_quotes = true; 62 used_quotes = true;
44 EscapeString("foo", ninja_options, &used_quotes); 63 EscapeString("foo", ninja_options, &used_quotes);
45 EXPECT_TRUE(used_quotes); 64 EXPECT_TRUE(used_quotes);
46 } 65 }
OLDNEW
« no previous file with comments | « tools/gn/escape.cc ('k') | tools/gn/filesystem_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698