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

Side by Side Diff: chrome/common/json_schema_validator_unittest_base.cc

Issue 7661009: base: Add Is* functions to Value class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tony review Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/json_schema_validator.cc ('k') | chrome/common/json_value_serializer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/common/json_schema_validator_unittest_base.h" 5 #include "chrome/common/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 22 matching lines...) Expand all
33 Value* result = serializer.Deserialize(NULL, &error_message); 33 Value* result = serializer.Deserialize(NULL, &error_message);
34 if (!result) 34 if (!result)
35 ADD_FAILURE() << "Could not parse JSON: " << error_message; 35 ADD_FAILURE() << "Could not parse JSON: " << error_message;
36 return result; 36 return result;
37 } 37 }
38 38
39 Value* LoadValue(const std::string& filename, base::Value::Type type) { 39 Value* LoadValue(const std::string& filename, base::Value::Type type) {
40 scoped_ptr<Value> result(LoadValue(filename)); 40 scoped_ptr<Value> result(LoadValue(filename));
41 if (!result.get()) 41 if (!result.get())
42 return NULL; 42 return NULL;
43 if (!result->IsType(type)) { 43 if (result->GetType() != type) {
44 ADD_FAILURE() << "Expected type " << type << ", got: " << result->GetType(); 44 ADD_FAILURE() << "Expected type " << type << ", got: " << result->GetType();
45 return NULL; 45 return NULL;
46 } 46 }
47 return result.release(); 47 return result.release();
48 } 48 }
49 49
50 ListValue* LoadList(const std::string& filename) { 50 ListValue* LoadList(const std::string& filename) {
51 return static_cast<ListValue*>( 51 return static_cast<ListValue*>(
52 LoadValue(filename, Value::TYPE_LIST)); 52 LoadValue(filename, Value::TYPE_LIST));
53 } 53 }
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 JSONSchemaValidator::FormatErrorMessage( 619 JSONSchemaValidator::FormatErrorMessage(
620 JSONSchemaValidator::kInvalidType, "boolean", "integer")); 620 JSONSchemaValidator::kInvalidType, "boolean", "integer"));
621 621
622 schema->SetString("type", "null"); 622 schema->SetString("type", "null");
623 ExpectNotValid(TEST_SOURCE, 623 ExpectNotValid(TEST_SOURCE,
624 scoped_ptr<Value>(Value::CreateBooleanValue(false)).get(), 624 scoped_ptr<Value>(Value::CreateBooleanValue(false)).get(),
625 schema.get(), NULL, "", 625 schema.get(), NULL, "",
626 JSONSchemaValidator::FormatErrorMessage( 626 JSONSchemaValidator::FormatErrorMessage(
627 JSONSchemaValidator::kInvalidType, "null", "boolean")); 627 JSONSchemaValidator::kInvalidType, "null", "boolean"));
628 } 628 }
OLDNEW
« no previous file with comments | « chrome/common/json_schema_validator.cc ('k') | chrome/common/json_value_serializer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698