package test.leecode.math; import org.junit.Assert; import org.junit.Test; import cn.fansunion.leecode.number.LargestNumberAtLeastTwiceOfOthers; /** * @author wen.lei@brgroup.com * * 2022-2-25 */ public class LargestNumberAtLeastTwiceOfOthersTest @Test public void test() LargestNumberAtLeastTwiceOfOthers test = new LargestNumberAtLeastTwiceOfOthers(); //-1 int [] num14= new int [] 2 , 3 , 4 , 7 , 11 ; Assert.assertEquals(- 1 ,test.dominantIndex(num14)); int [] nums13= new int [] 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 ; Assert.assertEquals(- 1 ,test.dominantIndex(nums13)); int [] nums12= new int [] 1 , 2 , 3 , 4 , 5 , 16 , 17 , 8 , 9 , 20 , 21 ; Assert.assertEquals(- 1 ,test.dominantIndex(nums12)); int [] nums11= new int [] 1 , 3 , 5 ; Assert.assertEquals(- 1 ,test.dominantIndex(nums11)); //有值 int [] nums0= new int [] 1 ; Assert.assertEquals( 0 ,test.dominantIndex(nums0)); int [] nums1= new int [] 0 , 1 ; Assert.assertEquals( 1 ,test.dominantIndex(nums1)); int [] nums5= new int [] 1 , 2 , 4 , 8 , 8 , 17 ; Assert.assertEquals( 5 ,test.dominantIndex(nums5));
|