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

Side by Side Diff: components/policy/core/common/schema_unittest.cc

Issue 1902633006: Convert //components/policy from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and use namespace alias Created 4 years, 8 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "components/policy/core/common/schema.h" 5 #include "components/policy/core/common/schema.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
10
9 #include "base/macros.h" 11 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
12 #include "components/policy/core/common/schema_internal.h" 13 #include "components/policy/core/common/schema_internal.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace policy { 16 namespace policy {
16 17
17 namespace { 18 namespace {
18 19
19 #define TestSchemaValidation(a, b, c, d) \ 20 #define TestSchemaValidation(a, b, c, d) \
20 TestSchemaValidationHelper( \ 21 TestSchemaValidationHelper( \
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 static const char kNoErrorReturned[] = "No error returned."; 150 static const char kNoErrorReturned[] = "No error returned.";
150 151
151 // Test that Schema::Validate() works as expected. 152 // Test that Schema::Validate() works as expected.
152 error = kNoErrorReturned; 153 error = kNoErrorReturned;
153 bool returned = schema.Validate(value, strategy, NULL, &error); 154 bool returned = schema.Validate(value, strategy, NULL, &error);
154 ASSERT_EQ(expected_return_value, returned) << source << ": " << error; 155 ASSERT_EQ(expected_return_value, returned) << source << ": " << error;
155 156
156 // Test that Schema::Normalize() will return the same value as 157 // Test that Schema::Normalize() will return the same value as
157 // Schema::Validate(). 158 // Schema::Validate().
158 error = kNoErrorReturned; 159 error = kNoErrorReturned;
159 scoped_ptr<base::Value> cloned_value(value.DeepCopy()); 160 std::unique_ptr<base::Value> cloned_value(value.DeepCopy());
160 bool touched = false; 161 bool touched = false;
161 returned = 162 returned =
162 schema.Normalize(cloned_value.get(), strategy, NULL, &error, &touched); 163 schema.Normalize(cloned_value.get(), strategy, NULL, &error, &touched);
163 EXPECT_EQ(expected_return_value, returned) << source << ": " << error; 164 EXPECT_EQ(expected_return_value, returned) << source << ": " << error;
164 165
165 bool strictly_valid = schema.Validate(value, SCHEMA_STRICT, NULL, &error); 166 bool strictly_valid = schema.Validate(value, SCHEMA_STRICT, NULL, &error);
166 EXPECT_EQ(touched, !strictly_valid && returned) << source; 167 EXPECT_EQ(touched, !strictly_valid && returned) << source;
167 168
168 // Test that Schema::Normalize() have actually dropped invalid and unknown 169 // Test that Schema::Normalize() have actually dropped invalid and unknown
169 // properties. 170 // properties.
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 1174
1174 EXPECT_FALSE(ParseFails(SchemaObjectWrapper( 1175 EXPECT_FALSE(ParseFails(SchemaObjectWrapper(
1175 "{" 1176 "{"
1176 " \"type\": \"integer\"," 1177 " \"type\": \"integer\","
1177 " \"minimum\": 10," 1178 " \"minimum\": 10,"
1178 " \"maximum\": 20" 1179 " \"maximum\": 20"
1179 "}"))); 1180 "}")));
1180 } 1181 }
1181 1182
1182 } // namespace policy 1183 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/schema_registry_unittest.cc ('k') | components/policy/tools/generate_policy_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698