OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 #include "tools/gn/err.h" | 6 #include "tools/gn/err.h" |
7 #include "tools/gn/input_conversion.h" | 7 #include "tools/gn/input_conversion.h" |
8 #include "tools/gn/input_file.h" | 8 #include "tools/gn/input_file.h" |
9 #include "tools/gn/parse_tree.h" | 9 #include "tools/gn/parse_tree.h" |
10 #include "tools/gn/scheduler.h" | 10 #include "tools/gn/scheduler.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 const Value* c_value = result.scope_value()->GetValue("c"); | 119 const Value* c_value = result.scope_value()->GetValue("c"); |
120 ASSERT_TRUE(c_value); | 120 ASSERT_TRUE(c_value); |
121 EXPECT_EQ(7, c_value->int_value()); | 121 EXPECT_EQ(7, c_value->int_value()); |
122 | 122 |
123 // Tests that when we get Values out of the input conversion, the resulting | 123 // Tests that when we get Values out of the input conversion, the resulting |
124 // values have an origin set to something corresponding to the input. | 124 // values have an origin set to something corresponding to the input. |
125 const ParseNode* a_origin = a_value->origin(); | 125 const ParseNode* a_origin = a_value->origin(); |
126 ASSERT_TRUE(a_origin); | 126 ASSERT_TRUE(a_origin); |
127 LocationRange a_range = a_origin->GetRange(); | 127 LocationRange a_range = a_origin->GetRange(); |
128 EXPECT_EQ(2, a_range.begin().line_number()); | 128 EXPECT_EQ(2, a_range.begin().line_number()); |
129 EXPECT_EQ(6, a_range.begin().char_offset()); | 129 EXPECT_EQ(6, a_range.begin().column_number()); |
130 | 130 |
131 const InputFile* a_file = a_range.begin().file(); | 131 const InputFile* a_file = a_range.begin().file(); |
132 EXPECT_EQ(input, a_file->contents()); | 132 EXPECT_EQ(input, a_file->contents()); |
133 } | 133 } |
134 | 134 |
135 TEST_F(InputConversionTest, ValueEmpty) { | 135 TEST_F(InputConversionTest, ValueEmpty) { |
136 Err err; | 136 Err err; |
137 Value result = ConvertInputToValue(settings(), "", nullptr, | 137 Value result = ConvertInputToValue(settings(), "", nullptr, |
138 Value(nullptr, "value"), &err); | 138 Value(nullptr, "value"), &err); |
139 EXPECT_FALSE(err.has_error()); | 139 EXPECT_FALSE(err.has_error()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 Err err; | 173 Err err; |
174 Value result = ConvertInputToValue(settings(), "foo", nullptr, Value(), &err); | 174 Value result = ConvertInputToValue(settings(), "foo", nullptr, Value(), &err); |
175 EXPECT_FALSE(err.has_error()); | 175 EXPECT_FALSE(err.has_error()); |
176 EXPECT_EQ(Value::NONE, result.type()); | 176 EXPECT_EQ(Value::NONE, result.type()); |
177 | 177 |
178 result = | 178 result = |
179 ConvertInputToValue(settings(), "foo", nullptr, Value(nullptr, ""), &err); | 179 ConvertInputToValue(settings(), "foo", nullptr, Value(nullptr, ""), &err); |
180 EXPECT_FALSE(err.has_error()); | 180 EXPECT_FALSE(err.has_error()); |
181 EXPECT_EQ(Value::NONE, result.type()); | 181 EXPECT_EQ(Value::NONE, result.type()); |
182 } | 182 } |
OLD | NEW |