// ---------------------------------------------------------------------------
// testmain.C
//
// Paul McNamee  (578-02-6375)
// ---------------------------------------------------------------------------

#include <string.h>
#include "String.h"

int main () {
  const char *foostring = "The question of whether a computer can think";

  String s1(foostring);
  String s2(" is no more interesting than that of whether a submarine can swim");
  String s3(s1 + s2);
  String s4("E. Djkstra");
  
  cout << "String 1: [Test of char * constructor] " << s1 << endl;
  cout << "String 2: [Another test of const char *] " << s2 << endl;
  cout << "String 3: [Test of String addition and copy ctor] " << s3 << endl;
  cout << "String 4: " << s4 << endl;
  cout << "Length of String 4 is: " << s4.len() << endl; 
  
  s2.~String();
  cout << "String3 [After destruction of String 2]: " << s3 << endl;

  s2 = String("Pepsi");
  s3 = String("and");
  s4 = String("Coke");
  cout << "Strings 2-4 [Test of operator =]: " << s2 << " " << s3 << " " << s4 << endl;

  s2 += s3 += s4;
  cout << "Strings 2-4 [Test of operator +=]: " << s2 << " " << s3 << " " << s4 << endl;

  cout << "String 2: " << s2 << endl;
  cout << "String 4: " << s4 << endl;

  cout << "String 2 == String 4 : " << ( (s2==s4) ? "Yes " : "No " ) << endl;
  cout << "String 2 != String 4 : " << ( (s2!=s4) ? "Yes " : "No " )<< endl;

  cout << "strlen (s1) is: [Test cast]: " << strlen(s1) << endl;
  cout << "Done with Testing.  Bye." << endl;
  
  return (0);
}
