2012-05-10 4 views
0

이 코드에 대한 제어 흐름 그래프 및 순환 복잡성을 찾아 화이트 박스 테스트 사례 및 블랙 박스 테스트 사례를 제안해야합니다. 하지만 코드에 CFG를 만드는 데 문제가 있습니다.제어 흐름 그래프 및 순환 복잡도

테스트 사례에 대한 도움을 받으실 수 있습니다.

private void downShift(int index) 
{ 
    // index of "child", which will be either index * 2 or index * 2 + 1 
    int childIndex; 

    // temp storage for item at index where shifting begins 
    Comparable temp = theItems[index]; 

    // shift items, as needed 
    while (index * 2 <= theSize) 
    { 
     // set childIndex to "left" child 
     childIndex = index * 2; 

     // move to "right" child if "right" child < "left" child 
     if (childIndex != theSize && theItems[childIndex + 1].compareTo(theItems[childIndex]) < 0) 
      childIndex++; 

     if (theItems[childIndex].compareTo(temp) < 0) 
     { 
     // shift "child" down if child < temp 
      theItems[index] = theItems[childIndex]; 
     } 
     else 
     { 
      // shifting complete 
      break; 
     } 

     // increment index 
     index = childIndex; 
    } 

    // position item that was originally at index where shifting began 
    theItems[index] = temp; 
} 

답변

1

여기에 기본 된 Cyclomatic의 복잡성은 4 : 동안 + +의 경우 경우에 의해 수행되는대로 복잡성을 확장 고려하면 + 1. 이해 또는 CMTJava은 또한 conjuncts 1을 추가해야합니다, 그래서 것 5. break과 같은 무조건 제어 명령문은 순환 복잡도 값에 영향을 미치지 않습니다.