<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">import static org.junit.Assert.*;

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


/**
 * implement method:
 * public static int[] Lab03.commonElements(int[] a,int b[])
 * which return array with values set(a) \cap set(b)
 * note: you can assume that arrays a and b are non-descending
 */
public class Lab03CommonElementsTest {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testSimple() {
		assertArrayEquals(
				new int[]{2}, 
				run(new int[]{1,2,3}, new int[]{0,2,4})
		);
	}

	@Test
	public void testEmpty() {
		assertArrayEquals(
				new int[]{}, 
				run(new int[]{1,2,3}, new int[]{})
		);
		assertArrayEquals(
				new int[]{}, 
				run(new int[]{}, new int[]{1,2,3})
		);
	}

	@Test
	public void testEquals() {
		assertArrayEquals(
				new int[]{1,2,3}, 
				run(new int[]{1,2,3}, new int[]{1,2,3})
		);
	}

	@Test
	public void testDuplicates() {
		assertArrayEquals(
				new int[]{2}, 
				run(new int[]{1,2,2,2,4}, new int[]{2,2,3,3})
		);
	}
	
	
	int[] run(int[] a, int[] b) {
		return Lab03.commonElements(a, b);
	}

}
</pre></body></html>