English 中文(简体)
基本范围——确切定义是什么?
原标题:Basic block coverage - what s the precise definition?

Let s say I have this piece of C/C++ code:

int c = 12; // Should I count this line as basic block?
if (a != 0 && b > 10) {
    c += (a + b);
} else {
    c += 1;
}
printf("%d", c); // Should I count this line as basic block?

试题a = 1, b = 12?

是75%还是50%?

我是否应该把第1行和最后一行作为基本内容? 基本块>的确切定义是什么?

另一个混淆点:

int c = 16;
d += c;

它是基本组成部分还是2个基本组成部分? 是否应当把每一条线都算作一个基本组成部分?

问题回答

基本单元包含所有有财产指示的,如果其中一人被处决,则同一基本区的所有其他人都是如此。 宣布基本部分的第一个指示如下: 我们下面对一个基本组成部分的定义是:如果领导人被处决,所有指示都是由一位领导人执行。 领导人是基本组成部分的开端。

确定领导人,在你们的法典中找到一切跳跃的指示。 每一个跳跃目标,每一个跳跃后的教学都是一位领导人。 第一项教学方法也是一位领导人。

To find the basic blocks simply go through all instructions from a leader to the next.

Your first example:

int c = 12; // Leader
if (a != 0 && b > 10) { // Jump
    c += (a + b); // Leader
} else {
    c += 1; // Leader
}
printf("%d", c); // Leader -- target of jump from the end of the true branch

您有4个基本区块:if各处各1个,fif之后各1个,c的初始化1个。 如果a = 1 && b = 12,只有3个基本区块得到执行,覆盖率为75%。

你的第二个例子没有跳跃升学 = ;只有一个基本障碍。





相关问题
Selenium not working with Firefox 3.x on linux

I am using selenium-server , selenium rc for UI testing in my application . My dev box is Windows with FireFox 3.5 and every thing is running fine and cool. But when i try to run selenium tests on my ...

Best browser for testing under Safari Mobile on Linux?

I have an iPhone web app I m producing on a Linux machine. What s the best browser I can use to most closely mimic the feature-limited version of Safari present on the iPhone? (It s a "slimmed down" ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Is there any error checking web app cralwers out there?

Wondering if there was some sort of crawler we could use to test and re-test everything when changes are made to the web app so we know some new change didn t error out any existing pages. Or maybe a ...