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

Unified Diff: test/cr_lf_remover_test.dart

Issue 1226083002: Fix several Windows issues. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: test/cr_lf_remover_test.dart
diff --git a/test/cr_lf_remover_test.dart b/test/cr_lf_remover_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d97747f93983388f8bd6b6bab894b44709f8a8c9
--- /dev/null
+++ b/test/cr_lf_remover_test.dart
@@ -0,0 +1,102 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS d.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.
+
+import 'dart:convert';
+
+import 'package:charcode/ascii.dart';
+import 'package:pub/src/cr_lf_remover.dart';
+import 'package:test/test.dart';
+
+final _remover = const CRLFRemover();
+
+void main() {
+ group("convert()", () {
+ test("removes CRs before LFs", () {
+ expect(_remover.convert([
+ $f, $o, $o, $cr, $lf,
+ $b, $a, $r, $cr, $lf,
+ $b, $a, $z, $cr, $lf
+ ]), equals([
+ $f, $o, $o, $lf,
+ $b, $a, $r, $lf,
+ $b, $a, $z, $lf
+ ]));
+ });
+
+ test("doesn't remove CRs that aren't before LFs", () {
+ expect(_remover.convert([
+ $f, $o, $o, $cr, $space, $lf,
+ $b, $a, $r, $cr,
+ $b, $a, $z, $cr
+ ]), equals([
+ $f, $o, $o, $cr, $space, $lf,
+ $b, $a, $r, $cr,
+ $b, $a, $z, $cr
+ ]));
+ });
+ });
+
+ group("startChunkedConversion()", () {
+ var result;
+ var sink;
+ setUp(() {
+ sink = _remover.startChunkedConversion(
+ new ByteConversionSink.withCallback((result_) => result = result_));
+ });
+
+ test("removes CRs before LFs", () {
+ sink.add([
+ $f, $o, $o, $cr, $lf,
+ $b, $a, $r, $cr, $lf,
+ $b, $a, $z, $cr, $lf
+ ]);
+
+ sink.close();
+ expect(result, equals([
+ $f, $o, $o, $lf,
+ $b, $a, $r, $lf,
+ $b, $a, $z, $lf
+ ]));
+ });
+
+ test("doesn't remove CRs that aren't before LFs", () {
+ sink.add([
+ $f, $o, $o, $cr, $space, $lf,
+ $b, $a, $r, $cr,
+ $b, $a, $z, $cr
+ ]);
+
+ sink.close();
+ expect(result, equals([
+ $f, $o, $o, $cr, $space, $lf,
+ $b, $a, $r, $cr,
+ $b, $a, $z, $cr
+ ]));
+ });
+
+ test("concatenates chunks", () {
+ sink.add([$f, $o, $o]);
+ sink.add([$b, $a, $r]);
+
+ sink.close();
+ expect(result, equals([$f, $o, $o, $b, $a, $r]));
+ });
+
+ test("remembers CRs between chunks", () {
+ sink.add([$f, $o, $o, $cr]);
+ sink.add([$lf, $b, $a, $r]);
+
+ sink.close();
+ expect(result, equals([$f, $o, $o, $lf, $b, $a, $r]));
+ });
+
+ test("emits unpaired CRs between chunks", () {
+ sink.add([$f, $o, $o, $cr]);
+ sink.add([$b, $a, $r]);
+
+ sink.close();
+ expect(result, equals([$f, $o, $o, $cr, $b, $a, $r]));
+ });
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698