# On the test of Fibonacci sequence

2022-02-02 20:24:25

part1
public static int[] getFibSeq(int i) {
int[] result = null;
int [] fib= new int [i];
if (i==0) {
result = fib;
}
if (i ==1) {
fib[0]=1;
result = fib;
}
if (i ==2) {
fib[0]=1;
fib[1]=1;
result = fib;
}
else {
for (int j=2 ; j<fib.length; j++) {
if (fib[j-2]+fib[j-1]==fib[j]) {
if (fib[0]==1) {
if(fib[1]==1) {
result=fib;
}

``                }            }                            }            }        ``

.
return result;
}

part2
public void test_isFibSeq_01() {
int[] input = {1, 1};
boolean result = Utilities.isFibSeq(input);
assertEquals(true, result);
}

``````@Testpublic void test_isFibSeq_02() {    int[] input = {

2, 2};    boolean result = Utilities.isFibSeq(input);    assertEquals(false, result);}@Testpublic void test_isFibSeq_03() {    int[] input = {

1, 1, 2, 3, 5, 8, 13};    boolean result = Utilities.isFibSeq(input);    assertEquals(true, result);}@Testpublic void test_isFibSeq_04() {    int[] input = {

1, 1, 2, 3, 7, 8, 13};    boolean result = Utilities.isFibSeq(input);    assertEquals(false, result);}@Testpublic void test_isFibSeq_05() {    int[] input = {

2, 2, 4, 6, 10, 16, 26};    boolean result = Utilities.isFibSeq(input);    assertEquals(false, result);} Run... With the code I edited part2  Of Junit test  after test05  There will be errors   I can't figure out how to solve it ,  I hope you can help solve   Thank you for ！    ``````