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

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/index/file/ContextCodecTest.java

Issue 347133002: Explicitly remove AnalysisContext from ContextCodec. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix for IDs generation Created 6 years, 6 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
Index: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/index/file/ContextCodecTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/index/file/ContextCodecTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/index/file/ContextCodecTest.java
index b31ed361ccffc9ac4cf8be889855ee0c0f1f665a..b0e94462494350695c77bc30f782dc32c43d76af 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/index/file/ContextCodecTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/index/file/ContextCodecTest.java
@@ -22,12 +22,34 @@ import static org.mockito.Mockito.mock;
public class ContextCodecTest extends TestCase {
private ContextCodec codec = new ContextCodec();
- public void test_all() throws Exception {
+ public void test_encode_decode() throws Exception {
AnalysisContext contextA = mock(AnalysisContext.class);
AnalysisContext contextB = mock(AnalysisContext.class);
int idA = codec.encode(contextA);
int idB = codec.encode(contextB);
+ assertEquals(idA, codec.encode(contextA));
+ assertEquals(idB, codec.encode(contextB));
assertSame(contextA, codec.decode(idA));
assertSame(contextB, codec.decode(idB));
}
+
+ public void test_remove() throws Exception {
+ // encode
+ {
+ AnalysisContext context = mock(AnalysisContext.class);
+ int id = codec.encode(context);
+ assertEquals(0, id);
+ assertSame(context, codec.decode(id));
+ // remove
+ codec.removeContext(context);
+ assertNull(codec.decode(id));
+ }
+ // encode again
+ {
+ AnalysisContext context = mock(AnalysisContext.class);
+ int id = codec.encode(context);
+ assertEquals(1, id);
+ assertSame(context, codec.decode(id));
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698