01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10: package de.uka.ilkd.key.java;
11:
12: import java.util.HashMap;
13:
14: import junit.framework.TestCase;
15: import de.uka.ilkd.key.java.statement.EmptyStatement;
16: import de.uka.ilkd.key.util.Debug;
17:
18: public class TestKeYRecoderMapping extends TestCase {
19:
20: private HashMap map, revmap;
21: private recoder.java.ProgramElement rp, rp2;
22: private ProgramElement kp;
23: private recoder.ModelElement rm, rm2;
24: private ModelElement km;
25: private KeYRecoderMapping mapping;
26:
27: public TestKeYRecoderMapping(String name) {
28: super (name);
29: }
30:
31: public void setUp() {
32: map = new HashMap();
33: revmap = new HashMap();
34: rp = new recoder.java.declaration.ClassDeclaration();
35: kp = (ProgramElement) (new EmptyStatement());
36: rm = new recoder.java.statement.Case();
37: km = (ModelElement) (new de.uka.ilkd.key.java.abstraction.Package(
38: "Packet"));
39: rp2 = new recoder.java.declaration.ClassDeclaration();
40: rm2 = new recoder.java.statement.Case();
41: map.put(rp, kp);
42: revmap.put(kp, rp);
43: map.put(rm, km);
44: revmap.put(km, rm);
45: mapping = new KeYRecoderMapping(map, revmap, null, false);
46: }
47:
48: public void testtoKeY() {
49: Debug.assertTrue(kp.equals(mapping.toKeY(rp)),
50: "Fehler[1] in toKeY(recoder.java.ProgramElement)");
51: Debug.assertTrue(null == mapping.toKeY(rp2),
52: "Fehler[2] in toKeY(recoder.java.ProgramElement)");
53: Debug.assertTrue(km.equals(mapping.toKeY(rm)),
54: "Fehler[3] in toKeY(recoder.ModelElement)");
55: Debug.assertTrue(null == mapping.toKeY(rm2),
56: "Fehler[4] in toKeY(recoder.ModelElement)");
57: }
58:
59: public void testtoRecoder() {
60: Debug
61: .assertTrue(rp.equals(mapping.toRecoder(kp)),
62: "Fehler[1] in toRecoder(de.uka.ilkd.key.java.ProgramElement)");
63: // Debug.assertTrue(null==mapping.toRecoder(kp2),"Fehler[2] in toRecoder(de.uka.ilkd.key.java.ProgramElement)");
64: Debug
65: .assertTrue(rm.equals(mapping.toRecoder(km)),
66: "Fehler[2] in toRecoder(de.uka.ilkd.key.java.ModelElement)");
67: // Debug.assertTrue(null==mapping.toRecoder(km2),"Fehler[4] in toRecoder(de.uka.ilkd.key.java.ModelElement)");
68: }
69:
70: }
|