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

Unified Diff: test/cctest/test-conversions.cc

Issue 2548243004: Return false in TryNumberToSize if there is a cast error (Closed)
Patch Set: Return false in TryNumberToSize if there is a cast error Created 4 years 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 side-by-side diff with in-line comments
Download patch
« src/conversions-inl.h ('K') | « src/conversions-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-conversions.cc
diff --git a/test/cctest/test-conversions.cc b/test/cctest/test-conversions.cc
index 2fee58a46d11a96f7370c5522fb541c3bce766f0..441bcaa7cd1d759ec667d8fb43677efdfa01f37c 100644
--- a/test/cctest/test-conversions.cc
+++ b/test/cctest/test-conversions.cc
@@ -444,3 +444,19 @@ TEST(NoHandlesForTryNumberToSize) {
}
}
}
+
+TEST(CastErrorInTryNumberToSize) {
+ i::Isolate* isolate = CcTest::i_isolate();
+ UnicodeCache uc;
+ size_t result = 0;
+ {
+ HandleScope scope(isolate);
+ double value = StringToDouble(&uc, "0x10000000000000000",
ahaas 2016/12/07 16:20:38 I think you could just write double value = 18446
qiuyi.zqy 2016/12/07 18:13:36 Done.
+ ALLOW_HEX | ALLOW_IMPLICIT_OCTAL);
+ Handle<HeapNumber> heap_number = isolate->factory()->NewHeapNumber(value);
+ bool success = TryNumberToSize(*heap_number, &result);
+ if (success && value > 0) {
ahaas 2016/12/07 16:20:38 I think you could just write "CHECK(!success);" in
qiuyi.zqy 2016/12/07 18:13:36 Done.
+ CHECK(result != 0);
+ }
+ }
+}
« src/conversions-inl.h ('K') | « src/conversions-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698