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

Side by Side Diff: tests/standalone/io/mime_multipart_parser_test.dart

Issue 10829459: Deprecate Math object in corelib in favor of dart:math library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 4 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 | « tests/standalone/io/http_server_socket_test.dart ('k') | tests/standalone/io/options_test.dart » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #import('dart:math');
6
5 #source("../../../runtime/bin/http_parser.dart"); 7 #source("../../../runtime/bin/http_parser.dart");
6 #source("../../../runtime/bin/mime_multipart_parser.dart"); 8 #source("../../../runtime/bin/mime_multipart_parser.dart");
7 9
8 void testParse(String message, 10 void testParse(String message,
9 String boundary, 11 String boundary,
10 [List<Map> expectedHeaders, 12 [List<Map> expectedHeaders,
11 List expectedParts]) { 13 List expectedParts]) {
12 _MimeMultipartParser parser; 14 _MimeMultipartParser parser;
13 int partCount; 15 int partCount;
14 Map headers; 16 Map headers;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 lastPartCalled = false; 59 lastPartCalled = false;
58 } 60 }
59 61
60 void testWrite(List<int> data, [int chunkSize = -1]) { 62 void testWrite(List<int> data, [int chunkSize = -1]) {
61 if (chunkSize == -1) chunkSize = data.length; 63 if (chunkSize == -1) chunkSize = data.length;
62 reset(); 64 reset();
63 int written = 0; 65 int written = 0;
64 int unparsed; 66 int unparsed;
65 for (int pos = 0; pos < data.length; pos += chunkSize) { 67 for (int pos = 0; pos < data.length; pos += chunkSize) {
66 int remaining = data.length - pos; 68 int remaining = data.length - pos;
67 int writeLength = Math.min(chunkSize, remaining); 69 int writeLength = min(chunkSize, remaining);
68 written += writeLength; 70 written += writeLength;
69 int parsed = 71 int parsed =
70 parser.update(data.getRange(pos, writeLength), 0, writeLength); 72 parser.update(data.getRange(pos, writeLength), 0, writeLength);
71 unparsed = writeLength - parsed; 73 unparsed = writeLength - parsed;
72 Expect.equals(0, unparsed); 74 Expect.equals(0, unparsed);
73 } 75 }
74 Expect.isTrue(lastPartCalled); 76 Expect.isTrue(lastPartCalled);
75 } 77 }
76 78
77 // Test parsing the data three times delivering the data in 79 // Test parsing the data three times delivering the data in
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 \r 331 \r
330 Body2\r 332 Body2\r
331 --xxx\r\n"""; 333 --xxx\r\n""";
332 Expect.throws(() => testParse(message, "xxx", null, [null, null])); 334 Expect.throws(() => testParse(message, "xxx", null, [null, null]));
333 } 335 }
334 336
335 void main() { 337 void main() {
336 testParseValid(); 338 testParseValid();
337 testParseInvalid(); 339 testParseInvalid();
338 } 340 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_server_socket_test.dart ('k') | tests/standalone/io/options_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698