| Index: pkg/analysis_server/test/index/store/collection_test.dart
|
| diff --git a/pkg/analysis_server/test/index/store/collection_test.dart b/pkg/analysis_server/test/index/store/collection_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..382510bd81b0eaa041ae9fc7be9e20177ffabfef
|
| --- /dev/null
|
| +++ b/pkg/analysis_server/test/index/store/collection_test.dart
|
| @@ -0,0 +1,83 @@
|
| +// Copyright (c) 2014, 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.
|
| +
|
| +library test.index.store.collection;
|
| +
|
| +import 'package:analysis_server/src/index/store/collection.dart';
|
| +import 'package:unittest/unittest.dart';
|
| +
|
| +import '../../reflective_tests.dart';
|
| +
|
| +
|
| +main() {
|
| + groupSep = ' | ';
|
| + group('IntArrayToIntMap', () {
|
| + runReflectiveTests(_IntArrayToIntMapTest);
|
| + });
|
| + group('IntToIntSetMap', () {
|
| + runReflectiveTests(_IntToIntSetMapTest);
|
| + });
|
| +}
|
| +
|
| +
|
| +@ReflectiveTestCase()
|
| +class _IntArrayToIntMapTest {
|
| + IntArrayToIntMap map = new IntArrayToIntMap();
|
| +
|
| + void test_put_get() {
|
| + map[<int>[1, 2, 3]] = 1;
|
| + map[<int>[2, 3, 4, 5]] = 2;
|
| + expect(map[<int>[0]], isNull);
|
| + expect(map[<int>[1, 2, 3]], 1);
|
| + expect(map[<int>[2, 3, 4, 5]], 2);
|
| + }
|
| +}
|
| +
|
| +
|
| +@ReflectiveTestCase()
|
| +class _IntToIntSetMapTest {
|
| + IntToIntSetMap map = new IntToIntSetMap();
|
| +
|
| + void test_add_duplicate() {
|
| + map.add(1, 0);
|
| + map.add(1, 0);
|
| + List<int> set = map.get(1);
|
| + expect(set, hasLength(1));
|
| + }
|
| +
|
| + void test_clear() {
|
| + map.add(1, 10);
|
| + map.add(2, 20);
|
| + expect(map.length, 2);
|
| + map.clear();
|
| + expect(map.length, 0);
|
| + }
|
| +
|
| + void test_get() {
|
| + map.add(1, 10);
|
| + map.add(1, 11);
|
| + map.add(1, 12);
|
| + map.add(2, 20);
|
| + map.add(2, 21);
|
| + expect(map.get(1), unorderedEquals([10, 11, 12]));
|
| + expect(map.get(2), unorderedEquals([20, 21]));
|
| + }
|
| +
|
| + void test_get_no() {
|
| + expect(map.get(3), []);
|
| + }
|
| +
|
| + void test_length() {
|
| + expect(map.length, 0);
|
| + map.add(1, 10);
|
| + expect(map.length, 1);
|
| + map.add(1, 11);
|
| + map.add(1, 12);
|
| + expect(map.length, 1);
|
| + map.add(2, 20);
|
| + expect(map.length, 2);
|
| + map.add(2, 21);
|
| + expect(map.length, 2);
|
| + }
|
| +}
|
|
|