Chromium Code Reviews| Index: pkg/analysis_server/test/services/index/indexable_file_test.dart |
| diff --git a/pkg/analysis_server/test/services/index/indexable_file_test.dart b/pkg/analysis_server/test/services/index/indexable_file_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..23c2c841c2fb7084073480c398a52d8528c20827 |
| --- /dev/null |
| +++ b/pkg/analysis_server/test/services/index/indexable_file_test.dart |
| @@ -0,0 +1,58 @@ |
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
|
Brian Wilkerson
2015/10/18 15:41:07
"2014" --> "2015"
|
| +// 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. |
| + |
| +library test.services.index.indexable_file; |
| + |
| +import 'package:analysis_server/src/services/index/indexable_file.dart'; |
| +import 'package:analysis_server/src/services/index/store/codec.dart'; |
| +import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| +import 'package:unittest/unittest.dart'; |
| + |
| +import '../../utils.dart'; |
| + |
| +main() { |
| + initializeTestEnvironment(); |
| + defineReflectiveTests(IndexableFileKindTest); |
| + defineReflectiveTests(IndexableFileTest); |
| +} |
| + |
| +@reflectiveTest |
| +class IndexableFileKindTest { |
| + void test_decode() { |
| + IndexableFile object = |
| + IndexableFileKind.INSTANCE.decode(null, '/a.dart', -1); |
| + expect(object.path, '/a.dart'); |
| + } |
| + |
| + void test_encodeHash() { |
| + StringCodec stringCodec = new StringCodec(); |
| + String path = '/a/bb/ccc.dart'; |
| + int hash1 = IndexableFileKind.INSTANCE |
| + .encodeHash(stringCodec.encode, new IndexableFile(path)); |
| + int hash2 = IndexableFileKind.INSTANCE |
| + .encodeHash(stringCodec.encode, new IndexableFile(path)); |
| + expect(hash2, hash1); |
| + } |
| +} |
| + |
| +@reflectiveTest |
| +class IndexableFileTest { |
| + void test_equals() { |
| + IndexableFile a = new IndexableFile('/a.dart'); |
| + IndexableFile a2 = new IndexableFile('/a.dart'); |
| + IndexableFile b = new IndexableFile('/b.dart'); |
| + expect(a == a, isTrue); |
| + expect(a == a2, isTrue); |
| + expect(a == b, isFalse); |
| + } |
| + |
| + void test_getters() { |
| + String path = '/a/bb/ccc.dart'; |
| + IndexableFile indexable = new IndexableFile(path); |
| + expect(indexable.kind, IndexableFileKind.INSTANCE); |
| + expect(indexable.filePath, path); |
| + expect(indexable.offset, -1); |
| + expect(indexable.toString(), path); |
| + } |
| +} |