You are on page 1of 17

Experiment

3 Decision Table

Student ID: 201936020140 Name:MPIANA DIEUDONNE KABWANGA

1. Triangle problem

Experiment Content
Design and develop a program in a language of your choice to solve the triangle problem
defined
as follows: Accept three integers which are supposed to be the three sides of a triangle and
determine if the three values represent an equilateral triangle, isosceles triangle, scalene triangle,
or they do not form a triangle at all. Assume that the upper limit for the size of any side is 10.
Derive test cases for your program based on boundary value analysis, execute the test cases and
discuss the results.

It receive three integers a, b, c as input. If a, b, c satisfy these conditions below:


C1. 1≤a ≤200 C4. a < b + c
C2. 1≤b ≤200 C5. b < a + c
C3. 1≤c ≤200 C6. c < a + b
Four possible outputs:
Not a Triangle
Scalene
Isosceles
Equilateral

Algorithm

Step 1: Input a, b & c i.e. three integer values which represent three sides of the triangle.
Step 2: if (a < (b + c)) and (b < (a + c)) and (c < (a + b) then do step 3 else print not a triangle.
do step 6.
Step 3: if (a=b) and (b=c) then Print triangle formed is equilateral. do step 6.
Step 4: if (a ≠ b) and (a ≠ c) and (b ≠ c) then Print triangle formed is scalene. do step 6.
Step 5: Print triangle formed is Isosceles
Step 6: stop

Program Code

def triangle():
    print('enter value for a: ')
    a = int(input())
    print('enter value for b: ')
    b = int(input())
    print('enter value for c: ')
    c = int(input())

    if((a>10) | (b>10) | (c>10)):
        print('out of range')
        exit()
    if((a<b+c) & (b<a+c) & (c<a+b)):
        if((a==b) & (b==c)):
            print('Equilateral triangle')
        elif ((a!=b) & (a!=c) & (b!=c)):
            print('Scalene triangle')
        else:
            print('Isosceles triangle')
    else:
        print('Triangle cannot be found')
triangle()
COLLEGE OF MC―--Department of SE--- Experiment Report of Software Quality Assurance and Testing

Test Design and Test Cases

Test Data: Enter the 3 Integer Value(a, b And c)


Pre-condition: 1 ≤ a ≤ 1 1 ≤ b ≤0,1 a 1 ≤ c ≤ 1 a 0a < b nd
+c b<a+ca c<a0 nd
+b
Brief Description: Check whether given value for an Equilateral, Isosceles, Scalene
triangle or can't form a triangle

conditions Rule1 Rule2 Rule3 Rule4 Rule5 Rule6 Rule7 Rule8 Rule9 Rule10
C1: a < b + c T T T F T T T T T T

C2: b < a + c T T T T T T T T T T

C3: c < a + b F T F T T T T T F T

C4: a = b F T F F T F T F F F
C5: a = c F T F F F T T F F F
C6: b = c F T F F F T T F F F
A1: Not a triangle X X
A2: scalene X X X
A3: isosceles X X
A4: equilateral X X
A5: impossible X

TEST CASES FOR THE TRIANGLE PROBLEM

Expected
Case ID a b c
Output
DT1 1 2 3 Not a Triangle
DT2 1 1 1 Equilateral
DT3 9 8 5 Scalene
DT4 10 1 0 Out of Range
DT5 2 2 3 Isosceles
DT6 4 5 4 Isosceles
DT7 8 8 8 Equilateral

3 / 17
DT8 7 5 3 Scalene
DT9 1 5 8 Not a Triangle
DT10 5 6 8 Scalene

Rule Counting
c1: a<b+c? T T T F T T T T T T
c2: b<a+c? T T T T T T T T T T
c3: c<a+b? F T F T T T T T F T
c4: a = b? F T F F T F T F F F
c5: a = c? F T F F F T T F F F
c6: b = c? F T F F F T T F F F
Rule count 16 1 1 1 1 1 1 1 8 1
a 1 : N o t a
X            X  
triangle
a2: Scalene      X         X    X 
a3: Isosceles          X X    
a4: Equilateral    X        X      
a5: Impossible       X       

Testing Executing and Test Result


Summary
Decision table is based on logical relationships just as the truth table. It is a tool that
helps us look at the “complete” combination of conditions
• Conditions are interpreted as
• Input
• Equivalence classes of inputs
• Actions are interpreted as
• Output
• Major functional processing portions
• Complete decision tables
• Complete set of test cases
• Advantages:
• A l l o w u s t o s t a r t w i t h a “ c o m p l e t e ” v i e w, w i t h n o c o n s i d e r a t i o n o f
dependence
• Allow us to look at and consider “dependence,” “impossible,” and
“not relevant” situations and eliminate some test cases.
• Allow us to detect potential error in our specifications
• Disadvantages:
• Need to decide (or know) what conditions are relevant for testing
• Scaling up can be massive: 2n for n conditions.

Experiment 3 Next Date

Experiment Content
Design, develop, code and run the program in any suitable language to implement the
Next Date
function. Analyze it from the perspective of boundary value testing, derive different
test cases,
execute these test cases and discuss the test results.

NextDate Function(1812≤year≤2012)
NextDate is a function has three variables (month, day, and year), for years from 1812
to 2012.
it return the next date which user input. Month, day and year are all integer, and
satisfy these
conditions below:
1 ≤ month ≤ 12
1 ≤ day≤ 31
1812 ≤ year ≤ 2012Equilateral
Algorithm
STEP 1: Input date in format DD.MM.YYYY
STEP2: if MM is 01, 03, 05,07,08,10 do STEP3 else STEP6
S T E: P i3 f D D < 3 1 t h e n d o S T E P 4 e l s e i f D D =
output(InvalidDate);
STEP4: tomorrowday=DD+1 goto STEP18
STEP5: tomorrowday=1; tomorrowmonth=month + 1 goto STEP18
STEP6: if MM is 04, 06, 09, 11 do STEP7
STEP7: if DD<30 then do STEP4 else if DD=30 do STEP5 else output(InvalidDate);
STEP8: if MM is 12
STEP9: if DD<31 then STEP4 else STEP10
STEP10: tomorrowday=1, tommorowmonth=1, tommorowyear=YYYY+1; goto
STEP18
STEP11: if MM is 2
STEP12: if DD<28 do STEP4 else do STEP13
STEP13: if DD=28 & YYYY is a leap do STEP14 else STEP15
STEP14: tommorowday=29 goto STEP18
STEP15: tommorowday=1, tomorrowmonth=3, goto STEP18;
STEP16: if DD=29 then do STEP15 else STEP17
STEP17: output(“Cannot have feb”, DD); STEP19
STEP18: output(tomorrowday, tomorrowmonth, tomorrowyear);
STEP19: exit

Program Code
PROGRAM CODE:
year = int(input("Input a year: "))

if (year % 400 == 0):
    leap_year = True
elif (year % 100 == 0):
    leap_year = False
elif (year % 4 == 0):
    leap_year = True
else:
    leap_year = False

month = int(input("Input a month [1-12]: "))
if month in (1, 3, 5, 7, 8, 10, 12):
    month_length = 31
elif month == 2:
    if leap_year:
        month_length = 29
    else:
        month_length = 28
else:
    month_length = 30

day = int(input("Input a day [1-31]: "))

if day < month_length:
    day += 1
else:
    day = 1
    if month == 12:
        month = 1
        year += 1
    else:
        month += 1
print("The next date is [yyyy-mm-dd] %d-%d-%d." % (year, month, day))

Test Design and Test Cases

The conditions are


C1: 1 ≤ month ≤ 12
C2: 1 ≤ day ≤ 31
C3: 1812 ≤ year ≤ 2012
Thus based on valid values, the equivalence classes are:

M1 = {month: month has 30 days}


M2 = {month: month has 31 days}
M3 = {month: month is February}
D1 = {day: 1 ≤ day ≤ 28}
D2 = {day: day = 29}
D3 = {day: day = 30}
D4 = {day: day = 31}
Y1 = {year: year = 2000}
Y2 = {year: year is a non-century leap year}
Y3 = {year: year is a common year}

NOTE: Because a month is in an equivalence class, we cannot have T in more than


one entry; the “do not care entries” are really F

NextDate: final version

CONDITIONS R1 R2 R3
C1: month in M1 T - -
C2: month in M2 - T -
C3: month in M3 - - T
A1: impossible
A2: Next Date
NextDate Decision Table (first half)
M1: 30 days months, M2: 31 days months, M3: Dec, M4: Feb
D1: 1~27, D2: 28, D3: 29, D4: 30, D5: 31
Y1: leap year, Y2: common year

  1 2 3 4 5 6 7 8 9 10

c 1 : m o n t hM1 M1 M1 M1 M1 M2 M2 M2 M2 M2
in

c2: day in D1 D2 D3 D4 D5 D1 D2 D3 D4 D5

c3: year in — — — — — — — — — —

a1:         X          
impossible

a2: X X X     X X X X  
increment
day

a 3 : r  e s  e t   X           X
day

a4:       X           X
increment
month

a 5 : r  e s  e t                
month

a6:                    
increment
year

NextDate Decision Table (second half)


M1: 30 days months, M2: 31 days months, M3: Dec, M4: Feb
D1: 1~27, D2: 28, D3: 29, D4: 30, D5: 31
Y1: leap year, Y2: common year
  11 12 13 14 15 16 17 18 19 20 21 22

c1: month M3 M3 M3 M3 M3 M4 M4 M4 M4 M4 M4 M4
in

c2: day in D1 D2 D3 D4 D5 D1 D2 D2 D3 D3 D4 D5

c3: year in — — — — — — Y1 Y2 Y1 Y2 — —

a1:                   X X X
impossibl
e

a2: X X X X   X X          
increment
day

a3: reset         X     X X      
day

a4:               X X      
increment
month

a5: reset         X              
month

a6:         X              
increment
year

NextDate Test Cases

Test Case Rule(s) Month Day Year Expected Output

1 1– 3 4 15 2001 4/16/2001

2 4 4 30 2001 5/1/2001

3 5 4 31 2001 Invalid Input Date

4 6–9 1 15 2001 1/16/2001

5 10 1 31 2001 2/1/2001
6 11–14 12 15 2001 12/16/2001

7 15 12 31 2001 1/1/2002

8 16 2 15 2001 2/16/2001

9 17 2 28 2004 2/29/2004

10 18 2 28 2001 3/1/2001

NexDate: the first try


NextDate: a second try
NextDate: second try, first part

NextDate: second try, second part


NextDate: third try

NextDate: third try first part


NextDate: third try second part

Summary

The NextDate problem illustrates the correspondence between equivalence classes


and decision table structure
The NextDate problem illustrates the problem of dependencies in the input
domain
Decision tables can highlight such dependencies
Impossible dates can be clearly marked as a separate action
The next date problem has constraints one of which deals with the value of the
month
Condition 1 : 1<=month <=12
Condition 2 : month < 12
Condition 3 : month >12

Decision table is based on logical relationships just as the truth table. It is a tool that
helps us look at the “complete” combination of conditions

• Conditions are interpreted as


• Input
• Equivalence classes of inputs
• Actions are interpreted as
• Output
• Major functional processing portions
• Complete decision tables
• Complete set of test cases
• Advantages:
• A l l o w u s t o s t a r t w i t h a “ c o m p l e t e ” v i e w, w i t h n o c o n s i d e r a t i o n o f
dependence
• Allow us to look at and consider “dependence,” “impossible,” and
“not relevant” situations and eliminate some test cases.
• Allow us to detect potential error in our specifications
• Disadvantages:
• Need to decide (or know) what conditions are relevant for testing
• Scaling up can be massive: 2n for n conditions.

You might also like