2012-05-10 20 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

ここでは基本的なサイクロマティック複雑度は4です:理解やCMTJavaによって行われているように、あなたが循環的複雑度を拡張を検討した場合、あなたはまた、論理積に1を追加する必要があり、それは意志1 +場合+ +もしながら、 breakのような無条件制御文は、循環複雑度の値に影響を与えません。

関連する問題