CS 1704 - Summer II 2003

Assignment 1


Directions:

Answer the following in a Microsoft Word compatible document.  Show work for partial credit.  

Questions:

Short answer #1:  What is regression testing? Why is it important?

Regression testing is the principle by which once a piece of the software has been tested and a new piece added, all tests done on the first piece are redone on the first piece before testing the new piece.  In other words, every time a new piece is added, all tests on all previous pieces are re-run.  This is important because it ensures that the any new code written hasn't broken old code or produced side affects that are undesirable in the old code.

Short answer #2:  Lets say you are interested in doing Multiple Condition Coverage for a decision that had 6 conditions. How many test cases would you have to supply?

Each condition has two states, and there are 6 conditions.  This uses 2^6=64

Short answer #3:  Calculate the Cyclomatic Complexity of the following code:

class Foo {
      public:
void example() {Node Start, edge to Node 1
                if (a == b) {   Node 1
   
             Edges to 4,2
                    if (a1 == b1) {Node 2
                Edges to 3, end

                       do something;
                    } else if (a2 == b2) {Node 3
                Edge to end

                        do something;
                    } else { 
                Edge to end
                        do something; 
                    }
                } else if (c == d) {Node 4
                Edge to 5, 6

                     while (c == d) {Node 5
                         do something;Looped Edge to 5
                      }
                Edge to end
                } else if (e == f) { Node 6
                Edge to 7, 8

                    for (int n = 0; n < h; n++) {Node 7
                         do something;Looped Edge to 7
                    }
                Edge to end
                } else {
                    switch (z) { 
                        case 1: do something; break;Node 8, edge to 9, end
                        case 2: do something; break;Node 9, edge to 10, end
                        case 3: do something; break;Node 10, edge to end via default, edge to end
                        default: do something; break;
                    }
                }
} End Node
}21 edges - 12 nodes + 2

CC=11

Short answer #4: For the code above, assume that "do something" is a valid command and that a, b, a1, b1, a2, b2, c, d, e, f, h, and z are defined as private.  Also, assume that a valid constructor and destructor have been included.  In the code above, find 2 errors.  At least one will be a design error.

        a.) The ";" is missing from the end of the class.
        b.) Since the code is inlined in the interface, the concept of data hiding has been violated.
        c.) There are others...the way public is declared, the class isn't public, etc.  This is actually Java code:)

Short answer #5:  Determine the output of the following code.  DO NOT COMPILE AND/OR RUN.
        #include <iostream>
        using std::cout;
        using std::endl;

        class M {

        public:
            M( int );
            int mystery( int );

        private:
            int data;
            int number;

        };    // end class M

        //constructor
        M::M( int q = 0 ) {
            data = q;
            number = 2;
        } // end class M constructor

        // function mystery definition
        int M::mystery( int q ) {
            data +=q;
            return data;
        } // end function mystery definition

        int main () {
            M mObject ( 2 );
            M * mPtr = &mObject;
         
            cout << mObject.mystery( 20 ) << endl;
            cout << mPtr->mystery( 30 );

            return 0;
        } // end main

   
22
    52

Short answer #6:  Determine the a.) row-major and b.) column-major memory position of array position [6][8] assuming the array is declared as 10 X 12 and assuming it is one-based.  The datatype has size 1 and starts at position 0 in memory. 

    a.)  (12-1+1)*(6-1)+(8-1)=67
    b.)  (10-1+1)*(8-1)+(6-1)=75
 

Standards:

In addition, include the following pledge at the bottom of your file:

On my honor:

- I have not discussed the C++ language code in my program with anyone other than my instructor or the teaching assistants assigned to this course.

- I have not used C++ language code obtained from another student, or any other unauthorized source, either modified or unmodified.

- If any C++ language code or documentation used in my program was obtained from another source, such as a textbook or course notes, that has been clearly noted with a proper citation in the comments of my program.

- I have not designed this program in such a way as to defeat or interfere with the normal operation of the Curator System.
<Your Name>

Submission

Name your file <yourpid>.doc before 12:00 midnight of Thursday, July 10, 2003.  To receive credit, your assignment must be submitted before the time and date listed above. The curator can only accept a limited number of submissions per minute, so curator lag is not an excuse for submitting late. It is your responsibility to successfully submit your assignment via the curator, so plan to submit early.  A maximum of five submissions is allowed per student!  The curator will NOT auto grade the homework.  Only the final submission will be graded, not your highest grade.

          Submit to:  http://www.cs.vt.edu/curator/                                                       

Additionally, print out a hard copy and turn in Friday, July 11, 2003, before class.  Note:  I will post the answers after Midnight on Thursday, so any late submission will receive a score of 0 without exception.