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

Unified Diff: test/utils_test.dart

Issue 1041163005: Support multiple occurrences of text in context (Closed) Base URL: git@github.com:dart-lang/source_span.git@master
Patch Set: Created 5 years, 9 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
« lib/src/utils.dart ('K') | « test/span_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/utils_test.dart
diff --git a/test/utils_test.dart b/test/utils_test.dart
index a9988470938f39bd961ab14cf3aae8942dbd0567..1e399acf6d919abb7b812f5003520dea1212d0d5 100644
--- a/test/utils_test.dart
+++ b/test/utils_test.dart
@@ -39,6 +39,33 @@ main() {
}
});
});
+
+ group('find line start', () {
+ test('skip entries in wrong column', () {
+ var context = '0_bb\n1_bbb\n2b____\n3bbb\n';
+ var index = findLineStart(context, 'b', 1);
+ expect(index, 11);
+ expect(context.substring(index - 1, index + 3), '\n2b_');
+ });
+
+ test('end of line column for empty text', () {
+ var context = '0123\n56789\nabcdefgh\n';
+ var index = findLineStart(context, '', 5);
+ expect(index, 5);
+ expect(context[index], '5');
+ });
+
+ test('column at the end of the file for empty text', () {
+ var context = '0\n2\n45\n';
+ var index = findLineStart(context, '', 2);
+ expect(index, 4);
+ expect(context[index], '4');
+
+ context = '0\n2\n45';
+ index = findLineStart(context, '', 2);
+ expect(index, 4);
+ });
+ });
}
nweiz 2015/03/31 19:22:10 Can you also add a test for printing a message whe
Siggi Cherem (dart-lang) 2015/03/31 19:51:21 Done.
_linearSearch(list, predicate) {
« lib/src/utils.dart ('K') | « test/span_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698