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

Side by Side Diff: components/json_schema/json_schema_validator_unittest_base.cc

Issue 1129083003: More base::Values-related bare pointer -> scoped_ptr conversions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix bad merge Created 5 years, 7 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/json_schema/json_schema_validator_unittest_base.h" 5 #include "components/json_schema/json_schema_validator_unittest_base.h"
6 6
7 #include <cfloat> 7 #include <cfloat>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 ExpectValid(TEST_SOURCE, 147 ExpectValid(TEST_SOURCE,
148 scoped_ptr<base::Value>(new base::FundamentalValue(false)).get(), 148 scoped_ptr<base::Value>(new base::FundamentalValue(false)).get(),
149 schema.get(), NULL); 149 schema.get(), NULL);
150 150
151 ExpectNotValid(TEST_SOURCE, 151 ExpectNotValid(TEST_SOURCE,
152 scoped_ptr<base::Value>(new base::StringValue("42")).get(), 152 scoped_ptr<base::Value>(new base::StringValue("42")).get(),
153 schema.get(), 153 schema.get(),
154 NULL, 154 NULL,
155 std::string(), 155 std::string(),
156 JSONSchemaValidator::kInvalidEnum); 156 JSONSchemaValidator::kInvalidEnum);
157 ExpectNotValid(TEST_SOURCE, 157 ExpectNotValid(TEST_SOURCE, base::Value::CreateNullValue().get(),
158 scoped_ptr<base::Value>(base::Value::CreateNullValue()).get(), 158 schema.get(), NULL, std::string(),
159 schema.get(),
160 NULL,
161 std::string(),
162 JSONSchemaValidator::kInvalidEnum); 159 JSONSchemaValidator::kInvalidEnum);
163 } 160 }
164 161
165 void JSONSchemaValidatorTestBase::TestChoices() { 162 void JSONSchemaValidatorTestBase::TestChoices() {
166 scoped_ptr<base::DictionaryValue> schema( 163 scoped_ptr<base::DictionaryValue> schema(
167 LoadDictionary("choices_schema.json")); 164 LoadDictionary("choices_schema.json"));
168 165
169 ExpectValid(TEST_SOURCE, 166 ExpectValid(TEST_SOURCE, base::Value::CreateNullValue().get(), schema.get(),
170 scoped_ptr<base::Value>(base::Value::CreateNullValue()).get(), 167 NULL);
171 schema.get(), NULL);
172 ExpectValid(TEST_SOURCE, 168 ExpectValid(TEST_SOURCE,
173 scoped_ptr<base::Value>(new base::FundamentalValue(42)).get(), 169 scoped_ptr<base::Value>(new base::FundamentalValue(42)).get(),
174 schema.get(), NULL); 170 schema.get(), NULL);
175 171
176 scoped_ptr<base::DictionaryValue> instance(new base::DictionaryValue()); 172 scoped_ptr<base::DictionaryValue> instance(new base::DictionaryValue());
177 instance->SetString("foo", "bar"); 173 instance->SetString("foo", "bar");
178 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); 174 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
179 175
180 ExpectNotValid(TEST_SOURCE, 176 ExpectNotValid(TEST_SOURCE,
181 scoped_ptr<base::Value>(new base::StringValue("foo")).get(), 177 scoped_ptr<base::Value>(new base::StringValue("foo")).get(),
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 JSONSchemaValidator::GetJSONSchemaType( 609 JSONSchemaValidator::GetJSONSchemaType(
614 scoped_ptr<base::Value>(new base::StringValue("foo")).get())); 610 scoped_ptr<base::Value>(new base::StringValue("foo")).get()));
615 EXPECT_EQ(std::string(schema::kArray), 611 EXPECT_EQ(std::string(schema::kArray),
616 JSONSchemaValidator::GetJSONSchemaType( 612 JSONSchemaValidator::GetJSONSchemaType(
617 scoped_ptr<base::Value>(new base::ListValue()).get())); 613 scoped_ptr<base::Value>(new base::ListValue()).get()));
618 EXPECT_EQ(std::string(schema::kObject), 614 EXPECT_EQ(std::string(schema::kObject),
619 JSONSchemaValidator::GetJSONSchemaType( 615 JSONSchemaValidator::GetJSONSchemaType(
620 scoped_ptr<base::Value>(new base::DictionaryValue()).get())); 616 scoped_ptr<base::Value>(new base::DictionaryValue()).get()));
621 EXPECT_EQ(std::string(schema::kNull), 617 EXPECT_EQ(std::string(schema::kNull),
622 JSONSchemaValidator::GetJSONSchemaType( 618 JSONSchemaValidator::GetJSONSchemaType(
623 scoped_ptr<base::Value>(base::Value::CreateNullValue()).get())); 619 base::Value::CreateNullValue().get()));
624 } 620 }
625 621
626 void JSONSchemaValidatorTestBase::TestTypes() { 622 void JSONSchemaValidatorTestBase::TestTypes() {
627 scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue()); 623 scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue());
628 624
629 // valid 625 // valid
630 schema->SetString(schema::kType, schema::kObject); 626 schema->SetString(schema::kType, schema::kObject);
631 ExpectValid(TEST_SOURCE, 627 ExpectValid(TEST_SOURCE,
632 scoped_ptr<base::Value>(new base::DictionaryValue()).get(), 628 scoped_ptr<base::Value>(new base::DictionaryValue()).get(),
633 schema.get(), NULL); 629 schema.get(), NULL);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 672
677 schema->SetString(schema::kType, schema::kBoolean); 673 schema->SetString(schema::kType, schema::kBoolean);
678 ExpectValid(TEST_SOURCE, 674 ExpectValid(TEST_SOURCE,
679 scoped_ptr<base::Value>(new base::FundamentalValue(false)).get(), 675 scoped_ptr<base::Value>(new base::FundamentalValue(false)).get(),
680 schema.get(), NULL); 676 schema.get(), NULL);
681 ExpectValid(TEST_SOURCE, 677 ExpectValid(TEST_SOURCE,
682 scoped_ptr<base::Value>(new base::FundamentalValue(true)).get(), 678 scoped_ptr<base::Value>(new base::FundamentalValue(true)).get(),
683 schema.get(), NULL); 679 schema.get(), NULL);
684 680
685 schema->SetString(schema::kType, schema::kNull); 681 schema->SetString(schema::kType, schema::kNull);
686 ExpectValid(TEST_SOURCE, 682 ExpectValid(TEST_SOURCE, base::Value::CreateNullValue().get(), schema.get(),
687 scoped_ptr<base::Value>(base::Value::CreateNullValue()).get(), 683 NULL);
688 schema.get(), NULL);
689 684
690 // not valid 685 // not valid
691 schema->SetString(schema::kType, schema::kObject); 686 schema->SetString(schema::kType, schema::kObject);
692 ExpectNotValid( 687 ExpectNotValid(
693 TEST_SOURCE, 688 TEST_SOURCE,
694 scoped_ptr<base::Value>(new base::ListValue()).get(), 689 scoped_ptr<base::Value>(new base::ListValue()).get(),
695 schema.get(), 690 schema.get(),
696 NULL, 691 NULL,
697 std::string(), 692 std::string(),
698 JSONSchemaValidator::FormatErrorMessage( 693 JSONSchemaValidator::FormatErrorMessage(
699 JSONSchemaValidator::kInvalidType, schema::kObject, schema::kArray)); 694 JSONSchemaValidator::kInvalidType, schema::kObject, schema::kArray));
700 695
701 schema->SetString(schema::kType, schema::kObject); 696 schema->SetString(schema::kType, schema::kObject);
702 ExpectNotValid( 697 ExpectNotValid(
703 TEST_SOURCE, 698 TEST_SOURCE, base::Value::CreateNullValue().get(), schema.get(), NULL,
704 scoped_ptr<base::Value>(base::Value::CreateNullValue()).get(),
705 schema.get(),
706 NULL,
707 std::string(), 699 std::string(),
708 JSONSchemaValidator::FormatErrorMessage( 700 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType,
709 JSONSchemaValidator::kInvalidType, schema::kObject, schema::kNull)); 701 schema::kObject, schema::kNull));
710 702
711 schema->SetString(schema::kType, schema::kArray); 703 schema->SetString(schema::kType, schema::kArray);
712 ExpectNotValid( 704 ExpectNotValid(
713 TEST_SOURCE, 705 TEST_SOURCE,
714 scoped_ptr<base::Value>(new base::FundamentalValue(42)).get(), 706 scoped_ptr<base::Value>(new base::FundamentalValue(42)).get(),
715 schema.get(), 707 schema.get(),
716 NULL, 708 NULL,
717 std::string(), 709 std::string(),
718 JSONSchemaValidator::FormatErrorMessage( 710 JSONSchemaValidator::FormatErrorMessage(
719 JSONSchemaValidator::kInvalidType, schema::kArray, schema::kInteger)); 711 JSONSchemaValidator::kInvalidType, schema::kArray, schema::kInteger));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 schema->SetString(schema::kType, schema::kNull); 754 schema->SetString(schema::kType, schema::kNull);
763 ExpectNotValid( 755 ExpectNotValid(
764 TEST_SOURCE, 756 TEST_SOURCE,
765 scoped_ptr<base::Value>(new base::FundamentalValue(false)).get(), 757 scoped_ptr<base::Value>(new base::FundamentalValue(false)).get(),
766 schema.get(), 758 schema.get(),
767 NULL, 759 NULL,
768 std::string(), 760 std::string(),
769 JSONSchemaValidator::FormatErrorMessage( 761 JSONSchemaValidator::FormatErrorMessage(
770 JSONSchemaValidator::kInvalidType, schema::kNull, schema::kBoolean)); 762 JSONSchemaValidator::kInvalidType, schema::kNull, schema::kBoolean));
771 } 763 }
OLDNEW
« no previous file with comments | « components/history/core/browser/top_sites_impl.cc ('k') | components/policy/core/common/mac_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698