BICEP Unit Test Plan-arithmetic-test

Source: Internet
Author: User

One or 6 specific areas worth testing, they can improve your testing skills

    • Right-is the result correct?
    • B is all the boundary conditions correct?
    • Can I check the inverse association?
    • C-Can you cross-check the results with other means?
    • E-Can you force error conditions to occur?
    • P Whether meets performance requirements

Second, the test module

Test in the occurrence of multiplication method and addition and subtraction process, whether there will be non-conforming to the operational rules of the data, such as the occurrence of a divisor of 0, judging the program running data in other modules, in the test of this module, the data used in other modules to determine the data range (0-1000), and in the test process, Force a divisor of 0 error conditions, and make the meiosis greater than the meiosis, the divisor is greater than the divisor, the test difference appears negative and the quotient false score is correct

Third, the test plan

R, test whether the module is running correctly by entering representative data

B, referring to external conditions, random number generation scoping, you can avoid the original data is not within the scope of the situation

I, to determine whether the raw data is processed by checking the results of the generated data

C, by modifying the program parameters to meet the test requirements, check the results

E, test what happens to the module by forcing the error condition to occur

P, change the judging conditions, check whether the results meet the requirements

Iv. Test Code

1 //test. Cpp:defines the entry point for the console application.2 //3 /*there is a multiplication method to test the addition and subtraction of negative modules*/4#include"stdafx.h"5#include"stdlib.h"6#include"Iomanip.h"7#include"iostream.h"8#include"string"9 using namespacestd;Ten  One intMain () A { -     inta,b,c,d; -     stringjudge1="Y"; the     stringJudge2="Y"; -cout<<"allows the addition and subtraction of negative results, allowing the multiplication method to appear as a false score"<<Endl; -cout<<"Please enter two numbers randomly: space bar separated"<<Endl; -Cin>>a>>b; +cout<<"Please enter the operation to be tested (0: addition 1: Subtraction 2: Multiplication 3: Division)"<<Endl; -Cin>>C; +     /*Set Right Alignment*/ A cout.flags (ios::right); at     if((judge1=="Y"|| judge1=="y"))//Allow false Fractions -     { -         Switch(c)//randomly generated operators -         { -          Case 0: -COUT&LT;&LT;SETW (4) <<a<<'+'<<b<<'='; in              Break; -          Case 1: to             if(judge2=="Y"|| judge2=="y")//allow negative results to appear +             { -COUT&LT;&LT;SETW (4) <<a<<'-'<<b<<'='; the             } *             Else $             {Panax Notoginseng                 if(a>=b) -COUT&LT;&LT;SETW (4) <<a<<'-'<<b<<'='; the                 Else +COUT&LT;&LT;SETW (4) <<b<<'-'<<a<<'='; A             } the              Break; +          Case 2: -COUT&LT;&LT;SETW (4) <<a<<'*'<<b<<'='; $              Break; $          Case 3://To determine the conditions for division generation, the divisor cannot be zero -             if(a!=0&&b==0) -COUT&LT;&LT;SETW (4) <<b<<'/'<<a<<'='; the             Else if(a==0&&b!=0) -COUT&LT;&LT;SETW (4) <<a<<'/'<<b<<'=';Wuyi             Else if(a==0&&b==0) theCOUT&LT;&LT;SETW (4) <<a<<'/'<<b+1<<'='; -             Else WuCOUT&LT;&LT;SETW (4) <<a<<'/'<<b<<'='; -              Break; About         } $      -     } -     Else                                            //false scores are not allowed to appear -     { A         Switch(c) +         { the          Case 0: -COUT&LT;&LT;SETW (4) <<a<<'+'<<b<<'='; $              Break; the          Case 1: the             if(judge2=="Y"|| judge2=="y")//allow negative results to appear the             { theCOUT&LT;&LT;SETW (4) <<a<<'-'<<b<<'='; -             } in             Else the             { the                 if(a>=b) AboutCOUT&LT;&LT;SETW (4) <<a<<'-'<<b<<'='; the                 Else theCOUT&LT;&LT;SETW (4) <<b<<'-'<<a<<'='; the             } +              Break; -          Case 2: theCOUT&LT;&LT;SETW (4) <<a<<'*'<<b<<'=';Bayi              Break; the          Case 3://true score judgment the             if(a<=b&&b!=0) -COUT&LT;&LT;SETW (4) <<a<<'/'<<b<<'='; -             Else  theCOUT&LT;&LT;SETW (4) <<b<<'/'<<a<<'='; the              Break; the         } the     } -cout<<Endl; thecout<<"whether to continue is (1) No (0)"<<Endl; theCin>>D; the     if(d==1)94 main (); the     Else the         return 0; the}

V. Test results


Addition Test Results

Subtraction Test Results

Multiplication test Results

Division test results

VI. Analysis of test results

In the process of programming, each module should have a corresponding test module, in order to avoid the entire program, the problem is difficult to find or find the wrong place, in addition, writing test module, can help improve the whole program, is a good programming habit

BICEP Unit Test Plan-arithmetic-test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.