| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.index.split.store; | 5 library test.index.split.store; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analysis_server/src/index/split_store.dart'; | 10 import 'package:analysis_server/src/index/split_store.dart'; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 fail('Expected to find Location' | 64 fail('Expected to find Location' |
| 65 '(element=$element, offset=$offset, length=$length)'); | 65 '(element=$element, offset=$offset, length=$length)'); |
| 66 } | 66 } |
| 67 | 67 |
| 68 | 68 |
| 69 @ReflectiveTestCase() | 69 @ReflectiveTestCase() |
| 70 class _ContextCodecTest { | 70 class _ContextCodecTest { |
| 71 ContextCodec codec = new ContextCodec(); | 71 ContextCodec codec = new ContextCodec(); |
| 72 | 72 |
| 73 void test_all() { | 73 void test_encode_decode() { |
| 74 AnalysisContext contextA = new _MockAnalysisContext('contextA'); | 74 AnalysisContext contextA = new _MockAnalysisContext('contextA'); |
| 75 AnalysisContext contextB = new _MockAnalysisContext('contextB'); | 75 AnalysisContext contextB = new _MockAnalysisContext('contextB'); |
| 76 int idA = codec.encode(contextA); | 76 int idA = codec.encode(contextA); |
| 77 int idB = codec.encode(contextB); | 77 int idB = codec.encode(contextB); |
| 78 expect(idA, codec.encode(contextA)); |
| 79 expect(idB, codec.encode(contextB)); |
| 78 expect(codec.decode(idA), contextA); | 80 expect(codec.decode(idA), contextA); |
| 79 expect(codec.decode(idB), contextB); | 81 expect(codec.decode(idB), contextB); |
| 80 } | 82 } |
| 83 |
| 84 void test_remove() { |
| 85 // encode |
| 86 { |
| 87 AnalysisContext context = new _MockAnalysisContext('context'); |
| 88 // encode |
| 89 int id = codec.encode(context); |
| 90 expect(id, 0); |
| 91 expect(codec.decode(id), context); |
| 92 // remove |
| 93 codec.remove(context); |
| 94 expect(codec.decode(id), isNull); |
| 95 } |
| 96 // encode again |
| 97 { |
| 98 AnalysisContext context = new _MockAnalysisContext('context'); |
| 99 // encode |
| 100 int id = codec.encode(context); |
| 101 expect(id, 1); |
| 102 expect(codec.decode(id), context); |
| 103 } |
| 104 } |
| 81 } | 105 } |
| 82 | 106 |
| 83 | 107 |
| 84 @ReflectiveTestCase() | 108 @ReflectiveTestCase() |
| 85 class _ElementCodecTest { | 109 class _ElementCodecTest { |
| 86 ElementCodec codec; | 110 ElementCodec codec; |
| 87 AnalysisContext context = new _MockAnalysisContext('context'); | 111 AnalysisContext context = new _MockAnalysisContext('context'); |
| 88 StringCodec stringCodec = new StringCodec(); | 112 StringCodec stringCodec = new StringCodec(); |
| 89 | 113 |
| 90 void setUp() { | 114 void setUp() { |
| (...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 class _StringCodecTest { | 1356 class _StringCodecTest { |
| 1333 StringCodec codec = new StringCodec(); | 1357 StringCodec codec = new StringCodec(); |
| 1334 | 1358 |
| 1335 void test_all() { | 1359 void test_all() { |
| 1336 int idA = codec.encode('aaa'); | 1360 int idA = codec.encode('aaa'); |
| 1337 int idB = codec.encode('bbb'); | 1361 int idB = codec.encode('bbb'); |
| 1338 expect(codec.decode(idA), 'aaa'); | 1362 expect(codec.decode(idA), 'aaa'); |
| 1339 expect(codec.decode(idB), 'bbb'); | 1363 expect(codec.decode(idB), 'bbb'); |
| 1340 } | 1364 } |
| 1341 } | 1365 } |
| OLD | NEW |