testing k complementary pairs algorithm with junit

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

The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path

String Ordered Permutation Algorithm Problem

setting JAVA_HOME on mac osx

hello world weblogic – hello world tutorial on weblogic

Passing composite object parameter to jersey in Restful Java web

J2EE Maven Eclipse Hello World Tutorial Part Two

Leave a Reply

Your email address will not be published. Required fields are marked *