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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 9195031: Add ByteArray interface and provide internal and external implementations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fewer templates Created 8 years, 11 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
diff --git a/runtime/vm/dart_api_impl_test.cc b/runtime/vm/dart_api_impl_test.cc
index 677bdd615128240316859c9a90a5afcbe3d81e28..834514cf814c9397a97d6ffb9d6be79a7788917e 100644
--- a/runtime/vm/dart_api_impl_test.cc
+++ b/runtime/vm/dart_api_impl_test.cc
@@ -615,6 +615,59 @@ TEST_CASE(ListAccess) {
#endif
+TEST_CASE(ByteArray) {
+ Dart_Handle obj1 = Dart_NewByteArray(10);
+ EXPECT_VALID(obj1);
+ EXPECT(Dart_IsByteArray(obj1));
+ EXPECT(Dart_IsList(obj1));
+
+ intptr_t length = 0;
+ Dart_Handle result = Dart_ListLength(obj1, &length);
+ EXPECT_VALID(result);
+ EXPECT_EQ(10, length);
+
+ result = Dart_ListSetAt(obj1, -1, Dart_NewInteger(1));
+ EXPECT(Dart_IsError(result));
+ result = Dart_ListSetAt(obj1, 10, Dart_NewInteger(1));
+ EXPECT(Dart_IsError(result));
+
+ for (intptr_t i = 0; i < 10; ++i) {
+ result = Dart_ListSetAt(obj1, i, Dart_NewInteger(i + 1));
+ EXPECT_VALID(result);
+ }
+
+ for (intptr_t i = 0; i < 10; ++i) {
+ result = Dart_ListGetAt(obj1, i);
+ EXPECT_VALID(result);
+ int64_t value = 0;
+ result = Dart_IntegerToInt64(result, &value);
+ EXPECT_VALID(result);
+ EXPECT_EQ(i + 1, value);
+ }
+
+ Dart_Handle obj2 = Dart_NewByteArray(10);
+ bool is_equal = false;
+ Dart_ObjectEquals(obj1, obj2, &is_equal);
+ EXPECT(!is_equal);
+
+ for (intptr_t i = 0; i < 10; ++i) {
+ result = Dart_ListSetAt(obj2, i, Dart_NewInteger(i + 1));
+ EXPECT_VALID(result);
+ }
+ is_equal = false;
+ Dart_ObjectEquals(obj1, obj2, &is_equal);
+ EXPECT(!is_equal);
+
+ for (intptr_t i = 0; i < 10; ++i) {
+ Dart_Handle e1 = Dart_ListGetAt(obj1, i);
+ Dart_Handle e2 = Dart_ListGetAt(obj2, i);
+ is_equal = false;
+ Dart_ObjectEquals(e1, e2, &is_equal);
+ EXPECT(is_equal);
+ }
+}
+
+
// Unit test for entering a scope, creating a local handle and exiting
// the scope.
UNIT_TEST_CASE(EnterExitScope) {

Powered by Google App Engine
This is Rietveld 408576698