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

Side by Side Diff: tests/lib/convert/chunked_conversion2_test.dart

Issue 20374003: Add transformer support to Converters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Upload Created 7 years, 5 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 | « sdk/lib/convert/utf.dart ('k') | tests/lib/convert/json_unicode_tests.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:convert';
6
7 import 'package:expect/expect.dart';
8
9 // Test that the String and ByteConversionSinks make a copy when they need to
10 // adapt.
11
12 class MyByteSink extends ByteConversionSinkBase {
13 var accumulator = [];
14 add(List<int> bytes) {
15 accumulator.add(bytes);
16 }
17 close() {}
18 }
19
20 void testBase() {
21 var byteSink = new MyByteSink();
22 var bytes = [1];
23 byteSink.addSlice(bytes, 0, 1, false);
24 bytes[0] = 2;
25 byteSink.addSlice(bytes, 0, 1, true);
26 Expect.equals(1, byteSink.accumulator[0][0]);
27 Expect.equals(2, byteSink.accumulator[1][0]);
28 }
29
30 class MyChunkedSink extends ChunkedConversionSink {
31 var accumulator = [];
32 add(List<int> bytes) {
33 accumulator.add(bytes);
34 }
35 close() {}
36 }
37
38 void testAdapter() {
39 var chunkedSink = new MyChunkedSink();
40 var byteSink = new ByteConversionSink.from(chunkedSink);
41 var bytes = [1];
42 byteSink.addSlice(bytes, 0, 1, false);
43 bytes[0] = 2;
44 byteSink.addSlice(bytes, 0, 1, true);
45 Expect.equals(1, chunkedSink.accumulator[0][0]);
46 Expect.equals(2, chunkedSink.accumulator[1][0]);
47 }
48
49 void main() {
50 testBase();
51 testAdapter();
52 }
OLDNEW
« no previous file with comments | « sdk/lib/convert/utf.dart ('k') | tests/lib/convert/json_unicode_tests.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698