// CatalogError_t.cxx #include "dataset_catalog/CatalogError.h" #include #include #include using std::string; using std::cout; using std::endl; using std::set; using dset::CatalogError; namespace { void msg(string txt) { cout << "--- " << txt << " ---" << endl; } } // end unnamed namespace int CatalogError_t() { msg("Begin testing CatalogError"); CatalogError err("some type"); msg("No error"); CatalogError::Status stat = CatalogError::no_error(); cout << err.message(stat) << endl; assert( ! stat ); assert( stat == 0 ); msg("Check uniqueness of error codes"); set stats; stats.insert(CatalogError::invalid_object_error()); stats.insert(CatalogError::id_assigned_error()); stats.insert(CatalogError::null_object_error()); stats.insert(CatalogError::invalid_id_error()); stats.insert(CatalogError::no_such_object_error()); stats.insert(CatalogError::generic_read_error()); stats.insert(CatalogError::generic_write_error()); stats.insert(CatalogError::generic_access_error()); stats.insert(CatalogError::local_id_error()); stats.insert(CatalogError::object_parse_error()); stats.insert(CatalogError::object_create_error()); stats.insert(CatalogError::unknown_error()); assert( stats.size() == 12 ); msg("Check messages"); set msgs; for ( set::const_iterator ista=stats.begin(); ista!=stats.end(); ++ista ) { stat = *ista; assert( stat != 0 ); string msg = err.message(stat); assert( msg != "" ); msgs.insert(msg); cout << stat << ": " << msg << endl; } assert( msgs.size() == stats.size() ); return 0; } #ifdef CTEST_MAIN int main() { return CatalogError_t(); } #endif