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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 21562002: Improve performance of Dart_ListGetAsBytes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments Created 7 years, 5 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
Index: runtime/vm/dart_api_impl_test.cc
===================================================================
--- runtime/vm/dart_api_impl_test.cc (revision 25704)
+++ runtime/vm/dart_api_impl_test.cc (working copy)
@@ -832,6 +832,39 @@
}
+TEST_CASE(TypedDataViewListGetAsBytes) {
+ const int kSize = 1000;
+
+ const char* kScriptChars =
+ "import 'dart:typed_data';\n"
+ "List main(int size) {\n"
+ " var a = new Int8List(size);\n"
+ " var view = new Int8List.view(a.buffer, 0, size);\n"
+ " return view;\n"
+ "}\n";
+ // Create a test library and Load up a test script in it.
+ Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
+
+ // Test with a typed data view object.
+ Dart_Handle dart_args[1];
+ dart_args[0] = Dart_NewInteger(kSize);
+ Dart_Handle view_obj = Dart_Invoke(lib, NewString("main"), 1, dart_args);
+ EXPECT_VALID(view_obj);
+ for (intptr_t i = 0; i < kSize; ++i) {
+ EXPECT_VALID(Dart_ListSetAt(view_obj, i, Dart_NewInteger(i & 0xff)));
+ }
+ uint8_t* data = new uint8_t[kSize];
+ EXPECT_VALID(Dart_ListGetAsBytes(view_obj, 0, data, kSize));
+ for (intptr_t i = 0; i < kSize; ++i) {
+ EXPECT_EQ(i & 0xff, data[i]);
+ }
+
+ Dart_Handle result = Dart_ListGetAsBytes(view_obj, 0, data, kSize + 1);
+ EXPECT(Dart_IsError(result));
+ delete[] data;
+}
+
+
TEST_CASE(TypedDataAccess) {
EXPECT_EQ(Dart_TypedData_kInvalid,
Dart_GetTypeOfTypedData(Dart_True()));

Powered by Google App Engine
This is Rietveld 408576698