blob: 2e466e65121939c289ca4fb5537e8d028b5a5e34 [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 Uint8ClampedList.fromList(array);
var byteBuffer = tmp.buffer;
var l = new Uint8ClampedList.view(byteBuffer, offset, length);
Expect.equals(offset, l.offsetInBytes);
}
main() {
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, 1);
check([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 5, 5);
}