1、计算器黑盒测试实验报告西南科技大学计算机学院实验报告实 验 名 称 计算器黑盒测试 实 验 地 点 实 验 日 期 指 导 教 师 学 生 班 级 学 生 姓 名 学 生 学 号 提 交 日 期 软件教研室制一、测试目的设计测试用例、使用各种测试方法进行计算器的测试,并对测试结果进行分析二、测试内容1.软件说明:实现一个小的计算器程序,只需要完成加、减、乘、除运算 ,设计测试用例,并对测试结果进行分析,同时计算器运行稳定。2、设计测试用例3、执行测试 4、测试结果分析5、源代码三、测试步骤 (一)、计算器界面2、设计测试用例(1)等价类测试:1、4个等价类测试用例的分析过程如下:测试用例加减乘
2、除预期输出整型55+5078-2415*2536/4正常运算小数25.3+12.714.3-11.725.6*12.850.2/20.7正常运算负数-20+-21(-15)-(-14)-12*-12-16/-5正常运算无效输入E1+t2G4-k5I5*l6Ff/se非法操作无法输入2、对应测试的结果分析:整型:1.加(55+50)2.减(78-24) 3.乘(15*25) 4.除(36/4) 小数1.加(25.3+12.7) 2.减(14.3-11.7) 3.乘(25.6*12.8) 4.除(50.2/20.7) 负数6.加 -20+-21 7.减(-15)-(-14) 8.乘-12*-12
3、9.除 -16/-5 (其中算式写法错误导致正常运算错误)无效输入1加(E1+t2):程序中无效数字无法正常输入,程序无法进行。2减(G4-k5)程序中无效数字无法正常输入,程序无法进行。(同上)3乘(I5*l6)程序中无效数字无法正常输入,程序无法进行。(同上)4除(Ff/se)程序中无效数字无法正常输入,程序无法进行。(同上)5(2)边界值法设计测试:加法:1、计算器4个标准等价类测试用例的分析过程如下:测试用例被加数加数预期输出Test1010正常运算Test2110正常运算Test34010正常运算Test455.510正常运算Test5-7010正常运算Test61010正常运算Te
4、st710110正常运算Test8100不能运算Test9101正常运算Test101040正常运算Test111055.5正常运算Test1210-78正常运算Test1310100正常运算Test1410101正常运算2、对应测试与结果:测试结果运算均属正常,对应的部分的示图如下:Test1结果:Test2结果:Test3结果:Test4结果:Test5结果:Test6结果:减法:1、计算器4个标准等价类测试用例的分析过程如下:测试用例被减数减数预期输出Test1010正常运算Test2110正常运算Test34010正常运算Test455.510正常运算Test5-7810正常运算Tes
5、t610010正常运算Test710110正常运算Test8100不能运算Test9101正常运算Test101040正常运算Test111055.5正常运算Test1210-78正常运算Test1310100正常运算Test1410101正常运算2、对应测试与结果:测试结果运算均属正常,对应的部分的示图如下:Test1结果:Test3结果:Test4结果:Test5结果:Test6结果:乘法1、计算器4个标准等价类测试用例的分析过程如下:测试用例被乘数乘数预期输出Test1050正常运算Test215正常运算Test32410正常运算Test455.510正常运算Test5-7810正常运算
6、Test610010正常运算Test710110正常运算Test8100不能运算Test9101正常运算Test101040正常运算Test111055.5正常运算Test1210-78正常运算Test1310100正常运算Test1410101正常运算2、对应测试与结果:测试结果运算均属正常,对应的部分的示图如下:Test1结果:Test3结果:Test4结果:Test5结果:Test6结果:除法1、计算器4个标准等价类测试用例的分析过程如下:测试用例被除数除数预期输出Test1010正常运算Test2110正常运算Test34010正常运算Test455.510正常运算Test5-7810
7、正常运算Test610010正常运算Test710110正常运算Test8100正常运算Test9101正常运算Test101040正常运算Test111055.5正常运算Test1210-78正常运算Test1310100正常运算Test1410101正常运算2、对应测试与结果:对应的部分的示图如下:Test1结果:Test2结果:Test3结果:Test8结果:附录:源代码CCalculateDlg:CCalculateDlg(CWnd* pParent /*=NULL*/) : CDialog(CCalculateDlg:IDD, pParent) /AFX_DATA_INIT(CCal
8、culateDlg) m_parameter = 0.0; /AFX_DATA_INIT / Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()-LoadIcon(IDR_MAINFRAME); CalculatePara = 0; CalculateResult = 0; Ispoint = false; Sumpoint = 0;void CCalculateDlg:DoDataExchange(CDataExchange* pDX) CDialog:DoDa
9、taExchange(pDX); /AFX_DATA_MAP(CCalculateDlg) DDX_Text(pDX, IDC_EDIT, m_parameter); /AFX_DATA_MAPBEGIN_MESSAGE_MAP(CCalculateDlg, CDialog) /AFX_MSG_MAP(CCalculateDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_clear, Onclear) ON_BN_CLICKED(IDC_calculate, Oncalculate) ON
10、_BN_CLICKED(IDC_para1, Onpara1) ON_BN_CLICKED(IDC_para2, Onpara2) ON_BN_CLICKED(IDC_para3, Onpara3) ON_BN_CLICKED(IDC_para4, Onpara4) ON_BN_CLICKED(IDC_para5, Onpara5) ON_BN_CLICKED(IDC_para6, Onpara6) ON_BN_CLICKED(IDC_para7, Onpara7) ON_BN_CLICKED(IDC_para8, Onpara8) ON_BN_CLICKED(IDC_para9, Onpar
11、a9) ON_BN_CLICKED(IDC_para0, Onpara0) ON_BN_CLICKED(IDC_point, Onpoint) ON_BN_CLICKED(IDC_minus, Onminus) ON_BN_CLICKED(IDC_plus, Onplus) ON_BN_CLICKED(IDC_subtrack, Onsubtrack) ON_BN_CLICKED(IDC_multiply, Onmultiply) ON_BN_CLICKED(IDC_divide, Ondivide) /AFX_MSG_MAPEND_MESSAGE_MAP()/ CCalculateDlg m
12、essage handlersBOOL CCalculateDlg:OnInitDialog() CDialog:OnInitDialog(); / Add About. menu item to system menu. / IDM_ABOUTBOX must be in the system command range. ASSERT(IDM_ABOUTBOX & 0xFFF0) = IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX AppendMenu(MF_SEPARATOR); pSysMenu-AppendMenu(MF_STRING, IDM_ABOUTBOX
13、, strAboutMenu); / Set the icon for this dialog. The framework does this automatically / when the applications main window is not a dialog SetIcon(m_hIcon, TRUE); / Set big icon SetIcon(m_hIcon, FALSE); / Set small icon / TODO: Add extra initialization here return TRUE; / return TRUE unless you set
14、the focus to a controlvoid CCalculateDlg:OnSysCommand(UINT nID, LPARAM lParam) if (nID & 0xFFF0) = IDM_ABOUTBOX) CAboutDlg dlgAbout; dlgAbout.DoModal(); else CDialog:OnSysCommand(nID, lParam); / If you add a minimize button to your dialog, you will need the code below/ to draw the icon. For MFC appl
15、ications using the document/view model,/ this is automatically done for you by the framework.void CCalculateDlg:OnPaint() if (IsIconic() CPaintDC dc(this); / device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); / Center icon in client rectangle int cxIcon = GetSys
16、temMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; / Draw the icon dc.DrawIcon(x, y, m_hIcon); else CDialog:OnPaint(); / The system calls this to obtain the cursor to di
17、splay while the user drags/ the minimized window.HCURSOR CCalculateDlg:OnQueryDragIcon() return (HCURSOR) m_hIcon;void CCalculateDlg:Onclear() UpdateData(true); m_parameter = 0; CalculatePara = 0; CalculateResult = 0; Ispoint = false; Sumpoint = 0; UpdateData(false);/ TODO: Add your control notifica
18、tion handler code here void CCalculateDlg:Oncalculate() UpdateData(true); CalculatePara = m_parameter; switch(CalculateExpre) case+: CalculateResult += CalculatePara; m_parameter = CalculateResult; break; case-: CalculateResult -= CalculatePara; m_parameter = CalculateResult; break; case*: Calculate
19、Result *= CalculatePara; m_parameter = CalculateResult; break; case/: if (CalculatePara) CalculateResult /= CalculatePara; m_parameter = CalculateResult; else m_parameter = 0; MessageBox(除数不能为零!); break; / TODO: Add your control notification handler code here CalculatePara = 0; CalculateResult = 0;
20、Ispoint = false; Sumpoint = 0; UpdateData(false); void CCalculateDlg:Onpara1() UpdateData(true); if (!Ispoint) CalculatePara = m_parameter*10 + 1; else CalculatePara = m_parameter + 1/pow(10,Sumpoint); Sumpoint+; m_parameter = CalculatePara; UpdateData(false);/ TODO: Add your control notification ha
21、ndler code here void CCalculateDlg:Onpara2() UpdateData(true); if (!Ispoint) CalculatePara = m_parameter*10 + 2; else CalculatePara = m_parameter + 2/pow(10,Sumpoint); Sumpoint+; m_parameter = CalculatePara; UpdateData(false);/ TODO: Add your control notification handler code here void CCalculateDlg
22、:Onpara3() UpdateData(true); if (!Ispoint) CalculatePara = m_parameter*10 + 3; else CalculatePara = m_parameter + 3/pow(10,Sumpoint); Sumpoint+; m_parameter = CalculatePara; UpdateData(false);/ TODO: Add your control notification handler code here void CCalculateDlg:Onpara4() UpdateData(true); if (!
23、Ispoint) CalculatePara = m_parameter*10 + 4; else CalculatePara = m_parameter + 4/pow(10,Sumpoint); Sumpoint+; m_parameter = CalculatePara; UpdateData(false);/ TODO: Add your control notification handler code here void CCalculateDlg:Onpara5() UpdateData(true); if (!Ispoint) CalculatePara = m_paramet
24、er*10 + 5; else CalculatePara = m_parameter + 5/pow(10,Sumpoint); Sumpoint+; m_parameter = CalculatePara; UpdateData(false);/ TODO: Add your control notification handler code here void CCalculateDlg:Onpara6() UpdateData(true); if (!Ispoint) CalculatePara = m_parameter*10 + 6; else CalculatePara = m_
25、parameter + 6/pow(10,Sumpoint); Sumpoint+; m_parameter = CalculatePara; UpdateData(false);/ TODO: Add your control notification handler code here void CCalculateDlg:Onpara7() UpdateData(true); if (!Ispoint) CalculatePara = m_parameter*10 + 7; else CalculatePara = m_parameter + 7/pow(10,Sumpoint); Su
26、mpoint+; m_parameter = CalculatePara; UpdateData(false);/ TODO: Add your control notification handler code here void CCalculateDlg:Onpara8() UpdateData(true); if (!Ispoint) CalculatePara = m_parameter*10 + 8; else CalculatePara = m_parameter + 8/pow(10,Sumpoint); Sumpoint+; m_parameter = CalculatePara; UpdateData(false);/ TODO: Add your control notification handler code here void CCalculateDlg:Onpara9()
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1