blob: c619a7cf995a60c41b90b2beb4d904d547b1b097 [file] [log] [blame]
// Copyright (c) 2017, 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.
/**
* @assertion void add(T chunk)
* Adds chunked data to this sink.
*
* This method is also used when converters are used as StreamTransformers.
* @description Checks that this method adds data to the ChunkedConversionSink.
* Test chunk modification
* @author sgrekhov@unipro.ru
*/
library add_A01_t02;
import "dart:convert";
import "../../../Utils/expect.dart";
test(ChunkedConversionSink create(ChunkedConversionSink<List<int>> outSink)) {
bool called = false;
Utf8Codec codec = new Utf8Codec();
var encoded1 = codec.encode("Кириллица");
var encoded2 = codec.encode("кириллица");
var outSink = new ChunkedConversionSink<List<int>>.withCallback((accumulated) {
called = true;
Expect.listEquals([encoded1, encoded2], accumulated);
});
ByteConversionSink inSink = create(outSink) as ByteConversionSink;
var list = utf8.encode("Кириллица");
Expect.isFalse(called);
inSink.add(list);
// Lowercase the first letter (к)
list[0] = 0xd0;
list[1] = 0xba;
inSink.add(list);
Expect.isFalse(called);
inSink.close();
Expect.isTrue(called);
}