Index: test/line_scanner_test.dart |
diff --git a/test/line_scanner_test.dart b/test/line_scanner_test.dart |
index 9874cb309461304aa0f250797b28016df1059e13..ed04b371c1e4b713e967c3c3a51c0f99a5b06095 100644 |
--- a/test/line_scanner_test.dart |
+++ b/test/line_scanner_test.dart |
@@ -2,6 +2,7 @@ |
// 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 'package:charcode/charcode.dart'; |
import 'package:string_scanner/string_scanner.dart'; |
import 'package:test/test.dart'; |
@@ -80,6 +81,39 @@ void main() { |
}); |
}); |
+ group("scanChar()", () { |
+ test("on a non-newline character increases the column but not the line", |
+ () { |
+ scanner.scanChar($f); |
+ expect(scanner.line, equals(0)); |
+ expect(scanner.column, equals(1)); |
+ }); |
+ |
+ test("consuming a newline resets the column and increases the line", () { |
+ scanner.expect('foo'); |
+ expect(scanner.line, equals(0)); |
+ expect(scanner.column, equals(3)); |
+ |
+ scanner.scanChar($lf); |
+ expect(scanner.line, equals(1)); |
+ expect(scanner.column, equals(0)); |
+ }); |
+ |
+ test("consuming halfway through a CR LF doesn't count as a line", () { |
+ scanner.expect('foo\nbar'); |
+ expect(scanner.line, equals(1)); |
+ expect(scanner.column, equals(3)); |
+ |
+ scanner.scanChar($cr); |
+ expect(scanner.line, equals(1)); |
+ expect(scanner.column, equals(4)); |
+ |
+ scanner.scanChar($lf); |
+ expect(scanner.line, equals(2)); |
+ expect(scanner.column, equals(0)); |
+ }); |
+ }); |
+ |
group("position=", () { |
test("forward through newlines sets the line and column", () { |
scanner.position = 10; // "foo\nbar\r\nb" |