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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 1284633004: Add Dart_ListGetRange (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/sdk.git@master
Patch Set: Address review comments Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl_test.cc
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index 9b2847a39d111912d6a3f5e1eed9c1a42354bd25..3d0b9b848eb3bb1829525c1308918aff0672b967 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -1368,6 +1368,28 @@ TEST_CASE(ListAccess) {
result = Dart_ListGetAt(list_access_test_obj, 4);
EXPECT(Dart_IsError(result));
+ // Check if we can get a range of values.
+ result = Dart_ListGetRange(list_access_test_obj, 8, 4, NULL);
+ EXPECT(Dart_IsError(result));
+ const int kRangeOffset = 1;
+ const int kRangeLength = 2;
+ Dart_Handle values[kRangeLength];
+
+ result = Dart_ListGetRange(list_access_test_obj, 8, 4, values);
+ EXPECT(Dart_IsError(result));
+
+ result = Dart_ListGetRange(
+ list_access_test_obj, kRangeOffset, kRangeLength, values);
+ EXPECT_VALID(result);
+
+ result = Dart_IntegerToInt64(values[0], &value);
+ EXPECT_VALID(result);
+ EXPECT_EQ(20, value);
+
+ result = Dart_IntegerToInt64(values[1], &value);
+ EXPECT_VALID(result);
+ EXPECT_EQ(30, value);
+
// Check that we get an exception (and not a fatal error) when
// calling ListSetAt and ListSetAsBytes with an immutable list.
list_access_test_obj = Dart_Invoke(lib, NewString("immutable"), 0, NULL);
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698