package MedianOfTwoSortedArrays;

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

import static org.assertj.core.api.Assertions.assertThat;


public class MedianOfTwoSortedArraysSolutionTest {

    private MedianOfTwoSortedArraysSolution medianOfTwoSortedArraysSolution;

    @Before
    public void setUp() {
        medianOfTwoSortedArraysSolution = new MedianOfTwoSortedArraysSolution();
    }

    @Test
    public void findMedianSortedArrays_1() {
        int[] nums1 = {1, 3};
        int[] nums2 = {2};

        double result = medianOfTwoSortedArraysSolution.findMedianSortedArrays(nums1, nums2);

        assertThat(result).isEqualTo(2);
    }

    @Test
    public void findMedianSortedArrays_2() {
        int[] nums1 = {1, 2};
        int[] nums2 = {3, 4};

        double result = medianOfTwoSortedArraysSolution.findMedianSortedArrays(nums1, nums2);

        assertThat(result).isEqualTo(2.5);
    }

    @Test
    public void findMedianSortedArrays_Has_Same_Number() {
        int[] nums1 = {2, 2};
        int[] nums2 = {2, 4};

        double result = medianOfTwoSortedArraysSolution.findMedianSortedArrays(nums1, nums2);

        assertThat(result).isEqualTo(2);
    }
}