Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
83
cde/programs/dtinfo/DtMmdb/oliasdb/stylesheet_test.C
Normal file
83
cde/programs/dtinfo/DtMmdb/oliasdb/stylesheet_test.C
Normal file
@@ -0,0 +1,83 @@
|
||||
/* $XConsortium: stylesheet_test.cc /main/4 1996/07/18 16:03:49 drk $ */
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#include "oliasdb/stylesheet_test.h"
|
||||
|
||||
#define LARGE_BUFSIZ 2048
|
||||
|
||||
void print_stylesheet(stylesheet_smart_ptr& x, ostream& out)
|
||||
{
|
||||
out << "name=" << x.name();
|
||||
out << "online_data_size=" << x.online_data_size();
|
||||
out << "online_data=" << x.online_data();
|
||||
out << "hardcopy_data_size=" << x.hardcopy_data_size();
|
||||
out << "hardcopy_data_size=" << x.hardcopy_data();
|
||||
}
|
||||
|
||||
int compare_stylesheet(stylesheet_smart_ptr& pattern, info_base* base_ptr)
|
||||
{
|
||||
char pattern_buf[LARGE_BUFSIZ];
|
||||
ostrstream pattern_out(pattern_buf, LARGE_BUFSIZ, ios::out);
|
||||
print_stylesheet(pattern, pattern_out);
|
||||
|
||||
char loc[BUFSIZ];
|
||||
strcpy(loc, pattern.name());
|
||||
|
||||
stylesheet_smart_ptr x( base_ptr, loc );
|
||||
char db_buf[LARGE_BUFSIZ];
|
||||
ostrstream db_out(db_buf, LARGE_BUFSIZ, ios::out);
|
||||
print_stylesheet(x, db_out);
|
||||
|
||||
return compare_stream(pattern_out, db_out);
|
||||
}
|
||||
|
||||
void update_stylesheet_test(char* filename, info_base* base_ptr, char* locator)
|
||||
{
|
||||
char buf[LBUFSIZ];
|
||||
char st_buf[LBUFSIZ];
|
||||
fstream in(filename, ios::in);
|
||||
while (in) {
|
||||
in.getline(buf, LBUFSIZ);
|
||||
strcat(st_buf, buf);
|
||||
}
|
||||
stylesheet_smart_ptr st(base_ptr, locator);
|
||||
st.update_online_data(st_buf, strlen(st_buf));
|
||||
}
|
||||
|
||||
int stylesheet_test_loc( info_lib* infolib_ptr, const char* base_name, const char* loc )
|
||||
{
|
||||
stylesheet_smart_ptr x( infolib_ptr, base_name, loc );
|
||||
cerr << form("info of stylesheet object with loc %s:\n", loc);
|
||||
print_stylesheet(x, cerr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stylesheet_test_oid( info_lib* infolib_ptr, const char* base_name, const char* oid_str)
|
||||
{
|
||||
oid_t id((char*)oid_str, true, false);
|
||||
stylesheet_smart_ptr x( infolib_ptr, base_name, id );
|
||||
|
||||
cerr << form("info of stylesheet object with id : ");
|
||||
debug(cerr, id);
|
||||
debug(cerr, x.name());
|
||||
debug(cerr, x.online_data_size());
|
||||
debug(cerr, x.online_data());
|
||||
debug(cerr, x.hardcopy_data_size());
|
||||
debug(cerr, x.hardcopy_data());
|
||||
|
||||
x.its_oid().asciiOut(cerr); cerr << "\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void generate_stylesheet_instance(random_gen& x, ostream& out, int min_len, int max_len)
|
||||
{
|
||||
out << "1011\n";
|
||||
out << "3\n";
|
||||
x.random_string(out, 15, 15); // name
|
||||
x.random_string(out, min_len, max_len); // sheet1
|
||||
x.random_string(out, min_len, max_len); // sheet2
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user