diff options
author | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-02 01:59:21 +0000 |
---|---|---|
committer | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-02 01:59:21 +0000 |
commit | d3accda938cb8e5417515820b882a539664ac6e3 (patch) | |
tree | 0041ae1e871dacc42ddf8bbad65bead7a7eae2d7 /base/values_unittest.cc | |
parent | 2cd8023ba7173fc6070a48d5cee7e390dd2e9ebd (diff) | |
download | chromium_src-d3accda938cb8e5417515820b882a539664ac6e3.zip chromium_src-d3accda938cb8e5417515820b882a539664ac6e3.tar.gz chromium_src-d3accda938cb8e5417515820b882a539664ac6e3.tar.bz2 |
Modified Value::GetAsDouble so the function returns true when the object holds an Integer.
This should be useful when implementing an extension API in C++ since chrome.api.call(1.0); call in JS passes a Value of Integer to the C++ code while chrome.api.call(1.1); does a Value of Double.
I'm working on this following Mihai's suggestion in http://codereview.chromium.org/6905053/.
BUG=chromium-os:14421
TEST=ran try
Review URL: http://codereview.chromium.org/6893089
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83705 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/values_unittest.cc')
-rw-r--r-- | base/values_unittest.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/base/values_unittest.cc b/base/values_unittest.cc index 809fe90..5fac826 100644 --- a/base/values_unittest.cc +++ b/base/values_unittest.cc @@ -74,10 +74,12 @@ TEST_F(ValuesTest, List) { ASSERT_FALSE(mixed_list->GetInteger(0, &int_value)); ASSERT_EQ(0, int_value); - ASSERT_FALSE(mixed_list->GetDouble(1, &double_value)); - ASSERT_EQ(0.0, double_value); + ASSERT_FALSE(mixed_list->GetBoolean(1, &bool_value)); + ASSERT_FALSE(bool_value); ASSERT_FALSE(mixed_list->GetString(2, &string_value)); ASSERT_EQ("", string_value); + ASSERT_FALSE(mixed_list->GetInteger(2, &int_value)); + ASSERT_EQ(0, int_value); ASSERT_FALSE(mixed_list->GetBoolean(3, &bool_value)); ASSERT_FALSE(bool_value); @@ -85,6 +87,9 @@ TEST_F(ValuesTest, List) { ASSERT_TRUE(bool_value); ASSERT_TRUE(mixed_list->GetInteger(1, &int_value)); ASSERT_EQ(42, int_value); + // implicit conversion from Integer to Double should be possible. + ASSERT_TRUE(mixed_list->GetDouble(1, &double_value)); + ASSERT_EQ(42, double_value); ASSERT_TRUE(mixed_list->GetDouble(2, &double_value)); ASSERT_EQ(88.8, double_value); ASSERT_TRUE(mixed_list->GetString(3, &string_value)); |