| Index: test/string_scanner_test.dart
|
| diff --git a/test/string_scanner_test.dart b/test/string_scanner_test.dart
|
| index 10e622a82a3cc2268eaf913e7aec260799e10f8f..0b4d4824f0bf2bf64cb85f4799d4cdceb004fc07 100644
|
| --- a/test/string_scanner_test.dart
|
| +++ b/test/string_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';
|
|
|
| @@ -41,6 +42,18 @@ void main() {
|
| expect(scanner.position, equals(0));
|
| });
|
|
|
| + test("scanChar returns false and doesn't change the state", () {
|
| + expect(scanner.scanChar($f), isFalse);
|
| + expect(scanner.lastMatch, isNull);
|
| + expect(scanner.position, equals(0));
|
| + });
|
| +
|
| + test("expectChar fails and doesn't change the state", () {
|
| + expect(() => scanner.expectChar($f), throwsFormatException);
|
| + expect(scanner.lastMatch, isNull);
|
| + expect(scanner.position, equals(0));
|
| + });
|
| +
|
| test("scan returns false and doesn't change the state", () {
|
| expect(scanner.scan(new RegExp('.')), isFalse);
|
| expect(scanner.lastMatch, isNull);
|
| @@ -117,6 +130,30 @@ void main() {
|
| expect(scanner.position, equals(0));
|
| });
|
|
|
| + test("a matching scanChar returns true moves forward", () {
|
| + expect(scanner.scanChar($f), isTrue);
|
| + expect(scanner.lastMatch, isNull);
|
| + expect(scanner.position, equals(1));
|
| + });
|
| +
|
| + test("a non-matching scanChar returns false and does nothing", () {
|
| + expect(scanner.scanChar($x), isFalse);
|
| + expect(scanner.lastMatch, isNull);
|
| + expect(scanner.position, equals(0));
|
| + });
|
| +
|
| + test("a matching expectChar moves forward", () {
|
| + scanner.expectChar($f);
|
| + expect(scanner.lastMatch, isNull);
|
| + expect(scanner.position, equals(1));
|
| + });
|
| +
|
| + test("a non-matching expectChar fails", () {
|
| + expect(() => scanner.expectChar($x), throwsFormatException);
|
| + expect(scanner.lastMatch, isNull);
|
| + expect(scanner.position, equals(0));
|
| + });
|
| +
|
| test("a matching scan returns true and changes the state", () {
|
| expect(scanner.scan(new RegExp('f(..)')), isTrue);
|
| expect(scanner.lastMatch[1], equals('oo'));
|
| @@ -256,6 +293,18 @@ void main() {
|
| expect(scanner.position, equals(7));
|
| });
|
|
|
| + test("scanChar returns false and doesn't change the state", () {
|
| + expect(scanner.scanChar($f), isFalse);
|
| + expect(scanner.lastMatch, isNotNull);
|
| + expect(scanner.position, equals(7));
|
| + });
|
| +
|
| + test("expectChar fails and doesn't change the state", () {
|
| + expect(() => scanner.expectChar($f), throwsFormatException);
|
| + expect(scanner.lastMatch, isNotNull);
|
| + expect(scanner.position, equals(7));
|
| + });
|
| +
|
| test("scan returns false and sets lastMatch to null", () {
|
| expect(scanner.scan(new RegExp('.')), isFalse);
|
| expect(scanner.lastMatch, isNull);
|
|
|