/////////////////////////////////////////////////////////////////// // // // qlpage3.cpp - qualification test #3 // // // // make_line process // // // /////////////////////////////////////////////////////////////////// // // // Process Description: // // The make_line process reads the next available characters // // from the selected file up to the next linefeed wor w // // characters, which ever comes first. There are stored // // in a text buffer and returned. The details of that trans- // // action constitute a communciation protocol between the // // LINES and PAGE modules. // // // /////////////////////////////////////////////////////////////////// // // // Requirements: // // // // A-Specification Requirement - 3.8 // // Carriage returns in the input text shall signal the end // // of a line. Lines longer than w characters shall be wrap- // // ped at w characters, forming a new line and adding to the // // line count for the current page. // // // // B-Specification Requirement - 3.4.2.a.1 // // The make_line process shall read characters from selected // // file until either a newline or formfeed is encountered or // // w characters have been read. // // B-Specification Requirement - 3.4.2.a.2 // // The make_line process shall store the characters in a null // // terminated array and return. // // B-Specification Requirement - 3.4.2.a.3 // // The make_line process shall convert tab characters to // // spaces using tab stops at multiples of T, starting from // // the zeroth element of the line array, excluding margin. // // B-Specification Requirement - 3.4.2.a.4 // // The make_line process shall treat the formfeed character // // as an exception requiring the formation of a line with // // just that character. // // // /////////////////////////////////////////////////////////////////// // // // Test Description: // // The attached test driver creates a text buffer and opens // // a file to use as a source of characters. It passes the // // file handle, text buffer, and pagination parameters to // // LINES module makeText() function for extraction of each // // line. Lines are returned to the driver in text buffer. // // // /////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////// // // // Preconditions: // // - cmdline.hpp, lines.hpp, and lines.cpp must be in the // // default directory // // // /////////////////////////////////////////////////////////////////// // // // Test Procedure - LINES module test // // // // 1. run test stub citing filename on command line // // // // qlpage3 qlpage3.tst // // // // Expected test results: // // // // The test driver prints out data from the file by lines. // // Lines are wrapped at w characters if longer and formfeeds // // are treated as page terminating exceptions. // // // /////////////////////////////////////////////////////////////////// // // // Signature: Date: // // ---------------------------- ------------- // // // /////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////// // // // qlpage3.cpp - qualification test #3 // // // // make_line process // // // /////////////////////////////////////////////////////////////////// #define NO_MAIN #include "cmdline.hpp" #include "cmdline.cpp" #undef NO_MAIN #include "lines.hpp" #include "lines.cpp" void main(int argc, char* argv[]) { cout << "\nTesting make_line process\n\n"; ifstream in(argv[argc-1]); if(!in.good()) { cout << "can't open file " << argv[argc-1] << endl; return; } else cout << "opening file " << argv[argc-1] << endl; int margin = 5; int width = 65; int tabSize = 8; char buffer[128]; cout << "pagination parameters are:\n" << " margin = " << margin << endl << " width = " << width << endl << " tabsize = " << tabSize << endl; cout << "\ntext lines are:\n\n"; while(in.good()) { makeText(buffer, in, margin, width, tabSize); cout << buffer << endl; int i; for(i=0; i<14; i++) cout << "|----"; cout << "|" << endl; } } // /* Testing make_line process opening file qlpage4.tst pagination parameters are: margin = 5 width = 65 tabsize = 8 text lines are: This is the first line - it has less than w chars. |----|----|----|----|----|----|----|----|----|----|----|----|----|----| This is the second line - it is rather long - it has more than w |----|----|----|----|----|----|----|----|----|----|----|----|----|----| characters by a considerable margin. |----|----|----|----|----|----|----|----|----|----|----|----|----|----| This is the third line and is followed by a formfeed. |----|----|----|----|----|----|----|----|----|----|----|----|----|----| |----|----|----|----|----|----|----|----|----|----|----|----|----|----| The final line has an embedded newline here --> |----|----|----|----|----|----|----|----|----|----|----|----|----|----| |----|----|----|----|----|----|----|----|----|----|----|----|----|----| <-- that was it. |----|----|----|----|----|----|----|----|----|----|----|----|----|----| ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ |----|----|----|----|----|----|----|----|----|----|----|----|----|----| */