test_util.h 1.9 KB

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