blob: df79fc580cf0c58502736e0a35d98143e46aed0d [file] [log] [blame]
/*
* 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.
*/
/**
* @assertion int offsetInBytes
* Returns the offset in bytes into the underlying byte buffer of this view.
* @description Checks that the returned offset is correct.
* @author msyabro
*/
import "dart:typed_data";
import "../../../Utils/expect.dart";
check(List<int> array, int offset, int length) {
var tmp = new Uint64List.fromList(array);
var byteBuffer = tmp.buffer;
var l = new Uint64List.view(byteBuffer, offset, length);
Expect.equals(offset, l.offsetInBytes);
}
main() {
var elemSize = Uint64List.bytesPerElement;
check([], 0, 0);
check([1], 0, 1);
check([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0, 1);
check([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 9 * elemSize, 1);
check([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 5 * elemSize, 5);
}