testing k complementary pairs algorithm with junit

This is the test class for the java solution of the k-complementary problem listed here

package algorithm;

import static org.junit.Assert.assertArrayEquals;

import org.junit.Before;
import org.junit.Test;

 * Testing KComplementary algorithm
 * @author Kaleb Woldearegay
public class KComplementaryTest {
	private KComplementary kComplementary;
	public void initiate() {
		this.kComplementary = new KComplementary();
	public void test1() {
		Integer[][] expectedResult = new Integer[][]{{1,9},{5,5},{9,1}};
		int[] test = new int[]{1,5,9};
		assertArrayEquals(this.kComplementary.getKComplementaryPairs(10,  test), expectedResult);
	public void test2() {
		Integer[][] expectedResult = new Integer[][]{{5,7},{7,5}};
		int[] test = new int[]{3,5,7};
		assertArrayEquals(this.kComplementary.getKComplementaryPairs(12,  test), expectedResult);
	public void test3() {
		Integer[][] expectedResult = new Integer[][]{{-1,1},{0,0},{1,-1}};
		int[] test = new int[]{5,-1,0,-2,3, 1};
		assertArrayEquals(this.kComplementary.getKComplementaryPairs(0,  test), expectedResult);


See more algorithm solutions by clicking Here