package ru.matevosyan;

import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertTrue;


/**
 * FastSimpleSetTest class.
 * Created on 04.06.2017.
 * @author Matevosyan Vardan
 * @version 1.0
 */

public class FastSimpleSetTest {

    /**
     * Create whenCreateTwoObjectAndAddValuesThanCheckWhoAddedFasterToTheContainer() to check hwo is faster.
     */

    @Test public void whenCreateTwoObjectAndAddValuesThanCheckWhoAddedFasterToTheContainer() {
        FastSimpleSet<String> fastSimpleSet = new FastSimpleSet<>();
        DynamicSimpleSet<String> dynamicSimpleSet = new DynamicSimpleSet<>();

        long fastSetTimeBegin = System.currentTimeMillis();
        for (int i = 0; i < 100000; i++) {
            fastSimpleSet.add("one" + i);
        }

        long fastSetTimeEnd = System.currentTimeMillis();


        long dynamicSimpleSetTimeBegin = System.currentTimeMillis();
        for (int i = 0; i < 100000; i++) {
            dynamicSimpleSet.add("one" + i);
        }

        long dynamicSimpleSetTimeEnd = System.currentTimeMillis();

        long fastTime = fastSetTimeEnd - fastSetTimeBegin;
        long dynamicSimpleTime = dynamicSimpleSetTimeEnd - dynamicSimpleSetTimeBegin;
        System.out.println(fastTime + "fast");

        System.out.println(dynamicSimpleTime + "simple");
        assertTrue(fastTime < dynamicSimpleTime);


    }

    /**
     * whenCreateObjectAndAddValuesThanCheckSize to test array size.
     */

    @Test public void whenCreateObjectAndAddValuesThanCheckSize() {
        FastSimpleSet<Integer> fastSimpleSet = new FastSimpleSet<>();

        for (int i = 0; i < 30; i++) {
            fastSimpleSet.add(i);
        }

        assertThat(fastSimpleSet.get(1), is(1));
        assertThat(fastSimpleSet.get(20), is(20));

        assertThat(fastSimpleSet.getSize(), is(30));
    }


}
@@ -41,16 +41,44 @@
 .Test;%0A%0A
+import java.util.Iterator;%0A%0A
 import s
@@ -1949,10 +1949,764 @@
 %0A    %7D%0A%0A
+    @Test public void whenCreateObjddectAndAddValuesThanCheckSize() %7B%0A        FastSimpleSet%3CString%3E fastSimpleSet = new FastSimpleSet%3C%3E();%0A%0A%0A            fastSimpleSet.add(%22abaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac%22);%0A            fastSimpleSet.add(%22dddddddddddddddddddddd%22);%0A            fastSimpleSet.add(%22papa%22);%0A            fastSimpleSet.add(%22ayyyyyyyyGGGGGGGGGGaaaaaac%22);%0A            fastSimpleSet.add(%22dddddddFFFFFGGGGGddddddddddddddd%22);%0A            fastSimpleSet.add(%22papGGFFFFFFFa%22);%0A%0A        Iterator%3CString%3E itr = fastSimpleSet.iterator();%0A%0A        while(itr.hasNext()) %7B%0A            System.out.println(itr.next());%0A        %7D%0A%0A%0A        assertThat(fastSimpleSet.get(%22abc%22 + 1), is(%22abc%22 + 1));%0A%0A        assertThat(fastSimpleSet.getSize(), is(30));%0A    %7D%0A%0A
 %0A%7D

add one test method