题目详情

[说明] 逻辑覆盖法是设计白盒测试用例的主要方法之一,它是通过对程序逻辑结构的遍历实现程序的覆盖。针对以下由C语言编写的程序,按要求回答问题。

Struct_ProtobufCIntRange{

Int start_value;

Unsigned orig_index;

};

typedef struct_ProtobufCIntRange ProtobufCIntRange;

in tint_range_lookup(unsigned n_ranges,const ProtobufCIntRange*ranges,int value) {

unsigned start,n; //1

start=0;

n=n_ranges;

while (n>1) { //2

unsigned mid=start+n/2;

if(value< ranges[mid].start_value) { //3

n=mid-start; //4

}

else if (value>=ranges[mid].start_value+ (int)(ranges[mid+1].orig_index-ranges[mid].orig_index)) { //5

unsigned new_start=mid+1; //6

n=start+n-new_start;

start=new_start;

}

else //7

return(value-ranges[mid].start_value)+ranges[mid].orig_index;

}

if(n>0){ //8

unsigned start_orig_index=ranges[start].orig_index;

unsigned range_size=ranges[start+1].orig_index-start_orig_index;

if (ranges[start].start_value<=value && value<(int)(ranges[start].start_value+range_size)) //9,10

return(value-ranges[start].start_value)+start_orig_index; //11

}

return -1; //12

} //13

5、[问题1] 请给出满足100%DC(判定覆盖)所需的逻辑条件。(6分)6、[问题2] 请画出上述程序的控制流图,并计算其控制流图的环路复杂度VG.。(6分)

7、[问题3] 请给出[问题2]中控制流图的线性无关路径。(4分)

正确答案及解析

正确答案
解析

5、本题考查白盒测试法的应用。

本问题考查白盒测试用例设计方法中的判定覆盖法。

判定覆盖指设计足够的测试用例,使得被测程序中每个判定表达式至少获得一次“真”值和“假”值,从而使程序的每一个分支至少都通过一次。本题中程序有5个判定,所以满足判定覆盖一共需要10个逻辑条件,如下表所示。

中级软件评测师,章节冲刺,测试用例设计方法

6、本问题考查白盒测试用例设计方法中的基本路径法。涉及到的知识点包括:根据代码绘制控制流图、计算环路复杂度。

控制流图是描述程序控制流的一种图示方法。其基本符号有圆圈和箭线:圆圈为控制流图中的一个结点,表示一个或多个无分支的语句;带箭头的线段称为边或连接,表示控制流。基本结构如下所示:

中级软件评测师,章节冲刺,测试用例设计方法

根据题中程序绘制的控制流图如下所示。其中要特别注意的是,如果判断中的条件表达式是复合条件,即条件表达式是由一个或多个逻辑运算符连接的逻辑表达式,则需要改变复合条件的判断为一系列之单个条件的嵌套的判断。本题程序中,if (ranges[start].start_valueihg<=value&&value<(int)(ranges[start].start_value+range_size))这条判断语句中的判定由两个条件组成,因此在画控制流图的时候需要拆开成两条判断语句。

中级软件评测师,章节冲刺,测试用例设计方法

环路复杂度用来衡量一个程序模块所包含的判定结构的复杂程度,数量上表现为独立路径的条数,即合理地预防错误所需测试的最少路径条数。环路复杂度等于图中判定结点的个数加1,图中判定结点个数为6,所以(G)=7。

7、本问题考查白盒测试用例设计方法中的基本路径法。

(1) 1-2-3-4-2...

(2) 1-2-3-5-6-2...

(3) 1-2-3-5-7-13 l

(4) 1-2-8-9-10-11-13

(5) 1-2-8-9-10-12-13

(6) 1-2-8-9-12-13

(7) 1-2-8-12-13

你可能感兴趣的试题

单选题

Advancements in ( )have contributed to the growth of the automotive industry through the creation and evolution of self-driving vehicles.

  • A.Artificial Intelligence
  • B.Cloud Computing
  • C.Internet of Things
  • D.Big Data
查看答案
单选题

In project human resource management , ( )is not a source of power for the project manager.

  • A.referent power
  • B.expert power
  • C.reward power
  • D.audit power
查看答案
单选题

At the project establishment stage , the feasibility study mainly includes techinical feasibility analysis , ( ), operation environment feasibility analysis and other aspects of feasibility analysis.

  • A.detail feasibility analysis
  • B.opportunity analysis
  • C.economic feasibility analysis
  • D.risk analysis
查看答案
单选题

( )is a grid that shows the project resources assigned to each work package.

  • A.Stakeholder engagement assessment matrix
  • B.Requirements traceability matrix
  • C.Probability and impact matrix
  • D.Responsibility assignment matrix
查看答案
单选题

Xinhua News Agency reported in January 2022,Chian will further promote the developmet of a digital economy during the 14th Five-Year Plan eriod(2021-2025). The plan also emphasized industrial ( )transformation.

  • A.digital
  • B.networking
  • C.intelligentize
  • D.informatization
查看答案

相关题库更多 +