|
下面代码是从就业培训辅导教材《软件测试技术概论》中,第四章P52页摘出来的,
想请教老师同学们,这个例子想说明断言检测的啥呢?红色字体的部分,可以大致解释下吗?
先谢过了。:)
unsigned int Dev(int num1,int num2,int &ref)
{
int val1,val2,k=0;
val1 = num1;
val2 = num2;
while((val1-val2) > 0)
{
val1 = val1 - val2;
k++;
}
ref = val1;
return k;
}
unsigned int Dev(int num1,int num2,int &ref)
{
int val1,val2,k=0;
val1 = num1;
val2 = num2;
_ASSERT(num1 >= 0);
_ASSERT(num2 >= 0);
while((val1-val2) > 0)
{
val1 = val1 - val2;
k++;
_ASSERT(num2 * k + val1 == num1);
}
ref = val1;
_ASSERT(ref < num2);
return k;
} |
|