package test.leecode.number; import org.junit.Assert; import org.junit.Test; import cn.fansunion.leecode.todo.MaxConsecutiveOnes; /** * @author wen.lei@brgroup.com * * 2022-2-25 */ public class MaxConsecutiveOnesTest { @Test public void test() { MaxConsecutiveOnes test = new MaxConsecutiveOnes(); int [] nums0= new int [] { 0 , 0 , 0 , 0 , 0 }; Assert.assertEquals( 0 , test.findMaxConsecutiveOnes(nums0)); int [] nums1= new int [] { 1 , 0 , 0 , 0 , 0 }; Assert.assertEquals( 1 , test.findMaxConsecutiveOnes(nums1)); int [] nums11= new int [] { 0 , 0 , 0 , 0 , 1 }; Assert.assertEquals( 1 , test.findMaxConsecutiveOnes(nums11)); int [] nums2= new int [] { 1 , 1 , 0 , 0 , 0 }; Assert.assertEquals( 2 , test.findMaxConsecutiveOnes(nums2)); int [] nums21= new int [] { 1 , 0 , 1 , 1 , 0 }; Assert.assertEquals( 2 , test.findMaxConsecutiveOnes(nums21)); int [] nums22= new int [] { 1 , 0 , 0 , 1 , 1 }; Assert.assertEquals( 2 , test.findMaxConsecutiveOnes(nums22)); int [] nums3= new int [] { 0 , 0 , 1 , 1 , 1 }; Assert.assertEquals( 3 , test.findMaxConsecutiveOnes(nums3)); int [] nums31= new int [] { 1 , 0 , 1 , 1 , 1 }; Assert.assertEquals( 3 , test.findMaxConsecutiveOnes(nums31)); int [] nums32= new int [] { 1 , 1 , 1 , 0 , 1 }; Assert.assertEquals( 3 , test.findMaxConsecutiveOnes(nums32)); int [] nums6= new int [] { 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 }; Assert.assertEquals( 6 , test.findMaxConsecutiveOnes(nums6)); int [] nums7= new int [] { 1 , 1 , 1 , 0 , 1 , 0 , 1 , 1 , 0 , 1 , 1 , 1 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 }; Assert.assertEquals( 7 , test.findMaxConsecutiveOnes(nums7)); } } |