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 3 // found in the LICENSE file. 4 5 #ifndef TOOLS_JSON_SCHEMA_COMPILER_TEST_TEST_UTIL_H_ 6 #define TOOLS_JSON_SCHEMA_COMPILER_TEST_TEST_UTIL_H_ 7 8 #include "base/memory/scoped_ptr.h" 9 #include "base/strings/string_piece.h" 10 #include "base/values.h" 11 12 namespace json_schema_compiler { 13 namespace test_util { 14 15 scoped_ptr<base::Value> ReadJson(const base::StringPiece& json); 16 17 template <typename T> 18 std::vector<T> Vector(const T& a) { 19 std::vector<T> arr; 20 arr.push_back(a); 21 return arr; 22 } 23 template <typename T> 24 std::vector<T> Vector(const T& a, const T& b) { 25 std::vector<T> arr = Vector(a); 26 arr.push_back(b); 27 return arr; 28 } 29 template <typename T> 30 std::vector<T> Vector(const T& a, const T& b, const T& c) { 31 std::vector<T> arr = Vector(a, b); 32 arr.push_back(c); 33 return arr; 34 } 35 36 scoped_ptr<base::ListValue> List(base::Value* a); 37 scoped_ptr<base::ListValue> List(base::Value* a, base::Value* b); 38 scoped_ptr<base::ListValue> List(base::Value* a, 39 base::Value* b, 40 base::Value* c); 41 42 scoped_ptr<base::DictionaryValue> Dictionary( 43 const std::string& ak, base::Value* av); 44 scoped_ptr<base::DictionaryValue> Dictionary( 45 const std::string& ak, base::Value* av, 46 const std::string& bk, base::Value* bv); 47 scoped_ptr<base::DictionaryValue> Dictionary( 48 const std::string& ak, base::Value* av, 49 const std::string& bk, base::Value* bv, 50 const std::string& ck, base::Value* cv); 51 52 } // namespace test_util 53 } // namespace json_schema_compiler 54 55 #endif // TOOLS_JSON_SCHEMA_COMPILER_TEST_TEST_UTIL_H_ 56