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

Side by Side Diff: tests/standalone/typed_data_test.dart

Issue 13529005: Fix view creation for byte-size types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix checked mode problems Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/typeddata.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // Dart test program for testing typed data. 5 // Dart test program for testing typed data.
6 6
7 // Library tag to be able to run in html test framework. 7 // Library tag to be able to run in html test framework.
8 library TypedDataTest; 8 library TypedDataTest;
9 9
10 import 'dart:typeddata'; 10 import 'dart:typeddata';
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 for (int i = 0; i < bdata.lengthInBytes-7; i+=8) { 272 for (int i = 0; i < bdata.lengthInBytes-7; i+=8) {
273 bdata.setInt64(i, 3038287259199220266); 273 bdata.setInt64(i, 3038287259199220266);
274 } 274 }
275 validate(); 275 validate();
276 for (int i = 0; i < bdata.lengthInBytes-7; i+=8) { 276 for (int i = 0; i < bdata.lengthInBytes-7; i+=8) {
277 bdata.setFloat64(i, 1.4260258159703532e-105); 277 bdata.setFloat64(i, 1.4260258159703532e-105);
278 } 278 }
279 validate(false); 279 validate(false);
280 } 280 }
281 281
282 testViewCreation() {
283 var bytes = new Uint8List(1024);
284 var view = new ByteData.view(bytes, 24);
285 Expect.equals(1000, view.lengthInBytes);
286 view = new Uint8List.view(bytes, 24);
287 Expect.equals(1000, view.lengthInBytes);
288 view = new Int8List.view(bytes, 24);
289 Expect.equals(1000, view.lengthInBytes);
290 view = new Uint8ClampedList.view(bytes, 24);
291 Expect.equals(1000, view.lengthInBytes);
292 view = new Uint16List.view(bytes, 24);
293 Expect.equals(1000, view.lengthInBytes);
294 view = new Int16List.view(bytes, 24);
295 Expect.equals(1000, view.lengthInBytes);
296 view = new Uint32List.view(bytes, 24);
297 Expect.equals(1000, view.lengthInBytes);
298 view = new Int32List.view(bytes, 24);
299 Expect.equals(1000, view.lengthInBytes);
300 view = new Uint64List.view(bytes, 24);
301 Expect.equals(1000, view.lengthInBytes);
302 view = new Int64List.view(bytes, 24);
303 Expect.equals(1000, view.lengthInBytes);
304 view = new Float32List.view(bytes, 24);
305 Expect.equals(1000, view.lengthInBytes);
306 view = new Float64List.view(bytes, 24);
307 Expect.equals(1000, view.lengthInBytes);
308 }
309
310 testWhere() {
311 var bytes = new Uint8List(13);
312 bytes.setRange(0, 5, [1, 1, 1, 1, 1]);
313 Expect.equals(5, bytes.where((v) => v > 0).length);
314 }
315
282 main() { 316 main() {
283 for (int i = 0; i < 2000; i++) { 317 for (int i = 0; i < 2000; i++) {
284 testCreateUint8TypedData(); 318 testCreateUint8TypedData();
285 testCreateClampedUint8TypedData(); 319 testCreateClampedUint8TypedData();
286 testCreateExternalClampedUint8TypedData(); 320 testCreateExternalClampedUint8TypedData();
287 testTypedDataRange(false); 321 testTypedDataRange(false);
288 testUnsignedTypedDataRange(false); 322 testUnsignedTypedDataRange(false);
289 testClampedUnsignedTypedDataRange(false); 323 testClampedUnsignedTypedDataRange(false);
290 testExternalClampedUnsignedTypedDataRange(false); 324 testExternalClampedUnsignedTypedDataRange(false);
291 testSetRange(); 325 testSetRange();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 testSetAtIndex(float32list, 1.511366173271439e-13, true); 362 testSetAtIndex(float32list, 1.511366173271439e-13, true);
329 testGetAtIndex(float32list, 1.511366173271439e-13); 363 testGetAtIndex(float32list, 1.511366173271439e-13);
330 364
331 var float64list = new Float64List(16); 365 var float64list = new Float64List(16);
332 testSetAtIndex(float64list, 1.4260258159703532e-105, true); 366 testSetAtIndex(float64list, 1.4260258159703532e-105, true);
333 testGetAtIndex(float64list, 1.4260258159703532e-105); 367 testGetAtIndex(float64list, 1.4260258159703532e-105);
334 } 368 }
335 testTypedDataRange(true); 369 testTypedDataRange(true);
336 testUnsignedTypedDataRange(true); 370 testUnsignedTypedDataRange(true);
337 testExternalClampedUnsignedTypedDataRange(true); 371 testExternalClampedUnsignedTypedDataRange(true);
372 testViewCreation();
373 testWhere();
338 } 374 }
339 375
OLDNEW
« no previous file with comments | « runtime/lib/typeddata.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698