题目详情

使用在汽车、飞机中的嵌入式软件,由于直接影响人的生命及财产安全,测试要求更为严格。语句覆盖、判定覆盖、条件覆盖和MC/DC覆盖是通常对这类软件的要求。

以下是一段C语言代码,请仔细阅读,并回答相关问题:int logicTest(int x, int y){int magic=0;if(x>0 && y>0) {magic=x+y+10;}else{magic=x+y-10;}if(magic image.png 0){magic=0;}return magic;}

问题1:请根据测试要求,简要说明语句覆盖、判定覆盖、条件覆盖和MC/DC覆盖的含义。

问题2:画出以上代码的流程图。

问题3:请根据[说明]中的C语言代码,计算满足MC/DC覆盖要求的用例数量及条件取值范围

正确答案及解析

正确答案
解析

问题1:

中级嵌入式系统设计师,历年真题,案例分析

问题2:

中级嵌入式系统设计师,历年真题,案例分析

问题3:用例数量:3个;条件取值范围:(x>0 and y<=0)、(x<=0 and y>0)及(x>0 and y>0)

本问题考查MC/DC覆盖率判定的综合运用。MC/DC与代码中的逻辑运算有关。本题代码中的逻辑运算为x>0 &&y>0。根据MC/DC的定义,MC/DC覆盖要求每个条件的取值都有覆盖,每个判定值都有覆盖且每个条件都能独立影响判定结果。

对于a&&b这样的逻辑运算,真值表如下。

中级嵌入式系统设计师,历年真题,案例分析

对测试用例1和测试用例2,条件a不变,因为条件b的不同而导致结果的不同,因此条件b独立影响判定的结果。对测试用例2和测试用例3,因为条件b不变,条件a的不同而导致结果的不同,因此条件a独立影响判定的结果。

综合以上,对逻辑运算a&&b应产生三个测试用例,包括:(True,False)、(True,True)、(False,True)。所以本题用例数量:3个;条件取值范围:(x>0 and y<=0)、(x<=0 and y>0)及(x>0 and y>0)。

包含此试题的试卷

你可能感兴趣的试题

单选题

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
查看答案

相关题库更多 +