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

Unified Diff: pkg/string_scanner/test/string_scanner_test.dart

Issue 689513002: Rewrite the pkg/yaml parser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years, 1 month 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
« no previous file with comments | « pkg/string_scanner/pubspec.yaml ('k') | pkg/yaml/CHANGELOG.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/string_scanner/test/string_scanner_test.dart
diff --git a/pkg/string_scanner/test/string_scanner_test.dart b/pkg/string_scanner/test/string_scanner_test.dart
index 6144bf9c007c3dcc30b09684d9899df46c8ddf68..fcd904aba17d6f652e4ba9610b26d90102ef9b4d 100644
--- a/pkg/string_scanner/test/string_scanner_test.dart
+++ b/pkg/string_scanner/test/string_scanner_test.dart
@@ -61,6 +61,10 @@ void main() {
expect(scanner.position, equals(0));
});
+ test("substring returns the empty string", () {
+ expect(scanner.substring(0), isEmpty);
+ });
+
test('setting position to 1 throws an ArgumentError', () {
expect(() {
scanner.position = 1;
@@ -165,6 +169,18 @@ void main() {
expect(scanner.rest, equals('foo bar'));
});
+ test("substring from the beginning returns the empty string", () {
+ expect(scanner.substring(0), isEmpty);
+ });
+
+ test("substring with a custom end returns the substring", () {
+ expect(scanner.substring(0, 3), equals('foo'));
+ });
+
+ test("substring with the string length returns the whole string", () {
+ expect(scanner.substring(0, 7), equals('foo bar'));
+ });
+
test('setting position to 1 moves the cursor forward', () {
scanner.position = 1;
expect(scanner.position, equals(1));
@@ -260,6 +276,18 @@ void main() {
expect(scanner.position, equals(7));
});
+ test("substring from the beginning returns the whole string", () {
+ expect(scanner.substring(0), equals('foo bar'));
+ });
+
+ test("substring with a custom start returns a substring from there", () {
+ expect(scanner.substring(4), equals('bar'));
+ });
+
+ test("substring with a custom start and end returns that substring", () {
+ expect(scanner.substring(3, 5), equals(' b'));
+ });
+
test('setting position to 1 moves the cursor backward', () {
scanner.position = 1;
expect(scanner.position, equals(1));
« no previous file with comments | « pkg/string_scanner/pubspec.yaml ('k') | pkg/yaml/CHANGELOG.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698