TwoSumsTest.java 1.35 KB
Newer Older
Younis's avatar
Younis committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import static org.junit.Assert.*;
import org.junit.Test;

public class TwoSumsTest {

    @Test
    public void testStudentOneSolution() {
        int[] nums = { 2, 7, 11, 15 };
        int target = 18;
        int[][] expectedPairs = {{2, 16}, {7, 11}};
        int[][] expectedIndices = {{0, 3}, {1, 2}};

        // Replace StudentOneSolution with the actual name of the class submitted by the first student
        int[][] actualPairs = StudentOneSolution.findPairs(nums, target);
        int[][] actualIndices = StudentOneSolution.findIndices(nums, target);

        assertArrayEquals(expectedPairs, actualPairs);
        assertArrayEquals(expectedIndices, actualIndices);
    }

    @Test
    public void testStudentTwoSolution() {
        int[] nums = { 2, 7, 11, 15 };
        int target = 18;
        int[][] expectedPairs = {{2, 16}, {7, 11}};
        int[][] expectedIndices = {{0, 3}, {1, 2}};

        // Replace StudentTwoSolution with the actual name of the class submitted by the second student
        int[][] actualPairs = StudentTwoSolution.findPairs(nums, target);
        int[][] actualIndices = StudentTwoSolution.findIndices(nums, target);

        assertArrayEquals(expectedPairs, actualPairs);
        assertArrayEquals(expectedIndices, actualIndices);
    }

    @Test
    public void testStudentThreeSolution() {
        int[] nums = { 2, 7, 11, 15 };