//strng_ct.cpp
#include "string_c.h"
#include <iostream>
#include <fstream>

using namespace enhance;
int main() {
   String *str1 = ::String_ctor();
   String *str2 = ::String_ctor("hello");

   cout << "str1(len=" << length(str1) << "):" << *str1 << endl;
   cout << "str2(len=" << length(str2) << "):" << *str2 << endl;

   if (!(str1 == *str2))
      cout << "good, str1 & str2 don't match" << endl;

   String *str3 = String_ctor(*str2);
   cout << "str3(len=" << length(str3) << "):" << *str3 << endl;

   if (!(str1 == *str3))
      cout << "good, str1 & str3 don't match" << endl;
   if (str2 == *str3)
      cout << "good, str2 & str3 do match" << endl;

   assign(str1,*str2);
   if (str1 == *str2)
      cout << "good, str1 & str3 now match" << endl;

   fstream file("string.dat", ios::in | ios::out );
   saveOn(str1, file);
   String* str4 = String_ctor();
   file.seekg(0);
   restoreFrom(str4, file);
   if (str1 == *str4)
      cout << "good, str1 & str4 match, file must have worked!" << endl;

   dtor(str1);
   dtor(str2);
   dtor(str3);

   return 0;
};

/*********** output ***************************
str1(len=0):
str2(len=5):hello
good, str1 & str2 don't match
str3(len=5):hello
good, str1 & str3 don't match
good, str2 & str3 do match
good, str1 & str3 now match
good, str1 & str4 match, file must have worked!
**********************************************/

