#include "io.h"
int main( int argc, char** argv ) {
We begin each example by creating the input stream. Next, we initialize the string we expect suplib::getrecord to return. Finally, we call getrecord and compare the returned string to the expected string.
{
strstream strstr;
strstr << " now, is, the, time ";
expected = " now, is, the, time ";
cout << ( returned == expected ? "OK" : "NOT OK" ) << endl;
}
With suplib::READ_PHYS set, we read up until the ‘\n’ or EOF.
{
strstream strstr;
strstr << " now, is, the, time \n";
expected = " now, is, the, time";
cout << ( returned == expected ? "OK" : "NOT OK" ) << endl;
}
With suplib::READ_PHYS and suplib::STRIP set, we read up until the ‘\n’ and then strip all whitespace from the end of the string.
{
strstream strstr;
strstr << " now, is, the, time \\ \n"
<< " now, is, the, time \\ \n"
<< " now, is, the, time ";
expected = " now, is, the, time ";
expected += " now, is, the, time ";
expected += " now, is, the, time ";
cout << ( returned == expected ? "OK" : "NOT OK" ) << endl;
}
With suplib::READ_LOGICAL set, we read all three physical lines.
{
strstream strstr;
strstr << " now, is, the, time \\ \n"
<< " now, is, the, time \\ \n"
<< " now, is, the, time ";
expected = " now, is, the, time \\\n";
expected += " now, is, the, time \\\n";
expected += " now, is, the, time ";
cout << ( returned == expected ? "OK" : "NOT OK" ) << endl;
}
With suplib::READ_LOGICAL and suplib::CLEAN set, we read all three physical lines and remove whitespace between the continuation character and the newline character.
{
strstream strstr;
strstr << " now, is, the, time \n";
expected = " now, is, the, time";
cout << ( returned == expected ? "OK" : "NOT OK" ) << endl;
}
With suplib::READ_LOGICAL and suplib::STRIP set, we read the single physical line since there is no continuation character. We then strip the trailing whitespace from the line.
{
strstream strstr;
strstr << " now, is, the, time \\ \n"
<< " now, is, the, time \\ \n"
<< " now, is, the, time ";
expected = " now, is, the, time ";
expected += " now, is, the, time ";
expected += " now, is, the, time";
cout << ( returned == expected ? "OK" : "NOT OK" ) << endl;
}
With suplib::READ_LOGICAL and suplib::STRIP set, we read the three physical lines. We then strip the continuation character and trailing whitespace from the line.
{
strstream strstr;
strstr << " now, is, the, time \\ \n"
<< " now, is, the, time \\ \n"
<< " now, is, the, time ";
expected = " now, is, the, time \\\n";
expected += " now, is, the, time \\\n";
expected += " now, is, the, time";
cout << ( returned == expected ? "OK" : "NOT OK" ) << endl;
}
With suplib::READ_LOGICAL, suplib::STRIP, and suplib::CLEAN set, we read the three physical lines. We then strip the continuation character and trailing whitespace from the line.
{
strstream strstr;
strstr << " now, is, the, time - \n"
<< " now, is, the, time - \n"
<< " now, is, the, time ";
expected = " now, is, the, time ";
expected += " now, is, the, time ";
expected += " now, is, the, time ";
cout << ( returned == expected ? "OK" : "NOT OK" ) << endl;
}
Here we change the definition of the continuation character.