OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |