1 // Copyright 2014 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 "base/files/file_util.h" 6 #include "base/strings/string_util.h" 7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "tools/gn/commands.h" 9 10 namespace commands { 11 bool FormatFileToString(const std::string& input_filename, 12 bool dump_tree, 13 std::string* output); 14 } // namespace commands 15 16 #define FORMAT_TEST(n) \ 17 TEST(Format, n) { \ 18 std::string out; \ 19 std::string expected; \ 20 EXPECT_TRUE(commands::FormatFileToString( \ 21 "//tools/gn/format_test_data/" #n ".gn", false, &out)); \ 22 ASSERT_TRUE(base::ReadFileToString( \ 23 base::FilePath(FILE_PATH_LITERAL("tools/gn/format_test_data/") \ 24 FILE_PATH_LITERAL(#n) \ 25 FILE_PATH_LITERAL(".golden")), \ 26 &expected)); \ 27 EXPECT_EQ(out, expected); \ 28 } 29 30 // These are expanded out this way rather than a runtime loop so that 31 // --gtest_filter works as expected for individual test running. 32 FORMAT_TEST(001) 33 FORMAT_TEST(002) 34 FORMAT_TEST(003) 35 FORMAT_TEST(004) 36 FORMAT_TEST(005) 37 FORMAT_TEST(006) 38 FORMAT_TEST(007) 39 FORMAT_TEST(008) 40 FORMAT_TEST(009) 41 FORMAT_TEST(010) 42 FORMAT_TEST(011) 43 FORMAT_TEST(012) 44 FORMAT_TEST(013) 45 FORMAT_TEST(014) 46