Posts

Showing posts from August, 2019

A program and test to merge two lists whose length and item values are in the range 1 to 10,000 inclusive

import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; import java.util.stream.Collectors; import java.util.stream.Stream; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; public class MergerTest { private static final int MIN = 1; private static final int MAX = 10000; @DataProvider(parallel = true) public Object[][] data() { int[] one = new int[]{1, 2, 3, 4, 10, 20, 30}; int[] two = new int[]{20, 30, 1, 2, 1, 3, 4, 4, 5}; int[] dynamicOne = ThreadLocalRandom .current().ints(MIN, MAX + 1).limit(MAX).toArray(); int[] dynamicTwo = ThreadLocalRandom .current().ints(MIN, MAX + 1).limit(MAX).toArray(); int[] sameOne = new int[]{7, 7, 7, 7, 7, 7, 7}; int[] diffOne = new int[]{1, 2, 3, 4, 5, 6, 7};