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

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

Issue 1570113002: Visual Studio generators for GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests failing on non-Windows platforms Created 4 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2016 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 "tools/gn/visual_studio_utils.h"
6
7 #include "base/location.h"
8 #include "base/strings/string_util.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 TEST(VisualStudioUtils, MakeGuid) {
12 std::string pattern = "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}";
13 std::string guid = MakeGuid(__FILE__, "foo");
14 ASSERT_EQ(pattern.size(), guid.size());
15 for (size_t i = 0; i < pattern.size(); ++i) {
16 if (pattern[i] == 'x')
17 ASSERT_TRUE(base::IsAsciiAlpha(guid[i]) || base::IsAsciiDigit(guid[i]));
18 else
19 ASSERT_EQ(pattern[i], guid[i]);
20 }
21
22 // Calling function again should produce the same GUID.
23 ASSERT_EQ(guid, MakeGuid(__FILE__, "foo"));
24
25 // GUIDs should be different if path or seed is different.
26 ASSERT_NE(guid, MakeGuid(std::string(__FILE__) + ".txt", "foo"));
27 ASSERT_NE(guid, MakeGuid(__FILE__, "bar"));
28 }
29
30 TEST(VisualStudioUtils, ParseCompilerOption) {
31 CompilerOptions options;
32 ParseCompilerOption("/FIinclude.h", &options);
33 ParseCompilerOption("/FIC:/path/file.h", &options);
34 ASSERT_EQ("include.h;C:/path/file.h;", options.forced_include_files);
35
36 CHECK(options.buffer_security_check.empty());
37 ParseCompilerOption("/GS", &options);
38 ASSERT_EQ("true", options.buffer_security_check);
39 ParseCompilerOption("/GS-", &options);
40 ASSERT_EQ("false", options.buffer_security_check);
41
42 CHECK(options.runtime_library.empty());
43 ParseCompilerOption("/MD", &options);
44 ASSERT_EQ("MultiThreadedDLL", options.runtime_library);
45 ParseCompilerOption("/MDd", &options);
46 ASSERT_EQ("MultiThreadedDebugDLL", options.runtime_library);
47 ParseCompilerOption("/MT", &options);
48 ASSERT_EQ("MultiThreaded", options.runtime_library);
49 ParseCompilerOption("/MTd", &options);
50 ASSERT_EQ("MultiThreadedDebug", options.runtime_library);
51
52 CHECK(options.optimization.empty());
53 ParseCompilerOption("/O1", &options);
54 ASSERT_EQ("MinSpace", options.optimization);
55 ParseCompilerOption("/O2", &options);
56 ASSERT_EQ("MaxSpeed", options.optimization);
57 ParseCompilerOption("/Od", &options);
58 ASSERT_EQ("Disabled", options.optimization);
59 ParseCompilerOption("/Ox", &options);
60 ASSERT_EQ("Full", options.optimization);
61
62 CHECK(options.additional_options.empty());
63 ParseCompilerOption("/TC", &options);
64 ASSERT_TRUE(options.additional_options.empty());
65 ParseCompilerOption("/TP", &options);
66 ASSERT_TRUE(options.additional_options.empty());
67
68 CHECK(options.warning_level.empty());
69 ParseCompilerOption("/W0", &options);
70 ASSERT_EQ("Level0", options.warning_level);
71 ParseCompilerOption("/W1", &options);
72 ASSERT_EQ("Level1", options.warning_level);
73 ParseCompilerOption("/W2", &options);
74 ASSERT_EQ("Level2", options.warning_level);
75 ParseCompilerOption("/W3", &options);
76 ASSERT_EQ("Level3", options.warning_level);
77 ParseCompilerOption("/W4", &options);
78 ASSERT_EQ("Level4", options.warning_level);
79
80 CHECK(options.treat_warning_as_error.empty());
81 ParseCompilerOption("/WX", &options);
82 ASSERT_EQ("true", options.treat_warning_as_error);
83
84 CHECK(options.disable_specific_warnings.empty());
85 ParseCompilerOption("/wd1234", &options);
86 ParseCompilerOption("/wd56", &options);
87 ASSERT_EQ("1234;56;", options.disable_specific_warnings);
88
89 CHECK(options.additional_options.empty());
90 ParseCompilerOption("/MP", &options);
91 ParseCompilerOption("/bigobj", &options);
92 ParseCompilerOption("/Zc:sizedDealloc", &options);
93 ASSERT_EQ("/MP /bigobj /Zc:sizedDealloc ", options.additional_options);
94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698