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

Side by Side Diff: test/string_accumulator_sink_test.dart

Issue 1911053002: Add sinks to provide synchronous access to events. (Closed) Base URL: git@github.com:dart-lang/convert@master
Patch Set: Created 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2016, 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:async';
6
7 import 'package:convert/convert.dart';
8 import 'package:test/test.dart';
9
10 void main() {
11 var sink;
12 setUp(() {
13 sink = new StringAccumulatorSink();
14 });
15
16 test("provides access to the concatenated string", () {
17 expect(sink.string, isEmpty);
18
19 sink.add("foo");
20 expect(sink.string, equals("foo"));
21
22 sink.addSlice(" bar baz", 1, 4, false);
23 expect(sink.string, equals("foobar"));
24 });
25
26 test("indicates whether the sink is closed", () {
27 expect(sink.isClosed, isFalse);
28 sink.close();
29 expect(sink.isClosed, isTrue);
30 });
31
32 test("indicates whether the sink is closed via addSlice", () {
33 expect(sink.isClosed, isFalse);
34 sink.addSlice("", 0, 0, true);
35 expect(sink.isClosed, isTrue);
36 });
37
38 test("doesn't allow add() to be called after close()", () {
39 sink.close();
40 expect(() => sink.add("x"), throwsStateError);
41 });
42
43 test("doesn't allow addSlice() to be called after close()", () {
44 sink.close();
45 expect(() => sink.addSlice("", 0, 0, false), throwsStateError);
46 });
47 }
OLDNEW
« lib/src/string_accumulator_sink.dart ('K') | « test/byte_accumulator_sink_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698