| OLD | NEW |
| (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 } | |
| OLD | NEW |