01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.harmony.pack200.tests;
18:
19: import junit.framework.TestCase;
20: import org.apache.harmony.pack200.IcTuple;
21:
22: public class ICTupleTest extends TestCase {
23:
24: public void testPredictedClassTupleParsing() {
25: IcTuple tuple = new IcTuple();
26: tuple.C = "orw/SimpleHelloWorld$SimpleHelloWorldInner";
27: tuple.C2 = null;
28: tuple.F = 0;
29: tuple.N = null;
30: assertEquals("SimpleHelloWorldInner", tuple.simpleClassName());
31: assertEquals("orw/SimpleHelloWorld", tuple.outerClassString());
32:
33: tuple = new IcTuple();
34: tuple.C = "java/util/AbstractList$2$Local";
35: tuple.C2 = null;
36: tuple.F = 0;
37: tuple.N = null;
38: assertEquals("Local", tuple.simpleClassName());
39: assertEquals("java/util/AbstractList$2", tuple
40: .outerClassString());
41:
42: tuple = new IcTuple();
43: tuple.C = "java/util/AbstractList#2#Local";
44: tuple.C2 = null;
45: tuple.F = 0;
46: tuple.N = null;
47: assertEquals("Local", tuple.simpleClassName());
48: assertEquals("java/util/AbstractList$2", tuple
49: .outerClassString());
50:
51: tuple = new IcTuple();
52: tuple.C = "java/util/AbstractList$1";
53: tuple.C2 = null;
54: tuple.F = 0;
55: tuple.N = null;
56: assertEquals("1", tuple.simpleClassName());
57: assertEquals("java/util/AbstractList", tuple.outerClassString());
58: }
59:
60: public void testExplicitClassTupleParsing() {
61: IcTuple tuple = new IcTuple();
62: tuple.C = "Foo$$2$Local";
63: tuple.C2 = null;
64: tuple.F = IcTuple.NESTED_CLASS_FLAG;
65: tuple.N = "$2$Local";
66: assertEquals("$2$Local", tuple.simpleClassName());
67: assertEquals(null, tuple.outerClassString());
68:
69: tuple = new IcTuple();
70: tuple.C = "Red$Herring";
71: tuple.C2 = "Red$Herring";
72: tuple.F = IcTuple.NESTED_CLASS_FLAG;
73: tuple.N = null;
74: assertEquals(null, tuple.simpleClassName());
75: assertEquals("Red$Herring", tuple.outerClassString());
76:
77: tuple = new IcTuple();
78: tuple.C = "X$1$Q";
79: tuple.C2 = "X$1";
80: tuple.F = IcTuple.NESTED_CLASS_FLAG;
81: tuple.N = "Q";
82: assertEquals("Q", tuple.simpleClassName());
83: assertEquals("X$1", tuple.outerClassString());
84: }
85: }
|