package ru.apetrov.Set;

import org.junit.Test;

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

/**
 * Created by Andrey on 01.04.2017.
 */
public class FastSetArrayTest {

    /**
     * check method enlargeCapacity().
     */
    @Test
    public void whenArrayLengthFullThenCreateNewArray() {
        FastSetArray<Integer> set = new FastSetArray<>(1);
        set.add(2);
        set.add(3);
        assertThat(set.getValue().length, is(2));
    }

    /**
     * Automatic sorting checking, when adding new items.
     */
    @Test
    public void whenAddElementsThenGetSortedArray() {
        FastSetArray<String> set = new FastSetArray<>(5);
        set.add("4");
        set.add("8");
        set.add("5");
        set.add("2");
        set.add("7");

        String[] result = new String[5];
        int index = 0;
        for (Object i: set.getValue()) {
            result[index++] = (String) i;
        }

        assertThat(result, is(new String[]{"2", "4", "5", "7", "8"}));

    }
}
@@ -739,24 +739,46 @@
 t.add(%225%22);%0A
+        set.add(%224%22);%0A
         set.
@@ -808,16 +808,60 @@
 dd(%227%22);
+%0A        set.add(%226%22);%0A        set.add(%225%22);
 %0A%0A      
@@ -891,17 +891,17 @@
  String%5B
-5
+6
 %5D;%0A     
@@ -955,24 +955,51 @@
 tValue()) %7B%0A
+            if (i != null)%0A
             
@@ -1096,16 +1096,21 @@
 4%22, %225%22,
+ %226%22,
  %227%22, %228

add coment