Program Graph is here.
1 get item 2 if item is numeric 3 print 'NUMERIC' 4 if item < 0 5 print 'NEGATIVE' 6 endif else 7 print 'NON-NUMERIC' 8 endif 9 print item Cyclomatic Number = 10 - 9 + 2 = 3 Independent Paths: i) 1, 2, 7, 8, 9 ii) 1, 2, 3, 4, 6, 8, 9 iii) 1, 2, 3, 4, 5, 6, 8, 9 Minimum Test Set: i) Non-numeric item ii) Numeric item, positive value iii) Numeric item, negative value
Pseudocode B:
Program Graph is here.
1 countline = 0 1 get first line in file 2 do while file not empty 3 countline = countline + 1 3 total = 0 3 get first number on line 4 do while not end of line 5 total = total + number 5 get next number on line 6 enddo 7 print total 8 if total > 1000000 9 print 'BIG TOTAL' 10 endif 11 get next line in file 12 enddo 13 print countline Cyclomatic Number = 15 - 13 + 2 = 4 Independent Paths: i) 1, 2, 12, 13 ii) 1, 2, 3, 4, 6, 7, 8, 10, 11, 2, 12, 13 iii) 1, 2, 3, 4, 5, 4, 6, 7, 8, 9, 10, 11, 2, 12, 13 iv) 1, 2, 3, 4, 5, 4, 6, 7, 8, 10, 11, 2, 12, 13 Minimum Test Set: i) Empty file ii) Non-empty file, blank line iii) Non-empty file, non-blank line, big total iv) Non-empty file, non-blank line, small total
Pseudocode C:
Program Graph is here.
1 count = 0 1 get flag 2 if flag is FILE 3 print 'FILE' 3 get first item from file 4 do while not end of file 5 count = count + 1 5 print item 5 get next item from file 6 enddo else 7 print 'LIST' 7 get first item from list 8 do while not end of list 9 count = count + 1 9 print item 9 get next item from list 10 enddo 11 endif 12 print count Cyclomatic Number = 14 - 12 + 2 = 4 Independent Paths: i) 1, 2, 3, 4, 6, 11, 12 ii) 1, 2, 3, 4, 5, 4, 6, 11, 12 iii) 1, 2, 7, 8, 10, 11, 12 iv) 1, 2, 7, 8, 9, 8, 10, 11, 12 Minimum Test Set: i) flag set to FILE, empty file ii) flag set to FILE, non-empty file iii) flag not set to FILE, empty list iv) flag not set to FILE, non-empty list