package org.commcare.utils;

import org.javarosa.core.util.DataUtil;
import org.junit.Test;

import java.util.Vector;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
 * @author Phillip Mates (pmates@dimagi.com)
 */
public class AndroidUtilTest {
    @Test
    public void intersectionTest() {
        DataUtil.IntersectionLambda intersectionLambda = new AndroidUtil.AndroidIntersectionLambda();
        Vector<String> setOne = new Vector<>();
        setOne.add("one");
        setOne.add("two");

        Vector<String> setTwo = new Vector<>();
        setTwo.add("one");
        setTwo.add("three");
        Vector<String> unionSet = intersectionLambda.intersection(setOne, setTwo);

        // for safety, we want to return a whole new vector
        assertFalse(unionSet == setOne);
        assertFalse(unionSet == setTwo);

        // for safety, don't modify ingoing vector arguments
        assertTrue(setOne.contains("one"));
        assertTrue(setOne.contains("two"));

        assertTrue(setTwo.contains("one"));
        assertTrue(setTwo.contains("three"));

        // make sure proper intersection is computed
        assertTrue(unionSet.contains("one"));

        assertFalse(unionSet.contains("two"));
        assertFalse(unionSet.contains("three"));
    }
}

@@ -663,21 +663,25 @@
 String%3E 
-union
+intersect
 Set = in
@@ -800,37 +800,41 @@
     assertFalse(
-union
+intersect
 Set == setOne);%0A
@@ -853,21 +853,25 @@
 rtFalse(
-union
+intersect
 Set == s
@@ -1192,21 +1192,25 @@
 ertTrue(
-union
+intersect
 Set.cont
@@ -1236,37 +1236,41 @@
     assertFalse(
-union
+intersect
 Set.contains(%22tw
@@ -1299,13 +1299,17 @@
 lse(
-union
+intersect
 Set.

Give test var proper name