logo - 刷刷题
下载APP
【简答题】

已知C源程序如下:
/*Input today’s date,output tomorrow’s date * /
/* version 2 * /
#include<stdio. h>
struct ydate
int day; int month; int year;;
int leap(struct ydate d)
if((d. year%4==0&&d. year%100 ! =0)||(d. year%400==0))
return 1;
else
return 0;

int numdays(struct ydate d)
int day;
static int daytab[]=
31,28,31,30,31,30,3l,31,30,31,30,31;
if(1eap(d)&&d. month==2)
day=29;
else
day=daytabEd. month-1];
return day;

int main(void)
struct ydate today,tomorrow;printf("format of date is:year,month,day输入的年、月、日之间应用逗号隔开\n);
printf(" today is:");
scanf(“%d,%d.%",&today.year,&today.month,&today.day);
while(0>=today. year
|| today. year>65535||0>=today. month||today. month>12)||
0>=today. day||today. day>numdays(today))
printf("input date error!reenter the day!\n");
printf(" today is:");
scanf("%d,%d,%d",&today. year,&today.month,&today. day);

if(today. day!=numdays(today))
tomorrow. year=today. year;
tomorrow. month=today. month;
tomorrow. day=today. day+1;

else if(today.month==12)
tomorrow. year=today. year+1;
tomorrow. month=1;
tomorrow. day=1;

else
tomorrow. year=today. year;
tomorrow. month=today. month+1:
tomorrow.day=1;

printf("tomorrow is:%d,%d,%d\n\n",
tomorrow. year,tomorrow. month,tomorrow. day);

(1) 画出程序中所有函数的控制流程图;
(2) 设计一组测试用例,使该程序所有函数的语句覆盖率和分支覆盖率均能达到100%。如果认为该程序的语句或分支覆盖率无法达到100%,需说明为什么。

已知C源程序如下:
/*Input today’s date,output tomorrow’s date * /
/* version 2 * /
#include<stdio. h>
struct ydate
int day; int month; int year;;
int leap(struct ydate d)
if((d. year%4==0&&d. year%100 ! =0)||(d. year%400==0))
return 1;
else
return 0;

int numdays(struct ydate d)
int day;
static int daytab[]=
31,28,31,30,31,30,3l,31,30,31,30,31;
if(1eap(d)&&d. month==2)
day=29;
else
day=daytabEd. month-1];
return day;

int main(void)
struct ydate today,tomorrow;printf("format of date is:year,month,day输入的年、月、日之间应用逗号隔开\n);
printf(" today is:");
scanf(“%d,%d.%",&today.year,&today.month,&today.day);
while(0>=today. year
|| today. year>65535||0>=today. month||today. month>12)||
0>=today. day||today. day>numdays(today))
printf("input date error!reenter the day!\n");
printf(" today is:");
scanf("%d,%d,%d",&today. year,&today.month,&today. day);

if(today. day!=numdays(today))
tomorrow. year=today. year;
tomorrow. month=today. month;
tomorrow. day=today. day+1;

else if(today.month==12)
tomorrow. year=today. year+1;
tomorrow. month=1;
tomorrow. day=1;

else
tomorrow. year=today. year;
tomorrow. month=today. month+1:
tomorrow.day=1;

printf("tomorrow is:%d,%d,%d\n\n",
tomorrow. year,tomorrow. month,tomorrow. day);

(1) 画出程序中所有函数的控制流程图;
(2) 设计一组测试用例,使该程序所有函数的语句覆盖率和分支覆盖率均能达到100%。如果认为该程序的语句或分支覆盖率无法达到100%,需说明为什么。

参考答案:
参考解析:
.
刷刷题刷刷变学霸
举一反三

【单选题】测试用例是一组()。

A.
测试用的输入数据以及对应的预期结果
B.
测试驱动程序
C.
测试数据
D.
测试程序及数据