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

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

Issue 21114002: Add initial prototype for the GN meta-buildsystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add owners and readme Created 7 years, 4 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/file_template.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/file_template.h"
7
8 TEST(FileTemplate, Static) {
9 std::vector<std::string> templates;
10 templates.push_back("something_static");
11 FileTemplate t(templates);
12
13 std::vector<std::string> result;
14 t.ApplyString("", &result);
15 ASSERT_EQ(1u, result.size());
16 EXPECT_EQ("something_static", result[0]);
17
18 t.ApplyString("lalala", &result);
19 ASSERT_EQ(1u, result.size());
20 EXPECT_EQ("something_static", result[0]);
21 }
22
23 TEST(FileTemplate, Typical) {
24 std::vector<std::string> templates;
25 templates.push_back("foo/{{source_name_part}}.cc");
26 templates.push_back("foo/{{source_name_part}}.h");
27 FileTemplate t(templates);
28
29 std::vector<std::string> result;
30 t.ApplyString("sources/ha.idl", &result);
31 ASSERT_EQ(2u, result.size());
32 EXPECT_EQ("foo/ha.cc", result[0]);
33 EXPECT_EQ("foo/ha.h", result[1]);
34 }
35
36 TEST(FileTemplate, Weird) {
37 std::vector<std::string> templates;
38 templates.push_back("{{{source}}{{source}}{{");
39 FileTemplate t(templates);
40
41 std::vector<std::string> result;
42 t.ApplyString("foo/lalala.c", &result);
43 ASSERT_EQ(1u, result.size());
44 EXPECT_EQ("{foo/lalala.cfoo/lalala.c{{", result[0]);
45 }
OLDNEW
« no previous file with comments | « tools/gn/file_template.cc ('k') | tools/gn/filesystem_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698