01: /*
02: * FindBugs - Find Bugs in Java programs
03: * Copyright (C) 2006, University of Maryland
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
19:
20: package edu.umd.cs.findbugs.ba.generic;
21:
22: import java.util.Iterator;
23:
24: import junit.framework.TestCase;
25:
26: /**
27: * @author Nat Ayewah
28: */
29: public class TestGenericSignatureParser extends TestCase {
30:
31: public void processTest(String genericSignature,
32: String... substrings) {
33: GenericSignatureParser parser = new GenericSignatureParser(
34: genericSignature);
35: Iterator<String> iter = parser.parameterSignatureIterator();
36:
37: for (String s : substrings) {
38: assertTrue(iter.hasNext());
39: assertEquals(s, iter.next());
40: }
41: assertFalse(iter.hasNext());
42: }
43:
44: public void testSignatures() {
45: processTest("(Ljava/lang/Comparable;)V",
46: "Ljava/lang/Comparable;");
47:
48: processTest(
49: "(Ljava/lang/Comparable;TE;**[Ljava/lang/Comparable;)V",
50: "Ljava/lang/Comparable;", "TE;", "*", "*",
51: "[Ljava/lang/Comparable;");
52:
53: processTest("(TE;*+[Ljava/lang/Comparable;-TV;)V", "TE;", "*",
54: "+[Ljava/lang/Comparable;", "-TV;");
55: }
56: }
|