一、测试方法(Right-BICEP
6个值得测试的具体部位:
Right-结果是否正确?
B-是否所有的边界条件都是正确的?
I-能查一下反向关联吗?
C-能用其他手段交叉检查一下结果吗?
E-你是否可以强制错误条件发生?
P-是否满足性能要求?
二、测试部分
  检查链表中是否和刚刚出的题目重复:
  该模块源代码如下:
//***********检查链表中的数据是否有重复***********//
int repeat(LinkList L,equation N)//函数返回值是1的话有重复,返回值是0的话无重复
{
    int flag=0;//如果有重复的则flag=1,否则为0
    LNode *temp;
    temp=L->next;
    if(L->next==NULL)//若链表为空
        return flag;
    while(temp!=NULL)//若链表不为空
    {
        if((temp->first_operand==N.first)&&(temp->second_operand==N.second)&&(temp->operat==N.ope))//如果有重复的话
        {
            flag=1;
            break;
        }
        temp=temp->next;
    }
    return flag;
}

  测试代码如下:

// 单元测试.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<iostream.h>
#include<time.h>
#include<stdlib.h>
typedef struct
{
    int first;
    int second;
    char ope;
}equation;
//***********链表的数据结构***********//
typedef struct LNode
{
    int first_operand;
    int second_operand;
    char operat;
    struct LNode *next;
}LNode,*LinkList;
//**********链表初始化***********//
void InitList_L(LinkList &L)
{
    L=new LNode;
    L->next=NULL;
}
//***********检查链表中的数据是否有重复***********//
int repeat(LinkList L,equation N)//函数返回值是1的话有重复,返回值是0的话无重复
{
    int flag=0;//如果有重复的则flag=1,否则为0
    LNode *temp;
    temp=L->next;
    if(L->next==NULL)//若链表为空
        return flag;
    while(temp!=NULL)//若链表不为空
    {
        if((temp->first_operand==N.first)&&(temp->second_operand==N.second)&&(temp->operat==N.ope))//如果有重复的话
        {
            flag=1;
            break;
        }
        temp=temp->next;
    }
    return flag;
}
//***********链表的输出***********//
void input_L(LinkList L,int m)//m,是每行的列数,n是每行的间隔
{
    LNode *head;
    head=L->next;
    int temp=0;
    while(head!=NULL)
    {
        cout<<head->first_operand<<head->operat<<head->second_operand<<"=\t";//数据的输出
        temp++;
        head=head->next;
        if(temp%m==0)//打印方式(列数)
        {
            cout<<endl;
        }
    }
}
int main()
{
    int i;
    int flag=0,flag1=1;
    equation N;
    LinkList L;
    InitList_L(L);
    LNode *head;
    head=L;
    
    cout<<"现在往链表中插入数据:"<<endl;
    for(i=0;i<3;i++)//往链表中插入三个算式
    {
        LNode *temp;
        temp=new LNode;
        cout<<"请输入第"<<i+1<<"个式子:"<<endl;
        cin>>temp->first_operand>>temp->operat>>temp->second_operand;
        temp->next=NULL;
        head->next=temp;
        head=head->next;
    }
    cout<<"链表中的数据是:"<<endl;
    input_L(L,3);
    while(flag1==1)
    {
        cout<<"请在输入一个算式:"<<endl;
        cin>>N.first>>N.ope>>N.second;
        flag=repeat(L,N);
        if(flag==1)
            cout<<"链表中有重复的算式!"<<endl;
        else if(flag==0)
            cout<<"链表中没有重复的算式"<<endl;
        cout<<"是否继续检验程序(是/1,否/0)";
        cin>>flag1;
    }
    return 0;
}
三、测试计划

  1.通过自己手动输入题目,查看结果是否正确。

  2.改变算式中数字的大小,再通过手动输入算式,查看结果是否正确。

  3.再插入链表中数据后,将链表的数据全部输出查看。

  4.通过增加链表中的数据,重新检查。

  5.故意输入错误参数,看是否正常运行。

四、测试步骤
  1.往链表里简单的插入三个数据,然后依次检查是否有重复:
  
  2.改变数据的大小,重新一次检查,看是否有重复的:
     
  3.改变数的范围,检查是否有重复
  
  
   
  
   
  
  
posted on 2015-03-16 18:13  梦里侃花落  阅读(162)  评论(0编辑  收藏  举报