diff --git a/test/diskiotest.cc b/test/diskiotest.cc index 98d578e..e368a64 100644 --- a/test/diskiotest.cc +++ b/test/diskiotest.cc @@ -10,6 +10,7 @@ double d_PI = 3.14159265358979323846; int main (int argc, char* argv[]) { base::diskio test (base::diskio::GZ_FILE); + base::diskio test_xml (base::diskio::XML_FILE); base::flat fl; char *block = new char[256]; @@ -33,7 +34,7 @@ int main (int argc, char* argv[]) { test.put_block ("block", block, 256); // a flat can contain other flats too - fl.put_string ("string", "Another flat"); + fl.put_string ("string", "Another flat so on."); fl.put_flat ("test", test); test.put_flat ("flat", fl); @@ -45,15 +46,34 @@ int main (int argc, char* argv[]) { // write record to disk cout << "Writing data to disk ..." << endl; test.put_record ("diskio.test"); - + // FIXME:This segfaults at the end + // test_xml = test; + test_xml.copy(test); + if (test.checksum () != test_xml.checksum ()) + cout << "Checksum mismatch!" << endl; + + cout << "Writing data to disk (xml) ..." << endl; + test_xml.put_record ("diskiotest.xml"); + if (test.checksum () != test_xml.checksum ()) + cout << "Checksum mismatch!" << endl; // read record from disk cout << "Reading data from disk" << endl; bool b = test.get_record ("diskio.test"); if (b == true) cout << "Reading successful" << endl; + cout << "Reading data from disk (xml)" << endl; + b = test_xml.get_record ("diskiotest.xml"); + if (b == true) cout << "Reading successful" << endl; + // print checksum of data read cout << "Checksum: " << (std::hex) << test.checksum () << (std::dec) << endl; - + + // cheat and just compare checksum for xml. + cout << "XML Checksum : "<< (std::hex) << test_xml.checksum () << (std::dec); + if (test.checksum () != test_xml.checksum ()) + cout << " mismatch!"; + cout << endl; + // unpack all kind of data using get_* // this may happen in any order, although using the original // order is much more efficient.