01: /*
02: * FindBugs - Find Bugs in Java programs
03: * Copyright (C) 2005, 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.visitclass;
21:
22: import junit.framework.TestCase;
23:
24: /**
25: * @author pugh
26: */
27:
28: public class GetNumberArgumentsTest extends TestCase {
29:
30: static String[] simpleTypes = "I J B C D F I S Z".split(" ");
31:
32: public void testSimpleWithVoidReturnType() {
33: for (String s : simpleTypes)
34: assertEquals(1, PreorderVisitor.getNumberArguments("(" + s
35: + ")V"));
36: }
37:
38: public void testSimpleWithVoidIntegerType() {
39: for (String s : simpleTypes)
40: assertEquals(1, PreorderVisitor.getNumberArguments("(" + s
41: + ")I"));
42: }
43:
44: public void testArrays() {
45: for (String s : simpleTypes) {
46: assertEquals(1, PreorderVisitor.getNumberArguments("([" + s
47: + ")V"));
48: assertEquals(1, PreorderVisitor.getNumberArguments("([["
49: + s + ")I"));
50: }
51: }
52:
53: public void testStringArguments() {
54: for (String s : simpleTypes) {
55: assertEquals(2, PreorderVisitor
56: .getNumberArguments("([Ljava/lang/String;" + s
57: + ")V"));
58: assertEquals(2, PreorderVisitor.getNumberArguments("([["
59: + s + "Ljava/lang/String;)I"));
60: }
61: }
62:
63: public void testSimpleObjectArgument() {
64: assertEquals(
65: 1,
66: PreorderVisitor
67: .getNumberArguments("(Ledu/umd/cs/findbugs/ba/ClassContext;)V"));
68: }
69:
70: }
|