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

Side by Side Diff: vm/dart_api_impl_test.cc

Issue 10782016: Enforce length/size limits for variable size heap object in order to (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 4 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 | « vm/dart_api_impl.cc ('k') | vm/object.h » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "platform/json.h" 7 #include "platform/json.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 6474 matching lines...) Expand 10 before | Expand all | Expand 10 after
6485 EXPECT_VALID(result); 6485 EXPECT_VALID(result);
6486 6486
6487 result = Dart_Invoke(lib, Dart_NewString("testMain"), 0, NULL); 6487 result = Dart_Invoke(lib, Dart_NewString("testMain"), 0, NULL);
6488 EXPECT_VALID(result); 6488 EXPECT_VALID(result);
6489 EXPECT(Dart_IsInteger(result)); 6489 EXPECT(Dart_IsInteger(result));
6490 int64_t value = 0; 6490 int64_t value = 0;
6491 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); 6491 EXPECT_VALID(Dart_IntegerToInt64(result, &value));
6492 EXPECT_EQ(0, value); 6492 EXPECT_EQ(0, value);
6493 } 6493 }
6494 6494
6495
6496 TEST_CASE(RangeLimits) {
6497 uint8_t chars8[1] = {'a'};
6498 uint16_t chars16[1] = {'a'};
6499 uint32_t chars32[1] = {'a'};
6500
6501 EXPECT_ERROR(Dart_NewList(-1),
6502 "expects argument 'length' to be in the range");
6503 EXPECT_ERROR(Dart_NewList(Array::kMaxElements+1),
6504 "expects argument 'length' to be in the range");
6505 EXPECT_ERROR(Dart_NewString8(chars8, -1),
6506 "expects argument 'length' to be in the range");
6507 EXPECT_ERROR(Dart_NewString8(chars8, OneByteString::kMaxElements+1),
6508 "expects argument 'length' to be in the range");
6509 EXPECT_ERROR(Dart_NewString16(chars16, -1),
6510 "expects argument 'length' to be in the range");
6511 EXPECT_ERROR(Dart_NewString16(chars16, TwoByteString::kMaxElements+1),
6512 "expects argument 'length' to be in the range");
6513 EXPECT_ERROR(Dart_NewString32(chars32, -1),
6514 "expects argument 'length' to be in the range");
6515 EXPECT_ERROR(Dart_NewString32(chars32, FourByteString::kMaxElements+1),
6516 "expects argument 'length' to be in the range");
6517 }
6518
6519
6495 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 6520 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
6496 6521
6497 } // namespace dart 6522 } // namespace dart
OLDNEW
« no previous file with comments | « vm/dart_api_impl.cc ('k') | vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698