Skip to content

Commit 573f089

Browse files
committed
Quality: add unit tests for method calls with "var args" and exactly one argument
- the "int[]..." case causes a problem in J2S. Reported by Bob Hanson via mail
1 parent 758449d commit 573f089

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tests/net.sf.j2s.test.junit/src/net/sf/j2s/test/junit/basic/VarArgsTest.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ public void testVarArgsEmpty() {
2929
assertEquals("ints: ", s);
3030
}
3131

32+
/**
33+
* Call a varArgs method with exactly one argument.
34+
*/
35+
public void testVarArgsExactlyOneArg() {
36+
String s = new CVarArgs().fVarArgsInt(4);
37+
assertEquals("ints: 4 ", s);
38+
}
39+
3240
/**
3341
* Call a varArgs method with some arguments.
3442
*/
@@ -55,7 +63,15 @@ public void testStringPlusVarArgsEmpty() {
5563
}
5664

5765
/**
58-
* Call a varArgs method with a mandatory arguments and no optional arguments.
66+
* Call a varArgs method with a mandatory arguments and exactly one optional arguments.
67+
*/
68+
public void testStringPlusVarArgsExactlyOneArg() {
69+
String s = new CVarArgs().fStringVarArgsInt("demo ", 4);
70+
assertEquals("demo 4 ", s);
71+
}
72+
73+
/**
74+
* Call a varArgs method with a mandatory arguments and some optional arguments.
5975
*/
6076
public void testStringPlusVarArgsNotEmpty() {
6177
String s = new CVarArgs().fStringVarArgsInt("demo ", 4, 7);
@@ -78,6 +94,14 @@ public void testIntArrVarArgsNotEmpty() {
7894
assertEquals("intss [3 5 7 ] [2 4 ] ", s);
7995
}
8096

97+
/**
98+
* Call a varArgs method of array type (here int[]) with exactly one argument.
99+
*/
100+
public void testIntArrVarArgsExactlyOneArg() {
101+
String s = new CVarArgs().fIntArr(new int[]{2,4});
102+
assertEquals("intss [2 4 ] ", s);
103+
}
104+
81105
/**
82106
* Call a varArgs method of array type (here int[]) with some arguments (via array).
83107
*/

0 commit comments

Comments
 (0)