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 ostringstream pattern_out(pattern_buf, LARGE_BUFSIZ, ios::out);
44 print_stylesheet(pattern, pattern_out);
47 int len = MIN(strlen(pattern.name()), BUFSIZ - 1);
48 *((char *) memcpy(loc, pattern.name(), len) + len) = '\0';
50 stylesheet_smart_ptr x( base_ptr, loc );
51 char db_buf[LARGE_BUFSIZ];
52 ostringstream db_out(db_buf, LARGE_BUFSIZ, ios::out);
53 print_stylesheet(x, db_out);
55 return compare_stream(pattern_out, db_out);
58 void update_stylesheet_test(char* filename, info_base* base_ptr, char* locator)
62 fstream in(filename, ios::in);
64 in.getline(buf, LBUFSIZ);
65 int slen = strlen(st_buf);
66 int len = MIN(strlen(buf), LBUFSIZ - 1 - slen);
67 *((char *) memcpy(st_buf + slen, buf, len) + len) = '\0';
69 stylesheet_smart_ptr st(base_ptr, locator);
70 st.update_online_data(st_buf, strlen(st_buf));
73 int stylesheet_test_loc( info_lib* infolib_ptr, const char* base_name, const char* loc )
75 stylesheet_smart_ptr x( infolib_ptr, base_name, loc );
76 cerr << form("info of stylesheet object with loc %s:\n", loc);
77 print_stylesheet(x, cerr);
81 int stylesheet_test_oid( info_lib* infolib_ptr, const char* base_name, const char* oid_str)
83 oid_t id((char*)oid_str, true, false);
84 stylesheet_smart_ptr x( infolib_ptr, base_name, id );
86 cerr << form("info of stylesheet object with id : ");
88 debug(cerr, x.name());
89 debug(cerr, x.online_data_size());
90 debug(cerr, x.online_data());
91 debug(cerr, x.hardcopy_data_size());
92 debug(cerr, x.hardcopy_data());
94 x.its_oid().asciiOut(cerr); cerr << "\n";
99 void generate_stylesheet_instance(random_gen& x, ostream& out, int min_len, int max_len)
103 x.random_string(out, 15, 15); // name
104 x.random_string(out, min_len, max_len); // sheet1
105 x.random_string(out, min_len, max_len); // sheet2