Skip to content

Instantly share code, notes, and snippets.

@occho
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save occho/32583fc23183e2aca6fa to your computer and use it in GitHub Desktop.
Save occho/32583fc23183e2aca6fa to your computer and use it in GitHub Desktop.
Variable arity method tests
1 []
1 null
1 [null, null]
1 [2]
1 [2, 3]
1 [null]
1 [null, null]
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