Chromium Code Reviews| Index: tests/standalone/io/file_typed_data_test.dart |
| diff --git a/tests/standalone/io/file_typed_data_test.dart b/tests/standalone/io/file_typed_data_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5631b4e8a004794c8bf4fb7929c1948d0fac0d17 |
| --- /dev/null |
| +++ b/tests/standalone/io/file_typed_data_test.dart |
| @@ -0,0 +1,39 @@ |
| +// 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. |
| +// |
| +// Dart test program for testing file I/O. |
| + |
| +import "package:expect/expect.dart"; |
| +import 'dart:async'; |
| +import 'dart:io'; |
| +import 'dart:typeddata'; |
| + |
| +void testWriteUint8ListAndView() { |
| + Uint8List list = new Uint8List(8); |
| + for (int i = 0; i < 8; i++) list[i] = i; |
| + var view = new Uint8List.view(list.buffer, 2, 4); |
| + |
| + new Directory('').createTemp().then((temp) { |
| + var file = new File("${temp.path}/test"); |
| + file.open(mode: FileMode.WRITE).then((raf) { |
| + return raf.writeList(list, 0, 8); |
| + }).then((raf) { |
| + return raf.writeList(view, 0, 4); |
| + }).then((raf) { |
| + return raf.close(); |
| + }).then((_) { |
| + var expected = []; |
| + expected.addAll(list); |
| + expected.addAll(view); |
| + var content = file.readAsBytesSync(); |
| + Expect.listEquals(expected, content); |
| + temp.deleteSync(recursive: true); |
|
Mads Ager (google)
2013/04/11 05:57:04
Maybe add a keep-alive port so we time-out if one
Søren Gjesse
2013/04/11 06:47:27
Done.
|
| + }); |
| + }); |
| +} |
| + |
| + |
| +main() { |
| + testWriteUint8ListAndView(); |
| +} |