home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sets115.zip / SetTest.cpp < prev    next >
C/C++ Source or Header  |  1997-05-24  |  1KB  |  44 lines

  1. // Test program for Sets by Hubert Chan
  2. // May 24, 1997
  3.  
  4. #include "Sets.hpp"
  5. #include <stdio.h>
  6.  
  7. #define Test(x) (x ? "is\0" : "is not\0")
  8.  
  9. void main() {
  10.     Set::SetElement Aarray[3] = { 1,2,3 };
  11.     Set A(3,Aarray);
  12.     Set::SetElement Barray[3] = { 2,3,4 };
  13.     Set B(3,Barray);
  14.     Set::SetElement Carray[2] = { 2,3 };
  15.     Set C(2,Carray);
  16.     printf("****************************************\n");
  17.     printf("* Test program for Sets by Hubert Chan *\n");
  18.     printf("* Last modified: May 24, 1997          *\n");
  19.     printf("****************************************\n\n");
  20.     printf("A = "); PrintSet(A);
  21.     printf("B = "); PrintSet(B);
  22.     printf("C = "); PrintSet(C);
  23.     printf("|A| = %d\n", A.Card());
  24.     printf("|B| = %d\n", B.Card());
  25.     printf("|C| = %d\n", C.Card());
  26.     printf("A U B = "); PrintSet(A + B);
  27.     printf("A ^ B = "); PrintSet(A * B);
  28.     printf("A - B = "); PrintSet(A - B);
  29.     printf("~A = "); PrintSet(~A);
  30.     printf("2 %s in A\n", Test(2<=A));
  31.     printf("5 %s in A\n", Test(5<=A));
  32.     printf("C %s a subset of A\n", Test(C<=A));
  33.     printf("C %s a proper subset of A\n", Test(C<A));
  34.     printf("C %s equal to A\n", Test(C==A));
  35.     printf("C %s not equal to A\n", Test(C!=A));
  36.     printf("A %s a subset of A\n", Test(A<=A));
  37.     printf("A %s a proper subset of A\n", Test(A<A));
  38.     printf("A %s equal to A\n", Test(A==A));
  39.     printf("A %s not equal to A\n", Test(A!=A));
  40.     printf("A %s a superset of C\n", Test(A>=C));
  41.     printf("A %s a proper superset of C\n", Test(A>C));
  42. }
  43.  
  44.