package test.leecode.math; import java.util.List; import org.junit.Assert; import org.junit.Test; import cn.fansunion.leecode.math.PascalsTriangle; /** * @author wen.lei@brgroup.com * * 2022-2-25 */ public class PascalsTriangleTest @Test public void test() // 输入: numRows = 5 // 输出: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]] PascalsTriangle test = new PascalsTriangle(); List<List<Integer>> rowList = test.generate( 5 ); //重载函数有歧义,烦死 //1 Assert.assertEquals( 1 , (Object)rowList.get( 0 ).get( 0 )); //2 Assert.assertEquals( 1 , (Object)rowList.get( 1 ).get( 0 )); Assert.assertEquals( 1 , (Object)rowList.get( 1 ).get( 1 )); //3 Assert.assertEquals( 1 , (Object)rowList.get( 2 ).get( 0 )); Assert.assertEquals( 2 , (Object)rowList.get( 2 ).get( 1 )); Assert.assertEquals( 1 , (Object)rowList.get( 2 ).get( 2 )); //4 Assert.assertEquals( 1 , (Object)rowList.get( 3 ).get( 0 )); Assert.assertEquals( 3 , (Object)rowList.get( 3 ).get( 1 )); Assert.assertEquals( 3 , (Object)rowList.get( 3 ).get( 2 )); Assert.assertEquals( 1 , (Object)rowList.get( 3 ).get( 3 )); //5 Assert.assertEquals( 1 , (Object)rowList.get( 4 ).get( 0 )); Assert.assertEquals( 4 , (Object)rowList.get( 4 ).get( 1 )); Assert.assertEquals( 6 , (Object)rowList.get( 4 ).get( 2 )); Assert.assertEquals( 4 , (Object)rowList.get( 4 ).get( 3 )); Assert.assertEquals( 1 , (Object)rowList.get( 4 ).get( 4 ));
|