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

Side by Side Diff: tools/json_schema_compiler/test/error_generation_unittest.cc

Issue 121123002: Update uses of UTF conversions in ppapi/, printing/, remoting/, rlz/, sandbox/, skia/, sql/, sync/,… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | « tools/json_schema_compiler/cc_generator.py ('k') | tools/memory_watcher/memory_watcher.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 2013 The Chromium Authors. All rights reserved. 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 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 "tools/json_schema_compiler/test/error_generation.h" 5 #include "tools/json_schema_compiler/test/error_generation.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "tools/json_schema_compiler/test/test_util.h" 10 #include "tools/json_schema_compiler/test/test_util.h"
11 11
12 using namespace test::api::error_generation; 12 using namespace test::api::error_generation;
13 using base::FundamentalValue; 13 using base::FundamentalValue;
14 using json_schema_compiler::test_util::Dictionary; 14 using json_schema_compiler::test_util::Dictionary;
15 using json_schema_compiler::test_util::List; 15 using json_schema_compiler::test_util::List;
16 16
17 template <typename T> 17 template <typename T>
18 base::string16 GetPopulateError(const base::Value& value) { 18 base::string16 GetPopulateError(const base::Value& value) {
19 base::string16 error; 19 base::string16 error;
20 T test_type; 20 T test_type;
21 T::Populate(value, &test_type, &error); 21 T::Populate(value, &test_type, &error);
22 return error; 22 return error;
23 } 23 }
24 24
25 testing::AssertionResult EqualsUtf16(const std::string& expected, 25 testing::AssertionResult EqualsUtf16(const std::string& expected,
26 const base::string16& actual) { 26 const base::string16& actual) {
27 if (ASCIIToUTF16(expected) != actual) 27 if (base::ASCIIToUTF16(expected) != actual)
28 return testing::AssertionFailure() << expected << " != " << actual; 28 return testing::AssertionFailure() << expected << " != " << actual;
29 return testing::AssertionSuccess(); 29 return testing::AssertionSuccess();
30 } 30 }
31 31
32 // GenerateTypePopulate errors 32 // GenerateTypePopulate errors
33 33
34 TEST(JsonSchemaCompilerErrorTest, RequiredPropertyPopulate) { 34 TEST(JsonSchemaCompilerErrorTest, RequiredPropertyPopulate) {
35 { 35 {
36 scoped_ptr<base::DictionaryValue> value = Dictionary( 36 scoped_ptr<base::DictionaryValue> value = Dictionary(
37 "string", new base::StringValue("bling")); 37 "string", new base::StringValue("bling"));
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 EXPECT_TRUE(EqualsUtf16("", GetPopulateError<HasEnumeration>(*value))); 205 EXPECT_TRUE(EqualsUtf16("", GetPopulateError<HasEnumeration>(*value)));
206 } 206 }
207 { 207 {
208 scoped_ptr<base::DictionaryValue> value = Dictionary( 208 scoped_ptr<base::DictionaryValue> value = Dictionary(
209 "enumeration", new base::StringValue("bad sauce")); 209 "enumeration", new base::StringValue("bad sauce"));
210 EXPECT_TRUE(EqualsUtf16("'enumeration': expected \"one\" or \"two\" " 210 EXPECT_TRUE(EqualsUtf16("'enumeration': expected \"one\" or \"two\" "
211 "or \"three\", got \"bad sauce\"", 211 "or \"three\", got \"bad sauce\"",
212 GetPopulateError<HasEnumeration>(*value))); 212 GetPopulateError<HasEnumeration>(*value)));
213 } 213 }
214 } 214 }
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/cc_generator.py ('k') | tools/memory_watcher/memory_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698