2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: stylesheet_test.cc /main/4 1996/07/18 16:03:49 drk $ */
25 #ifdef REGRESSION_TEST
27 #include "oliasdb/stylesheet_test.h"
29 #define LARGE_BUFSIZ 2048
31 void print_stylesheet(stylesheet_smart_ptr& x, ostream& out)
33 out << "name=" << x.name();
34 out << "online_data_size=" << x.online_data_size();
35 out << "online_data=" << x.online_data();
36 out << "hardcopy_data_size=" << x.hardcopy_data_size();
37 out << "hardcopy_data_size=" << x.hardcopy_data();
40 int compare_stylesheet(stylesheet_smart_ptr& pattern, info_base* base_ptr)
42 char pattern_buf[LARGE_BUFSIZ];
43 ostrstream pattern_out(pattern_buf, LARGE_BUFSIZ, ios::out);
44 print_stylesheet(pattern, pattern_out);
47 strcpy(loc, pattern.name());
49 stylesheet_smart_ptr x( base_ptr, loc );
50 char db_buf[LARGE_BUFSIZ];
51 ostrstream db_out(db_buf, LARGE_BUFSIZ, ios::out);
52 print_stylesheet(x, db_out);
54 return compare_stream(pattern_out, db_out);
57 void update_stylesheet_test(char* filename, info_base* base_ptr, char* locator)
61 fstream in(filename, ios::in);
63 in.getline(buf, LBUFSIZ);
66 stylesheet_smart_ptr st(base_ptr, locator);
67 st.update_online_data(st_buf, strlen(st_buf));
70 int stylesheet_test_loc( info_lib* infolib_ptr, const char* base_name, const char* loc )
72 stylesheet_smart_ptr x( infolib_ptr, base_name, loc );
73 cerr << form("info of stylesheet object with loc %s:\n", loc);
74 print_stylesheet(x, cerr);
78 int stylesheet_test_oid( info_lib* infolib_ptr, const char* base_name, const char* oid_str)
80 oid_t id((char*)oid_str, true, false);
81 stylesheet_smart_ptr x( infolib_ptr, base_name, id );
83 cerr << form("info of stylesheet object with id : ");
85 debug(cerr, x.name());
86 debug(cerr, x.online_data_size());
87 debug(cerr, x.online_data());
88 debug(cerr, x.hardcopy_data_size());
89 debug(cerr, x.hardcopy_data());
91 x.its_oid().asciiOut(cerr); cerr << "\n";
96 void generate_stylesheet_instance(random_gen& x, ostream& out, int min_len, int max_len)
100 x.random_string(out, 15, 15); // name
101 x.random_string(out, min_len, max_len); // sheet1
102 x.random_string(out, min_len, max_len); // sheet2