Chromium Code Reviews| Index: tools/json_schema_compiler/test/test_util.cc |
| diff --git a/tools/json_schema_compiler/test/test_util.cc b/tools/json_schema_compiler/test/test_util.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4c10c3ac6acb3cfec61f67042df78615870cc401 |
| --- /dev/null |
| +++ b/tools/json_schema_compiler/test/test_util.cc |
| @@ -0,0 +1,32 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "tools/json_schema_compiler/test/test_util.h" |
| + |
| +#include "base/values.h" |
| + |
| +namespace json_schema_compiler { |
| +namespace test_util { |
| + |
| +scoped_ptr<base::DictionaryValue> ValueMapToDictionary( |
|
Yoyo Zhou
2013/01/15 01:49:25
Why are these converters in test_util? You've used
not at google - send to devlin
2013/01/15 21:47:27
Yeah, I'll delete.
|
| + const std::map<std::string, linked_ptr<base::Value> >& values) { |
| + scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| + for (std::map<std::string, linked_ptr<base::Value> >::const_iterator it = |
| + values.begin(); |
| + it != values.end(); ++it) { |
| + dict->SetWithoutPathExpansion(it->first, it->second->DeepCopy()); |
| + } |
| + return dict.Pass(); |
| +} |
| + |
| +std::map<std::string, linked_ptr<base::Value> > DictionaryToValueMap( |
| + const base::DictionaryValue& dict) { |
| + std::map<std::string, linked_ptr<base::Value> > values; |
| + for (DictionaryValue::Iterator it(dict); it.HasNext(); it.Advance()) |
| + values[it.key()] = make_linked_ptr(it.value().DeepCopy()); |
| + return values; |
| +} |
| + |
| +} // namespace test_util |
| +} // namespace json_schema_compiler |