Last active
August 29, 2015 14:23
-
-
Save occho/32583fc23183e2aca6fa to your computer and use it in GitHub Desktop.
Variable arity method tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 [] | |
1 null | |
1 [null, null] | |
1 [2] | |
1 [2, 3] | |
1 [null] | |
1 [null, null] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lang; | |
import org.junit.Test; | |
import java.util.Arrays; | |
/** | |
* @author Tomoyuki Saito | |
*/ | |
public class JavaTest { | |
private void func(String arg, String... arguments) { | |
System.out.printf("%s %s%n", arg, Arrays.toString(arguments)); | |
} | |
@Test | |
public void testVariableArityMethod() { | |
func("1"); | |
func("1", null); | |
func("1", null, null); | |
func("1", "2"); | |
func("1", "2", "3"); | |
func("1", new String[]{null}); | |
func("1", new String[]{null, null}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment