<commit_before>package test.asserttests;

import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;

/**
 * Tests different equality cases for nested collections
 * and arrays.
 */
public class ArrayEqualityAssertTest {
    @Test
    public void arrayInsideListAssertEquals() {
        List<int[]> list = Arrays.asList(
            new int[]{ 42 }
        );
        List<int[]> listCopy = Arrays.asList(
            new int[]{ 42 }
        );
        assertEquals(list, listCopy,
                "arrays inside lists are compared by value in assertEquals");
    }

    @Test
    public void arrayInsideListAssertNotEquals() {
        List<int[]> list = Arrays.asList(
            new int[]{ 42 }
        );
        List<int[]> listCopy = Arrays.asList(
            new int[]{ 42 }
        );
        assertNotEquals(list, listCopy,
                "arrays inside lists aren't compared by value in assertNotEquals");
    }

    @Test
    public void arrayInsideMapAssertEquals() {
        Map<String, int[]> map = new HashMap<>();
        map.put("array", new int[]{ 42 });
        Map<String, int[]> mapCopy = new HashMap<>();
        mapCopy.put("array", new int[]{ 42 });

        // arrays inside maps are compared by value in assertEquals(Map,Map)
        assertEquals(map, mapCopy);
    }

    @Test(expectedExceptions = AssertionError.class)
    public void arrayInsideMapAssertEqualsWithMessage() {
        Map<String, int[]> map = new HashMap<>();
        map.put("array", new int[]{ 42 });
        Map<String, int[]> mapCopy = new HashMap<>();
        mapCopy.put("array", new int[]{ 42 });

        assertEquals(map, mapCopy,
                "arrays inside maps aren't compared by value in assertEquals(Map,Map,String)");
    }

    @Test
    public void arrayInsideMapAssertNotEquals() {
        Map<String, int[]> map = new HashMap<>();
        map.put("array", new int[]{ 42 });
        Map<String, int[]> mapCopy = new HashMap<>();
        mapCopy.put("array", new int[]{ 42 });

        assertNotEquals(map, mapCopy,
                "arrays inside maps aren't compared by value in assertNotEquals");
    }

    @Test(expectedExceptions = AssertionError.class)
    public void arrayInsideSetAssertEquals() {
        Set<int[]> set = new HashSet<>();
        set.add(new int[]{ 42 });
        Set<int[]> setCopy = new HashSet<>();
        setCopy.add(new int[]{ 42 });

        assertEquals(set, setCopy,
                "arrays inside sets aren't compared by value in assertNotEquals");
    }

    @Test
    public void arrayInsideSetAssertNotEquals() {
        Set<int[]> set = new HashSet<>();
        set.add(new int[]{ 42 });
        Set<int[]> setCopy = new HashSet<>();
        setCopy.add(new int[]{ 42 });

        assertNotEquals(set, setCopy,
                "arrays inside sets aren't compared by value in assertNotEquals");
    }

    @Test(expectedExceptions = AssertionError.class)
    public void arrayDeepInListsAssertEquals() {
        List<List<int[]>> list = Collections.singletonList(Arrays.asList(new int[]{ 42 }));
        List<List<int[]>> listCopy = Collections.singletonList(Arrays.asList(new int[]{ 42 }));

        assertEquals(list, listCopy,
                "arrays inside lists which are inside lists themselves aren't compared by value in assertEquals");
    }

    @Test(expectedExceptions = AssertionError.class)
    public void arrayDeepInMapsAssertEquals() {
        Map<String, Map<String, int[]>> map = new HashMap<>();
        Map<String, int[]> innerMap = new HashMap<>();
        innerMap.put("array", new int[]{ 42 });
        map.put("map", innerMap);
        Map<String, Map<String, int[]>> mapCopy = new HashMap<>();
        Map<String, int[]> innerMapCopy = new HashMap<>();
        innerMapCopy.put("array", new int[]{ 42 });
        mapCopy.put("map", innerMapCopy);

        assertEquals(map, mapCopy,
                "arrays inside maps which are inside maps themselves aren't compared by value in assertEquals");
    }

    @Test(expectedExceptions = AssertionError.class)
    public void arrayDeepInListAndMapAssertEquals() {
        List<Map<String, int[]>> list = new ArrayList<>();
        Map<String, int[]> innerMap = new HashMap<>();
        innerMap.put("array", new int[]{ 42 });
        list.add(innerMap);
        List<Map<String, int[]>> listCopy = new ArrayList<>();
        Map<String, int[]> innerMapCopy = new HashMap<>();
        innerMapCopy.put("array", new int[]{ 42 });
        list.add(innerMapCopy);

        assertEquals(list, listCopy,
                "arrays inside maps which are inside lists themselves aren't compared by value in assertEquals");
    }

    @Test(expectedExceptions = AssertionError.class)
    public void arrayDeepInMapAndListAssertEquals() {
        Map<String, List<int[]>> map = new HashMap<>();
        map.put("list", Arrays.asList(new int[]{ 42 }));
        Map<String, List<int[]>> mapCopy = new HashMap<>();
        mapCopy.put("list", Arrays.asList(new int[]{ 42 }));

        assertEquals(map, mapCopy,
                "arrays inside maps which are inside lists themselves aren't compared by value in assertEquals");
    }

    // Test Iterable and assertArrayEquals()
}
<commit_msg>Add tests for arrays equality in Iterables/arrays<commit_after>package test.asserttests;

import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;

/**
 * Tests different equality cases for nested collections
 * and arrays.
 */
public class ArrayEqualityAssertTest {
    @Test
    public void arrayInsideListAssertEquals() {
        List<int[]> list = Arrays.asList(
            new int[]{ 42 }
        );
        List<int[]> listCopy = Arrays.asList(
            new int[]{ 42 }
        );
        assertEquals(list, listCopy,
                "arrays inside lists are compared by value in assertEquals");
    }

    @Test
    public void arrayInsideListAssertNotEquals() {
        List<int[]> list = Arrays.asList(
            new int[]{ 42 }
        );
        List<int[]> listCopy = Arrays.asList(
            new int[]{ 42 }
        );
        assertNotEquals(list, listCopy,
                "arrays inside lists aren't compared by value in assertNotEquals");
    }

    @Test
    public void arrayInsideMapAssertEquals() {
        Map<String, int[]> map = new HashMap<>();
        map.put("array", new int[]{ 42 });
        Map<String, int[]> mapCopy = new HashMap<>();
        mapCopy.put("array", new int[]{ 42 });

        // arrays inside maps are compared by value in assertEquals(Map,Map)
        assertEquals(map, mapCopy);
    }

    @Test(expectedExceptions = AssertionError.class)
    public void arrayInsideMapAssertEqualsWithMessage() {
        Map<String, int[]> map = new HashMap<>();
        map.put("array", new int[]{ 42 });
        Map<String, int[]> mapCopy = new HashMap<>();
        mapCopy.put("array", new int[]{ 42 });

        assertEquals(map, mapCopy,
                "arrays inside maps aren't compared by value in assertEquals(Map,Map,String)");
    }

    @Test
    public void arrayInsideMapAssertNotEquals() {
        Map<String, int[]> map = new HashMap<>();
        map.put("array", new int[]{ 42 });
        Map<String, int[]> mapCopy = new HashMap<>();
        mapCopy.put("array", new int[]{ 42 });

        assertNotEquals(map, mapCopy,
                "arrays inside maps aren't compared by value in assertNotEquals");
    }

    @Test(expectedExceptions = AssertionError.class)
    public void arrayInsideSetAssertEquals() {
        Set<int[]> set = new HashSet<>();
        set.add(new int[]{ 42 });
        Set<int[]> setCopy = new HashSet<>();
        setCopy.add(new int[]{ 42 });

        assertEquals(set, setCopy,
                "arrays inside sets aren't compared by value in assertNotEquals");
    }

    @Test
    public void arrayInsideSetAssertNotEquals() {
        Set<int[]> set = new HashSet<>();
        set.add(new int[]{ 42 });
        Set<int[]> setCopy = new HashSet<>();
        setCopy.add(new int[]{ 42 });

        assertNotEquals(set, setCopy,
                "arrays inside sets aren't compared by value in assertNotEquals");
    }

    @Test(expectedExceptions = AssertionError.class)
    public void arrayDeepInListsAssertEquals() {
        List<List<int[]>> list = Collections.singletonList(Arrays.asList(new int[]{ 42 }));
        List<List<int[]>> listCopy = Collections.singletonList(Arrays.asList(new int[]{ 42 }));

        assertEquals(list, listCopy,
                "arrays inside lists which are inside lists themselves aren't compared by value in assertEquals");
    }

    @Test(expectedExceptions = AssertionError.class)
    public void arrayDeepInMapsAssertEquals() {
        Map<String, Map<String, int[]>> map = new HashMap<>();
        Map<String, int[]> innerMap = new HashMap<>();
        innerMap.put("array", new int[]{ 42 });
        map.put("map", innerMap);
        Map<String, Map<String, int[]>> mapCopy = new HashMap<>();
        Map<String, int[]> innerMapCopy = new HashMap<>();
        innerMapCopy.put("array", new int[]{ 42 });
        mapCopy.put("map", innerMapCopy);

        assertEquals(map, mapCopy,
                "arrays inside maps which are inside maps themselves aren't compared by value in assertEquals");
    }

    @Test(expectedExceptions = AssertionError.class)
    public void arrayDeepInListAndMapAssertEquals() {
        List<Map<String, int[]>> list = new ArrayList<>();
        Map<String, int[]> innerMap = new HashMap<>();
        innerMap.put("array", new int[]{ 42 });
        list.add(innerMap);
        List<Map<String, int[]>> listCopy = new ArrayList<>();
        Map<String, int[]> innerMapCopy = new HashMap<>();
        innerMapCopy.put("array", new int[]{ 42 });
        list.add(innerMapCopy);

        assertEquals(list, listCopy,
                "arrays inside maps which are inside lists themselves aren't compared by value in assertEquals");
    }

    @Test(expectedExceptions = AssertionError.class)
    public void arrayDeepInMapAndListAssertEquals() {
        Map<String, List<int[]>> map = new HashMap<>();
        map.put("list", Arrays.asList(new int[]{ 42 }));
        Map<String, List<int[]>> mapCopy = new HashMap<>();
        mapCopy.put("list", Arrays.asList(new int[]{ 42 }));

        assertEquals(map, mapCopy,
                "arrays inside maps which are inside lists themselves aren't compared by value in assertEquals");
    }

    @Test
    public void arrayInsideIterableAssertEquals() {
        Iterable<int[]> iterable = Arrays.asList(
            new int[]{ 42 }
        );
        Iterable<int[]> iterableCopy = Arrays.asList(
            new int[]{ 42 }
        );
        assertEquals(iterable, iterableCopy,
                "arrays inside Iterables are compared by value in assertEquals");
    }

    @Test(expectedExceptions = AssertionError.class)
    public void arrayDeepInIterablesAssertEquals() {
        List<List<int[]>> iterable = Collections.singletonList(Arrays.asList(new int[]{ 42 }));
        List<List<int[]>> iterableCopy = Collections.singletonList(Arrays.asList(new int[]{ 42 }));

        assertEquals(iterable, iterableCopy,
                "arrays inside Iterables which are inside Iterables themselves aren't compared by value in assertEquals");
    }

    @Test
    public void arrayInsideArrayAssertEquals() {
        int[][] array = new int[][] {
            new int[]{ 42 }
        };
        int[][] arrayCopy = new int[][] {
            new int[]{ 42 }
        };
        assertEquals(array, arrayCopy,
                "arrays inside arrays are compared by value in assertEquals");
    }

    @Test
    public void arrayDeepInArraysAssertEquals() {
        int[][][] array = new int[][][] {
            new int[][] { new int[]{ 42 } }
        };
        int[][][] arrayCopy = new int[][][] {
            new int[][] { new int[]{ 42 } }
        };

        assertEquals(array, arrayCopy,
                "arrays inside arrays which are inside arrays themselves are compared by value in assertEquals");
    }

    @SuppressWarnings("unchecked")
    @Test(expectedExceptions = AssertionError.class)
    public void arrayDeepInArrayAndListAssertEquals() {
        List<int[]>[] array = new List[] {
            Arrays.asList(new int[]{ 42 })
        };
        List<int[]>[] arrayCopy = new List[] {
            Arrays.asList(new int[]{ 42 })
        };

        assertEquals(array, arrayCopy,
                "arrays inside arrays which are inside arrays themselves aren't compared by value in assertEquals");
    }

}

{'fraction_non_alphanumeric': 0.1285809956097924, 'fraction_numerical': 0.008036312225612024, 'mean_word_length': 2.4259495284221257, 'pattern_counts': {'":': 0, '<': 119, '<?xml version=': 0, '>': 119, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3748296', 'n_tokens_mistral': 3842, 'n_tokens_neox': 3513, 'n_words': 1025}