package io.schinzel.basicutils;

import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;
import org.junit.Test;

/**
 *
 * @author schinzel
 */
public class CheckerTest {

    @Test
    public void testIsEmptyList() {
        List list = null;
        assertTrue(Checker.isEmpty(list));
        ArrayList arrayList = null;
        assertTrue(Checker.isEmpty(arrayList));
        arrayList = new ArrayList();
        assertTrue(Checker.isEmpty(arrayList));
        arrayList.add("monkey");
        assertFalse(Checker.isEmpty(arrayList));
        arrayList.remove("monkey");
        assertTrue(Checker.isEmpty(arrayList));
        arrayList.add("monkey");
        assertFalse(Checker.isEmpty(arrayList));
        arrayList.clear();
        assertTrue(Checker.isEmpty(arrayList));
    }


    @Test
    public void testIsEmptyObject() {
        ArbitraryObjectForTestingIsEmpty o = null;
        assertTrue(Checker.isEmpty(o));
        o = new ArbitraryObjectForTestingIsEmpty();
        assertFalse(Checker.isEmpty(o));
    }


    @Test
    public void testIsEmptyString() {
        String str = null;
        assertTrue(Checker.isEmpty(str));
        str = "";
        assertTrue(Checker.isEmpty(str));
        str = "monkey";
        assertFalse(Checker.isEmpty(str));
    }


    @Test
    public void testIsEmptyStringArray() {
        String[] arr = null;
        assertTrue(Checker.isEmpty(arr));
        arr = new String[0];
        assertTrue(Checker.isEmpty(arr));
        arr = new String[1];
        assertFalse(Checker.isEmpty(arr));
        arr = new String[]{"monkey"};
        assertFalse(Checker.isEmpty(arr));
    }


    @Test
    public void testIsEmptyByteArray() {
        byte[] arr = null;
        assertTrue(Checker.isEmpty(arr));
        arr = new byte[0];
        assertTrue(Checker.isEmpty(arr));
        arr = new byte[1];
        assertFalse(Checker.isEmpty(arr));
        arr = new byte[]{1};
        assertFalse(Checker.isEmpty(arr));
    }


    @Test
    public void testIsEmptyDoubleArray() {
        double[] arr = null;
        assertTrue(Checker.isEmpty(arr));

        arr = new double[0];
        assertTrue(Checker.isEmpty(arr));

        arr = new double[1];
        assertFalse(Checker.isEmpty(arr));

        arr = new double[]{1d};
        assertFalse(Checker.isEmpty(arr));
    }


    @Test
    public void testObjectArray() {
        ArbitraryObjectForTestingIsEmpty[] arr = null;
        assertTrue(Checker.isEmpty(arr));

        arr = new ArbitraryObjectForTestingIsEmpty[0];
        assertTrue(Checker.isEmpty(arr));

        arr = new ArbitraryObjectForTestingIsEmpty[1];
        assertFalse(Checker.isEmpty(arr));

        arr = new ArbitraryObjectForTestingIsEmpty[]{new ArbitraryObjectForTestingIsEmpty()};
        assertFalse(Checker.isEmpty(arr));
    }

    static class ArbitraryObjectForTestingIsEmpty {
    }
}

@@ -71,20 +71,68 @@
 va.util.
-List
+HashMap;%0Aimport java.util.List;%0Aimport java.util.Map
 ;%0Aimport
@@ -214,16 +214,16 @@
 zel%0A */%0A
-
 public c
@@ -242,16 +242,251 @@
 Test %7B%0A%0A
+    @Test%0A    public void testIsEmptyMap() %7B%0A        assertTrue(Checker.isEmpty(EmptyObjects.EMPTY_MAP));%0A        Map%3CString, String%3E map = new HashMap%3C%3E();%0A        map.put(%22a%22, %22b%22);%0A        assertFalse(Checker.isEmpty(map));%0A    %7D%0A%0A%0A
     @Tes
@@ -3117,16 +3117,17 @@
 %0A    %7D%0A%0A
+%0A
     stat

Test added