// // test relational operators. // // assumes constructors work. // #include #include // has EXIT_SUCCESS #include "lstring.h" #include "testsub.h" // has functions for testing // apply all relational operators to pair of strings; print results. void doRelationals(const char *s1In, const char *s2In, const lstring & s1, const lstring & s2) { cout << "comparing " << s1In << " and " << s2In << ": "; if (s1 == s2) cout << "== "; if (s1 != s2) cout << "!= "; if (s1 < s2) cout << "< "; if (s1 > s2) cout << "> "; if (s1 <= s2) cout << "<= "; if (s1 >= s2) cout << ">= "; cout << endl; return; } int main(void) { lstring empty; lstring x('x'); lstring xy("xy"); lstring y('y'); lstring yz("yz"); lstring abcd("abcd"); lstring abcef("abcef"); doRelationals("''", "''", empty, empty); doRelationals("''", "'x'", empty, x); doRelationals("'x'", "'x'", x, x); doRelationals("'x'", "'y'", x, y); doRelationals("'abcd'", "'abcd'", abcd, abcd); doRelationals("'x'", "'xy'", x, xy); doRelationals("'xy'", "'x'", xy, x); doRelationals("'xy'", "'yz'", xy, yz); doRelationals("'abcd'", "'abcef'", abcd, abcef); cout << "That's all, folks!\n"; return EXIT_SUCCESS; }