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

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

Issue 94043003: Ignore unknown attributes when parsing JSON schemas. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added Options enum Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « components/policy/core/common/schema.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/policy/core/common/schema_internal.h" 7 #include "components/policy/core/common/schema_internal.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace policy { 10 namespace policy {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 "{" 104 "{"
105 " \"type\": \"object\"," 105 " \"type\": \"object\","
106 " \"properties\": { \"Policy\": { \"type\": \"any\" } }" 106 " \"properties\": { \"Policy\": { \"type\": \"any\" } }"
107 "}")); 107 "}"));
108 108
109 EXPECT_TRUE(ParseFails( 109 EXPECT_TRUE(ParseFails(
110 "{" 110 "{"
111 " \"type\": \"object\"," 111 " \"type\": \"object\","
112 " \"properties\": { \"Policy\": 123 }" 112 " \"properties\": { \"Policy\": 123 }"
113 "}")); 113 "}"));
114
115 EXPECT_FALSE(ParseFails(
116 "{"
117 " \"type\": \"object\","
118 " \"unknown attribute\": \"is ignored\""
119 "}"));
114 } 120 }
115 121
116 TEST(SchemaTest, Ownership) { 122 TEST(SchemaTest, Ownership) {
117 std::string error; 123 std::string error;
118 Schema schema = Schema::Parse( 124 Schema schema = Schema::Parse(
119 "{" 125 "{"
120 " \"type\": \"object\"," 126 " \"type\": \"object\","
121 " \"properties\": {" 127 " \"properties\": {"
122 " \"sub\": {" 128 " \"sub\": {"
123 " \"type\": \"object\"," 129 " \"type\": \"object\","
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 ASSERT_TRUE(list.valid()); 677 ASSERT_TRUE(list.valid());
672 ASSERT_EQ(base::Value::TYPE_LIST, list.type()); 678 ASSERT_EQ(base::Value::TYPE_LIST, list.type());
673 679
674 Schema items = list.GetItems(); 680 Schema items = list.GetItems();
675 ASSERT_TRUE(items.valid()); 681 ASSERT_TRUE(items.valid());
676 ASSERT_EQ(base::Value::TYPE_BOOLEAN, items.type()); 682 ASSERT_EQ(base::Value::TYPE_BOOLEAN, items.type());
677 } 683 }
678 684
679 685
680 } // namespace policy 686 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/schema.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698