//import junit.framework.Assert;
import org.junit.Test;
import org.junit.Assert ;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.*;

public class ArrazTest {
    Arraz arraz = new Arraz();

    @Test
    public void testSumOfValues() {
        int[] a = {4, 5, 102, 6, -7, 12, -32, 92, 8};
        int expected = 190;
        int actual = arraz.sumOfValues(a);
        Assert.assertEquals(expected, actual);

    }

    @Test
    public void testSumOfValues1() {
        int[] a = {1, 2, 3, 4, 4, 5, 6, 7};
        int expected = 32;
        int actual = arraz.sumOfValues(a);
        Assert.assertEquals(expected, actual);

    }

    @Test

    public void testSumOfDoubleValues() {
        double[] a = {1.0, 0.5, 3.6, 38.4, 17.3, 62.0, 9.0, 3.375, 0, 3.14159};
        double expected = 138.31659000000002;

        double actual = arraz.sumDoublesOfArra(a);
        Assert.assertEquals(expected, actual);

    }

    @Test

    public void testSumOfDoubleValues1() {
        double[] a = {1.2, 2.3, 3.4, 4.5, 4.6};
        double expected = 27.6;

        double actual = arraz.sumDoublesOfArra(a);
        Assert.assertEquals(expected, actual);

    }

    @Test

    public void testavgOfArray() {
        int[] a = {4, 5, 102, 6, -7, 12, -32, 92, 8};
        int expected = 21;
        int actual = arraz.averageOfArray(a);
        Assert.assertEquals(expected, actual);

    }

    @Test

    public void testavgfDoubleValues() {
        double[] a = {1.0, 0.5, 3.6, 38.4, 17.3, 62.0, 9.0, 3.375, 0, 3.14159};
        double expected = 13.831659;
        double actual = arraz.doubleaverageOfArray(a);
        Assert.assertEquals(expected, actual);

    }

    @Test
    public void testcontains() {
        int[] a = {4, 5, 102, 6, -7, 12, -32, 92, 8};
        int value = 5;
        boolean expected = true;
        boolean actual = arraz.containsValue(a, value);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testReverse() {
        Integer[] a = {4, 5, 102, 6, -7, 12, -32, 92, 8};
        Integer[] expected = {8, 92, -32, 12, -7, 6, 102, 5, 4};
        Integer[] actual = arraz.reverseArray(a);
        assertEquals(expected, actual);

    }

    @Test
    public void testeven() {
        int[] a = {4, 5, 102, 6, -7, 12, -32, 92, 8};

        int expected = 7;
        //int  actual=arraz.oddEven(a) ;
        // Assert.assertEquals(expected ,actual) ;
    }

    @Test
    public void testevenodds() {
        int[] a = {4, 5, 102, 6, -7, 12, -32, 92, 8};


        OddEven expected = new OddEven(2, 7);

        OddEven actual = arraz.oddEven(a);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testevenodd() {
        //int [] a={4,5,102,6,-7,12,-32,92,8};
        int[] a = {0, 1, 2};


        OddEven expected = new OddEven(1, 2);

        OddEven actual = arraz.oddEven(a);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testIndexOf() {
        int[] a = {4, 5, 102, 6, -7, 12, -32, 92, 8};
        int value = 102;
        int expected = 2;
        int actual = arraz.indexOf(a, value);
        Assert.assertEquals(expected, actual);
    }


    @Test
    public void testcoppyOfarray() {
        Integer[] a = {4, 5, 102, 6, -7, 12, -32, 92, 8};
        Integer[] expected = {4, 5, 102, 6, -7, 12, -32, 92, 8};
        Integer actual[] = arraz.copyArrayLoop(a);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testcoppyOfarrayItr() {
        Integer[] a = {4, 5, 102, 6, -7, 12, -32, 92, 8};
        Integer[] expected = {4, 5, 102, 6, -7, 12, -32, 92, 8};
        Integer actual[] = arraz.copyArrayByInterator(a);
        Assert.assertEquals(expected, actual);
    }

    @Test

    public void testremovevalue() {
        Integer[] a = {4, 5, 102, 6, -7, 12, -32, 92, 8};
        Integer value = 102;
        Integer[] expected = {-32, -7, 4, 5, 6, 8, 12, 92};
        Integer actual[] = arraz.removeElementFromArray(a, value);
        Assert.assertEquals(expected, actual);
    }

    @Test

    public void testinsertvalue() {
        Integer [] a = {4, 5, 102, 6, -7, 12, -32, 92, 8};
        int value = 40;
        int index = 3;
        Integer [] expected = {4, 5, 102, 40, 6, -7, 12, -32, 92, 8};
        Integer  actual[] = arraz.insertIntoArrayat(a, value, index);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testmaxminarray() {

        int[] a = {4, 5, 102, 6, -7, 12, -32, 92, 8};
        MaxMin expected = new MaxMin(102, -32);
        MaxMin actual = arraz.maxMinarray(a);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testDuplicate() {
        Integer [] a = {4, 5, 102, 6, -7, 12, -32, 92, 6};
        Integer  expected[] = {-32,-7, 4, 5, 6, 12, 92, 102};
        Integer  actual[] = arraz.duplicates(a);
        Assert.assertEquals(expected, actual);

    }

    @Test
    public void testfib() {
        int expected = 34;
        int actual = arraz.fib(9);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testfibanocci() {
        int expected = 34;
        int actual = arraz.fibanocci(9);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testsecondLargest() {
        int[] a = {4, 5, 102, 6, -7, 12, -32, 95, 6};
        int expected = 95;
        int actual = arraz.secondLargest(a);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testarrayList() {
        Integer[] a = {1, 2, 3, 4, 5, 6};
        List<Integer> expected = new ArrayList<Integer>();
        expected.add(1);
        expected.add(2);
        expected.add(3);
        expected.add(4);
        expected.add(5);
        expected.add(6);
        List<Integer> actual = arraz.makemeArrayList(a);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testArrayequals() {
        int array[] = {1, 2, 3, 4, 5};
        int array2[] = {1, 2, 3, 4, 5};
        boolean expected = true;
        boolean actual = arraz.arrayEquals(array, array2);
        Assert.assertEquals(expected, actual);
    }

    @Test

    public void testCheckValue() {
        int array[] = {1, 2, 65, 4, 67, 4, 5};
        boolean expected = true;
        int n = 65;
        int m = 67;
        boolean actual = arraz.checkvalues(array, n, m);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testsumofTens() {
        int array[] = {1, 2, 3, 10, 3, 10, 10};
        boolean expected = true;
        boolean actual = arraz.sumOfTens(array, 10);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testsumofTens1() {
        int array[] = {1, 2, 3, 10, 3, 20, 10};
        boolean expected = false;
        boolean actual = arraz.sumOfTens(array, 10);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testSmallest() {
        Integer array[] = {1, 2, 3, 10, 3, 10, 10};
        Integer expected[] = {1, 2};
        Integer[] actual = arraz.smallestSecondsmallest(array);
        Assert.assertEquals(expected, actual);

    }

    @Test

    public void testCopyRev() {
        Integer[] array = {1, 2, 3, 4, 5};
        Integer expected[] = {5, 4, 3, 2, 1};
        Integer actual[] = arraz.makeMeACopyPlease(array);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testdeleateCopy() {
        Integer[] array = {1, 2, 3, 4, 5};
        Integer[] exp = {1, 2, 3, 4};
        Integer[] actual = arraz.removeLastItemandCopy(array, 5);
        Assert.assertEquals(actual, exp);
    }

    @Test
    public void testfirstremoveCopy() {
        Integer[] array = {1, 2, 3, 4, 5};
        Integer[] exp = {2, 3, 4, 5};
        Integer[] actual = arraz.removeFirstItemandCopy(array, 1);
        Assert.assertEquals(actual, exp);
    }

    @Test
    public void testinsertAtStartAndCopy() {
        Integer[] array = {1, 2, 3, 4, 5};
        int value = 0;
        Integer[] expected = {0, 1, 2, 3, 4, 5};
        Integer[] actual = arraz.insertAtStartAndCopy(array, value);
        Assert.assertEquals(expected, actual);

    }

    @Test
    public void testinsertAtendAndCopy() {
        Integer[] array = {1, 2, 3, 4, 5};
        int value = 6;
        Integer[] expected = {1, 2, 3, 4, 5, 6};
        Integer[] actual = arraz.insertAtTheEnd(array, value);
        Assert.assertEquals(expected, actual);

    }

    @Test
    public void testSortEvenOdd() {
        Integer[] array = {1, 2, 3, 4, 5, 6};
        Integer expected[] = {2, 4, 6, 1, 3, 5};
        Integer actual[] = arraz.sortArrayIntoEvensThenOdds(array);
        Assert.assertEquals(expected, actual);
    }

    @Test
    public void testavg() {
        Integer[] array = {1, 2, 3, 4, 5, 6};
        Integer expected = 3;
        Integer actual = arraz.averageValueWithoutMaxMin(array);
        Assert.assertEquals(expected, actual);

    }
}