#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.
{ // Example 1 strstream strstr; strstr << " now, is, the, time "; expected = " now, is, the, time "; suplib::getrecord( strstr, returned, suplib::READ_PHYS ); cout << ( returned == expected ? "OK" : "NOT OK" ) << endl; }
{ // Example 2 strstream strstr; strstr << " now, is, the, time \n"; expected = " now, is, the, time"; suplib::getrecord( strstr, returned, suplib::READ_PHYS | suplib::STRIP ); cout << ( returned == expected ? "OK" : "NOT OK" ) << endl; }
{ // Example 3 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 "; suplib::getrecord( strstr, returned, suplib::READ_LOGICAL ); cout << ( returned == expected ? "OK" : "NOT OK" ) << endl; }
{ // Example 4 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 "; suplib::getrecord( strstr, returned, suplib::READ_LOGICAL | suplib::CLEAN ); cout << ( returned == expected ? "OK" : "NOT OK" ) << endl; }
{ // Example 5 strstream strstr; strstr << " now, is, the, time \n"; expected = " now, is, the, time"; suplib::getrecord( strstr, returned, suplib::READ_LOGICAL | suplib::STRIP ); cout << ( returned == expected ? "OK" : "NOT OK" ) << endl; }
{ // Example 6 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"; suplib::getrecord( strstr, returned, suplib::READ_LOGICAL | suplib::STRIP); cout << ( returned == expected ? "OK" : "NOT OK" ) << endl; }
{ // Example 7 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"; suplib::getrecord( strstr, returned, suplib::READ_LOGICAL | suplib::STRIP | suplib::CLEAN ); cout << ( returned == expected ? "OK" : "NOT OK" ) << endl; }
{ // Example 8 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 "; suplib::getrecord( strstr, returned, suplib::READ_LOGICAL, '\n', '-' ); cout << ( returned == expected ? "OK" : "NOT OK" ) << endl; }
}