mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:16:51 +00:00
e7d4c48a80
Change-Id: I9a51ae6a1f8f4d018da289b6f29ab18053304c19 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132341 Commit-Queue: Erik Ernst <eernst@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
41 lines
1.2 KiB
Dart
41 lines
1.2 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'dart:typed_data';
|
|
import "package:expect/expect.dart";
|
|
|
|
main() {
|
|
testRegress10898();
|
|
}
|
|
|
|
testRegress10898() {
|
|
ByteData data = new ByteData(16);
|
|
Expect.equals(16, data.lengthInBytes);
|
|
for (int i = 0; i < data.lengthInBytes; i++) {
|
|
Expect.equals(0, data.getInt8(i));
|
|
data.setInt8(i, 42 + i);
|
|
Expect.equals(42 + i, data.getInt8(i));
|
|
}
|
|
|
|
ByteData backing = new ByteData(16);
|
|
ByteData view = new ByteData.view(backing.buffer);
|
|
for (int i = 0; i < view.lengthInBytes; i++) {
|
|
Expect.equals(0, view.getInt8(i));
|
|
view.setInt8(i, 87 + i);
|
|
Expect.equals(87 + i, view.getInt8(i));
|
|
}
|
|
|
|
view = new ByteData.view(backing.buffer, 4);
|
|
Expect.equals(12, view.lengthInBytes);
|
|
for (int i = 0; i < view.lengthInBytes; i++) {
|
|
Expect.equals(87 + i + 4, view.getInt8(i));
|
|
}
|
|
|
|
view = new ByteData.view(backing.buffer, 8, 4);
|
|
Expect.equals(4, view.lengthInBytes);
|
|
for (int i = 0; i < view.lengthInBytes; i++) {
|
|
Expect.equals(87 + i + 8, view.getInt8(i));
|
|
}
|
|
}
|