Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / tools / gn / command_format_unittest.cc
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 #include "tools/gn/setup.h"
10
11 namespace commands {
12 bool FormatFileToString(Setup* setup,
13                         const SourceFile& file,
14                         bool dump_tree,
15                         std::string* output);
16 }  // namespace commands
17
18 #define FORMAT_TEST(n)                                                 \
19   TEST(Format, n) {                                                    \
20     ::Setup setup;                                                     \
21     std::string out;                                                   \
22     std::string expected;                                              \
23     EXPECT_TRUE(commands::FormatFileToString(                          \
24         &setup,                                                        \
25         SourceFile("//tools/gn/format_test_data/" #n ".gn"),           \
26         false,                                                         \
27         &out));                                                        \
28     ASSERT_TRUE(base::ReadFileToString(                                \
29         base::FilePath(FILE_PATH_LITERAL("tools/gn/format_test_data/") \
30                            FILE_PATH_LITERAL(#n)                       \
31                                FILE_PATH_LITERAL(".golden")),          \
32         &expected));                                                   \
33     EXPECT_EQ(expected, out);                                          \
34   }
35
36 // These are expanded out this way rather than a runtime loop so that
37 // --gtest_filter works as expected for individual test running.
38 FORMAT_TEST(001)
39 FORMAT_TEST(002)
40 FORMAT_TEST(003)
41 FORMAT_TEST(004)
42 FORMAT_TEST(005)
43 FORMAT_TEST(006)
44 FORMAT_TEST(007)
45 FORMAT_TEST(008)
46 FORMAT_TEST(009)
47 FORMAT_TEST(010)
48 FORMAT_TEST(011)
49 FORMAT_TEST(012)
50 FORMAT_TEST(013)
51 FORMAT_TEST(014)
52 FORMAT_TEST(015)
53 FORMAT_TEST(016)
54 FORMAT_TEST(017)
55 FORMAT_TEST(018)
56 FORMAT_TEST(019)
57 FORMAT_TEST(020)
58 FORMAT_TEST(021)
59 FORMAT_TEST(022)
60 FORMAT_TEST(023)
61 FORMAT_TEST(024)
62 FORMAT_TEST(025)
63 FORMAT_TEST(026)
64 FORMAT_TEST(027)
65 FORMAT_TEST(028)
66 FORMAT_TEST(029)
67 FORMAT_TEST(030)
68 FORMAT_TEST(031)
69 // TODO(scottmg): Continued conditions aren't aligned properly: FORMAT_TEST(032)
70 FORMAT_TEST(033)
71 // TODO(scottmg): args+rebase_path unnecessarily split: FORMAT_TEST(034)
72 FORMAT_TEST(035)
73 FORMAT_TEST(036)
74 // TODO(scottmg): Ugly line breaking: FORMAT_TEST(037)
75 FORMAT_TEST(038)
76 // TODO(scottmg): Bad break, exceeding 80 col: FORMAT_TEST(039)
77 // TODO(scottmg): Bad break, exceeding 80 col: FORMAT_TEST(040)
78 FORMAT_TEST(041)