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

Unified Diff: packages/source_span/test/utils_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « packages/source_span/test/span_test.dart ('k') | packages/stack_trace/.gitignore » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/source_span/test/utils_test.dart
diff --git a/packages/source_span/test/utils_test.dart b/packages/source_span/test/utils_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5d973f58acf29578617cec0f40529602ecef0e1c
--- /dev/null
+++ b/packages/source_span/test/utils_test.dart
@@ -0,0 +1,55 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS 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 'package:test/test.dart';
+import 'package:source_span/src/utils.dart';
+
+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);
+ });
+
+ test('found on the first line', () {
+ var context = '0\n2\n45\n';
+ var index = findLineStart(context, '0', 0);
+ expect(index, 0);
+ });
+
+ test('not found', () {
+ var context = '0\n2\n45\n';
+ var index = findLineStart(context, '0', 1);
+ expect(index, isNull);
+ });
+ });
+}
+
+_linearSearch(list, predicate) {
+ if (list.length == 0) return -1;
+ for (int i = 0; i < list.length; i++) {
+ if (predicate(list[i])) return i;
+ }
+ return list.length;
+}
« no previous file with comments | « packages/source_span/test/span_test.dart ('k') | packages/stack_trace/.gitignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698