diff options
author | dsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 20:21:01 +0000 |
---|---|---|
committer | dsh@google.com <dsh@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 20:21:01 +0000 |
commit | 32c147158f76e19aa22efa2a7b14d3f0e1e23a02 (patch) | |
tree | a84b94bc6c2e4e52d009db317ed49a343658634c /chrome/common/json_value_serializer_unittest.cc | |
parent | 600a41fb05efe99eb2890e884a7af0541456c365 (diff) | |
download | chromium_src-32c147158f76e19aa22efa2a7b14d3f0e1e23a02.zip chromium_src-32c147158f76e19aa22efa2a7b14d3f0e1e23a02.tar.gz chromium_src-32c147158f76e19aa22efa2a7b14d3f0e1e23a02.tar.bz2 |
Port DictionaryValue to use string16 instead of wstring.
Review URL: http://codereview.chromium.org/31014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10818 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/json_value_serializer_unittest.cc')
-rw-r--r-- | chrome/common/json_value_serializer_unittest.cc | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/chrome/common/json_value_serializer_unittest.cc b/chrome/common/json_value_serializer_unittest.cc index 1fc9e97..f09f8d3 100644 --- a/chrome/common/json_value_serializer_unittest.cc +++ b/chrome/common/json_value_serializer_unittest.cc @@ -24,20 +24,20 @@ TEST(JSONValueSerializerTest, Roundtrip) { DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get()); Value* null_value = NULL; - ASSERT_TRUE(root_dict->Get(L"null", &null_value)); + ASSERT_TRUE(root_dict->Get(LIT16("null"), &null_value)); ASSERT_TRUE(null_value); ASSERT_TRUE(null_value->IsType(Value::TYPE_NULL)); bool bool_value = false; - ASSERT_TRUE(root_dict->GetBoolean(L"bool", &bool_value)); + ASSERT_TRUE(root_dict->GetBoolean(LIT16("bool"), &bool_value)); ASSERT_TRUE(bool_value); int int_value = 0; - ASSERT_TRUE(root_dict->GetInteger(L"int", &int_value)); + ASSERT_TRUE(root_dict->GetInteger(LIT16("int"), &int_value)); ASSERT_EQ(42, int_value); double real_value = 0.0; - ASSERT_TRUE(root_dict->GetReal(L"real", &real_value)); + ASSERT_TRUE(root_dict->GetReal(LIT16("real"), &real_value)); ASSERT_DOUBLE_EQ(3.14, real_value); // We shouldn't be able to write using this serializer, since it was @@ -92,7 +92,7 @@ TEST(JSONValueSerializerTest, StringEscape) { // Test JSONWriter interface std::string output_js; DictionaryValue valueRoot; - valueRoot.SetString(L"all_chars", all_chars); + valueRoot.SetString(LIT16("all_chars"), WideToUTF16Hack(all_chars)); JSONWriter::Write(&valueRoot, false, &output_js); ASSERT_EQ(expected_output, output_js); @@ -106,7 +106,7 @@ TEST(JSONValueSerializerTest, UnicodeStrings) { // unicode string json -> escaped ascii text DictionaryValue root; std::wstring test(L"\x7F51\x9875"); - root.SetString(L"web", test); + root.SetString(LIT16("web"), WideToUTF16Hack(test)); std::string expected = "{\"web\":\"\\u7F51\\u9875\"}"; @@ -121,16 +121,16 @@ TEST(JSONValueSerializerTest, UnicodeStrings) { ASSERT_TRUE(deserial_root.get()); DictionaryValue* dict_root = static_cast<DictionaryValue*>(deserial_root.get()); - std::wstring web_value; - ASSERT_TRUE(dict_root->GetString(L"web", &web_value)); - ASSERT_EQ(test, web_value); + string16 web_value; + ASSERT_TRUE(dict_root->GetString(LIT16("web"), &web_value)); + ASSERT_EQ(test, UTF16ToWideHack(web_value)); } TEST(JSONValueSerializerTest, HexStrings) { // hex string json -> escaped ascii text DictionaryValue root; std::wstring test(L"\x01\x02"); - root.SetString(L"test", test); + root.SetString(LIT16("test"), WideToUTF16Hack(test)); std::string expected = "{\"test\":\"\\x01\\x02\"}"; @@ -145,9 +145,9 @@ TEST(JSONValueSerializerTest, HexStrings) { ASSERT_TRUE(deserial_root.get()); DictionaryValue* dict_root = static_cast<DictionaryValue*>(deserial_root.get()); - std::wstring test_value; - ASSERT_TRUE(dict_root->GetString(L"test", &test_value)); - ASSERT_EQ(test, test_value); + string16 test_value; + ASSERT_TRUE(dict_root->GetString(LIT16("test"), &test_value)); + ASSERT_EQ(test, UTF16ToWideHack(test_value)); // Test converting escaped regular chars std::string escaped_chars = "{\"test\":\"\\x67\\x6f\"}"; @@ -155,8 +155,8 @@ TEST(JSONValueSerializerTest, HexStrings) { deserial_root.reset(deserializer2.Deserialize(NULL)); ASSERT_TRUE(deserial_root.get()); dict_root = static_cast<DictionaryValue*>(deserial_root.get()); - ASSERT_TRUE(dict_root->GetString(L"test", &test_value)); - ASSERT_EQ(std::wstring(L"go"), test_value); + ASSERT_TRUE(dict_root->GetString(LIT16("test"), &test_value)); + ASSERT_EQ(L"go", UTF16ToWideHack(test_value)); } TEST(JSONValueSerializerTest, AllowTrailingComma) { @@ -260,21 +260,21 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) { DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get()); Value* null_value = NULL; - ASSERT_TRUE(root_dict->Get(L"null", &null_value)); + ASSERT_TRUE(root_dict->Get(LIT16("null"), &null_value)); ASSERT_TRUE(null_value); ASSERT_TRUE(null_value->IsType(Value::TYPE_NULL)); bool bool_value = false; - ASSERT_TRUE(root_dict->GetBoolean(L"bool", &bool_value)); + ASSERT_TRUE(root_dict->GetBoolean(LIT16("bool"), &bool_value)); ASSERT_TRUE(bool_value); int int_value = 0; - ASSERT_TRUE(root_dict->GetInteger(L"int", &int_value)); + ASSERT_TRUE(root_dict->GetInteger(LIT16("int"), &int_value)); ASSERT_EQ(42, int_value); - std::wstring string_value; - ASSERT_TRUE(root_dict->GetString(L"string", &string_value)); - ASSERT_EQ(L"hello", string_value); + string16 string_value; + ASSERT_TRUE(root_dict->GetString(LIT16("string"), &string_value)); + ASSERT_EQ(L"hello", UTF16ToWideHack(string_value)); // Now try writing. std::wstring written_file_path = test_dir_; |