/* PASSFAIL: print out pass (>=45)/fail(<45)/pass distinction(>=81) on a score Note: should also verify input 0..100 but not that the code does not check this - bug. */ /* 1. FLOWGRAPH: R1 enter artificial 1 . . . . . . . . |a . v . . 2 . | . +-------+-------+ . b | F T | c . v v . R2 . 4 3 . . d | | e . +-----> 5 <-----+ . | R3 . i + ------+ . | T | g . |F v . f | . | R4 6 . v . | h . 7 <-----+ . exit . . . . . . 2. CYCLOMETRIC COMPLEXITY: Predicates (2) + 1 = Edges (9) - Nodes (7) + 1 = Regions (4) - 1 = 3 3. BASIS SET OF CYCLES: 1. 1-2-4-5-6-7-1 PASS WITH DISTINCTION 2. 1-2-3-5-7-1 FAIL 3. 1-2-4-5-7-1 PASS Note: The following is NOT a basis cycle because it is not independent: 4. 1-2-3-5-6-7-1 Proof: Consider nine edges: a,b,c,d,e,f,g,h,i a b c d e f g h i In Cycle 1: : (1 1 0 1 0 0 1 1 1) In Cycle 2: : +(1 0 1 0 1 1 0 0 1) In Cycle 3: : -(1 1 0 1 0 1 0 0 1) ----------------- In Cycle 4: : =(1 0 1 0 1 0 1 1 1) Cycle 4 = Cycle 1 + Cycle 2 - Cycle 3 Note: This path is also INFEASIBLE: FAIL WITH DISTINCTION 4. 1-2-3-5-6-7-1 4. LINEARLY INDEPENDENT PATHS 5. FEASABLE (YES/NO) 6. TEST CASES 7. RESULT (score) (printf) 1. 1-2-4-5-6-7 YES 85 PASS WITH DISTINCTION 2. 1-2-3-5-7 YES 40 FAIL 3. 1-2-4-5-7 YES 60 PASS Note: Although this white box strategy did 100% path coverage, it did not meet the specification. It did not test for 0..100. An input of 120 would pass the test. A BLACK BOX test of 4 different values (40, 60, 85, 110) would have discovered the problem. Therefore, even with 100% path coverage, no white box testing strategy on its own can guarantee adequate software testing. See passfail.bat */ #include int debug = 0; #define PASS 45 #define DISTINCTION 81 #define MIN 0 #define MAX 100 /* instrumentation for the line #'s*/ int L(int i) { if (debug) printf("%d-",i); return 1; } void passfail() { int score; L(1); scanf("%d ",&score); if (L(2)&&(score=DISTINCTION)) { L(6); printf(" WITH DISTINCTION "); } L(7); printf("\n"); } int main(int argc, char *argv[]) { int a, b, c; if (argc > 1) { debug = 1; printf("Path : "); } passfail(); }