package ru.matevosyan;

import org.junit.Test;

import java.util.Iterator;

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));
    }

    @Test public void whenCreateObjddectAndAddValuesThanCheckSize() {
        FastSimpleSet<String> fastSimpleSet = new FastSimpleSet<>();


            fastSimpleSet.add("abaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac");
            fastSimpleSet.add("dddddddddddddddddddddd");
            fastSimpleSet.add("papa");
            fastSimpleSet.add("ayyyyyyyyGGGGGGGGGGaaaaaac");
            fastSimpleSet.add("dddddddFFFFFGGGGGddddddddddddddd");
            fastSimpleSet.add("papGGFFFFFFFa");

        Iterator<String> itr = fastSimpleSet.iterator();

        while(itr.hasNext()) {
            System.out.println(itr.next());
        }


//        assertThat(fastSimpleSet.get("abc" + 1), is("abc" + 1));

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


}
@@ -864,32 +864,126 @@
 + i);%0A        %7D%0A
+        for (int i = 0; i %3C 100000; i++) %7B%0A            fastSimpleSet.get(%22one%22 + i);%0A        %7D
 %0A        long fa
@@ -1186,32 +1186,121 @@
 + i);%0A        %7D%0A
+        for (int i = 0; i %3C 100000; i++) %7B%0A            dynamicSimpleSet.get(i);%0A        %7D
 %0A        long dy
@@ -2128,24 +2128,160 @@
 0));%0A    %7D%0A%0A
+    /**%0A     * whenCreateObjddectAndAddValuesThanCheckSize for testing iterator and check size.%0A     * when insert duplicates.%0A     */%0A%0A
     @Test pu
@@ -2444,42 +2444,25 @@
 dd(%22
-abaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac
+---qqqqqqqqqqqqqq
 %22);%0A
@@ -2496,30 +2496,21 @@
 dd(%22
-dddddddddddddddddddddd
+444ergw3grger
 %22);%0A
@@ -2543,16 +2543,23 @@
 add(%22pap
+gerg34g
 a%22);%0A   
@@ -2590,149 +2590,269 @@
 dd(%22
-ayyyyyyyyGGGGGGGGGGaaaaaac%22);%0A            fastSimpleSet.add(%22dddddddFFFFFGGGGGddddddddddddddd%22);%0A            fastSimpleSet.add(%22papGGFFFFFFFa
+@gerge4g3g@@%22);%0A            fastSimpleSet.add(%22%3Eergerge%3E%3E%22);%0A            fastSimpleSet.add(%22~~~%7Crgerhrtj%7Cooo%22);%0A            fastSimpleSet.add(%22~~~%7Crgerhrtj%7Cooo%22);%0A            fastSimpleSet.add(%22~~~%7Crgerhrtj%7Cooo%22);%0A            fastSimpleSet.add(%22~~~%7Crgerhrtj%7Cooo
 %22);%0A
@@ -2954,34 +2954,26 @@
        S
-ystem.out.println(
+tring s = 
 itr.next
@@ -2974,17 +2974,16 @@
 r.next()
-)
 ;%0A      
@@ -2988,78 +2988,44 @@
     
-%7D%0A%0A%0A//        assertThat(fastSimpleSet.get(%22abc%22 + 1), is(%22abc%22 + 1));
+    System.out.println(s);%0A        %7D
 %0A%0A  

change method