Approach: These tests use two sessions of interaction with the program: ./flexvec < invalid.in.txt &> invalid.out.txt ./flexvec < valid.in.txt > valid.out.txt The nl-numbered content of those files, plus the prefixes IN/OUT, are narrated in this document. ====================== User interface testing ====================== Narrative of the "invalid" run. ----------------------------------- Case 1, Boundary: command placement ----------------------------------- Commands and comments that don't start in the first column of the line are considered invalid. IN 1 * Command not starting in first column OUT 1 ERROR: unknown command ' * Command not starting in first column' entered. IN 2 ? 0 OUT 2 ERROR: unknown command ' ? 0' entered. Observe that both a comment and a command which started in column 2 are rejected. Note, all other test cases' commands start in column 1. IN 3 * Verify that errors are correctly reported for each IN 4 * command by testing # of arguments, invalid commands, IN 5 * and invalid vector specifications. Valid comments are properly processed i.e. ignored, producing no output. ----------------------------------------- Case 2, Boundary: # parameters for assign ----------------------------------------- Invalid number of parameters for assign command (too few or too many). IN 6 * IN 7 * Assignment IN 8 = OUT 3 ERROR: invalid number of parameters for '='. IN 9 = 0 OUT 4 ERROR: invalid number of parameters for '= 0'. IN 10 = -1 OUT 5 ERROR: invalid vector specification '-1' entered for '= -1'. OUT 6 ERROR: invalid number of parameters for '= -1'. IN 11 = 3 OUT 7 ERROR: invalid vector specification '3' entered for '= 3'. OUT 8 ERROR: invalid number of parameters for '= 3'. IN 12 = x OUT 9 ERROR: invalid integer 'x' entered for '= x'. IN 13 = 3 1 1 1 OUT 10 ERROR: invalid number of parameters for '= 3 1 1 1'. Commands are rejected since an error message about invalid # of parameters is printed for each of these commands. -------------------------------------------- Case 3, Boundary: v < 0, v > 2, v != integer -------------------------------------------- Invalid vector number specified. Since test for vector is applied to all commands but the comment, only test for assignment. [See also above: in10-out5, in11-out7] IN 14 = 0 x 1 OUT 11 ERROR: invalid integer 'x' entered for '= 0 x 1'. Commands are rejected since an error message about invalid vector # printed for each invalid specification. ---------------------------------------- Case 4, Boundary: # parameters for fetch ---------------------------------------- Part A 20-22 45-47 Invalid number of parameters for fetch command (too few or too many). IN 15 * IN 16 * Fetch IN 17 * IN 18 ? OUT 12 ERROR: invalid number of parameters for '?'. IN 19 ? 0 OUT 13 ERROR: invalid number of parameters for '? 0'. IN 20 ? 0 1 1 OUT 14 ERROR: invalid number of parameters for '? 0 1 1'. Commands are rejected since an error message about invalid # of parameters is printed for each of these commands. ----------------------------------------- Case 5, Boundary: # parameters for status ----------------------------------------- Invalid number of parameters for status command (too few or too many). IN 21 * IN 22 * Status IN 23 * IN 24 s OUT 15 ERROR: invalid number of parameters for 's'. IN 25 s 0 1 OUT 16 ERROR: invalid number of parameters for 's 0 1'. Commands are rejected since an error message about invalid # of parameters is printed for each of these commands. ------------------------------------ Case 6, General random error command ------------------------------------ Test a random invalid command to ensure it is detected as an invalid command. IN 26 * IN 27 * Other commands should be ignored IN 28 * IN 29 x OUT 17 ERROR: unknown command 'x' entered. IN 30 1 OUT 18 ERROR: unknown command '1' entered. Commands are rejected since error messages about an unknown command are printed. ============================ Implementation of the vector ============================ Narrative of the "valid" run. ---------------------------------------- Case 7, Boundary: Status on empty vector ---------------------------------------- Test status command on empty vectors. Also confirms that vectors are correctly initialized to all non-zero items and no non-zero element index range. IN 1 * First verify the status of each vector. Also double-checks status IN 2 * command. IN 3 s 0 OUT 1 Vector0 has 0 non-zero entries. IN 4 s 1 OUT 2 Vector1 has 0 non-zero entries. IN 5 s 2 OUT 3 Vector2 has 0 non-zero entries. Observe that all vectors have no non-zero entries and correctly print out no range of indices for non-zero elements. --------------------------------------- Case 8, Boundary: Fetch on empty vector --------------------------------------- Fetch an element from an empty vector and verify that vector is left unchanged. Also determines whether or not correctly returns 0 for index position not explicitly set to 0 or non-0 value. IN 6 * Make a reference to a vector's element and verify that IN 7 * the status hasn't changed. IN 8 ? 0 5 OUT 4 FETCH returns 0 IN 9 s 0 OUT 5 Vector0 has 0 non-zero entries. Since vector contains no non-zero elements, fetch correctly returns 0 for the specified index. Status shows vector still has 0 non-zero elements and no index range. -------------------------- Case 9, Boundary: Insert 0 -------------------------- Assign a 0 element to an empty vector and check that the status is unchanged. IN 10 * Insert a zero element and ensure that the vector status has not IN 11 * been modified IN 12 = 0 0 0 IN 13 s 0 OUT 6 Vector0 has 0 non-zero entries. Status still shows that vector has 0 non-zero elements and no index range. ------------------------------------- Case 10, General: No unwanted effects ------------------------------------- Ensure that all changes to vector 0 have left the other vectors unchanged (only need to check one of the others to ensure all ok) IN 14 * First verify that vector 1 was untouched by other operations. IN 15 s 1 OUT 7 Vector1 has 0 non-zero entries. Status still shows that vector has 0 non-zero elements and no index range. -------------------------------------------- Case 11, Boundary: Insert non-0 empty vector -------------------------------------------- Assign a non-0 element to an empty vector and check that the status is correctly changed. IN 16 * Insert several non-zero items into a vector and verify IN 17 * that the status information has been correctly updated. IN 18 = 1 9 10 IN 19 s 1 OUT 8 Vector1 has 1 non-zero entries. Vector subscripts are in the range [9, 9]. Status shows that vector has 1 non-zero element and the index range correctly encompasses the single index as both ends of the index range. --------------------------------------------------- Case 12, General Insert non-0 into non-empty vector --------------------------------------------------- Insert non-0 elements to either end of previous index range and verify that the range was correctly extended. IN 20 = 1 100 101 IN 21 = 1 -10 -9 IN 22 s 1 OUT 9 Vector1 has 3 non-zero entries. Vector subscripts are in the range [-10, 100]. Status shows that vector correctly contains 3 elements now, and that the range has been expanded correctly in both directions. --------------------------------------------- Case 13, General. Fetch from non-empty vector --------------------------------------------- Perform a fetch on an index associated with a non-0 value. IN 23 ? 1 100 OUT 10 FETCH returns 101 Fetch correctly returns the value 101 with the index 100. Since the vector is dynamic, no boundaries need be tested.