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: graphic_test.cc /main/4 1996/07/18 16:02:34 drk $ */
25 #ifdef REGRESSION_TEST
27 #include "oliasdb/graphic_test.h"
29 #define LARGE_BUFSIZ 2048
32 void print_graphic(graphic_smart_ptr& x, ostream& out, Boolean out_misc)
34 out << "locator=" << x.locator() << "\n";
35 out << "filename=" << x.file_name() << "\n";
36 out << "version=" << x.version() << "\n";
38 const char* title = x.title();
40 out << "title=" << x.title() << "\n";
42 out << "no title" << "\n";
44 out << "data_size=" << x.data_size() << "\n";
46 int l = x.data_size();
47 const char* str = x.data();
49 for ( int i=0; i<l; i++ )
54 if ( out_misc == true ) {
55 out << "type=" << x.type() << "\n";
56 out << "coding=" << x.coding() << "\n";
57 out << "width=" << x.width() << "\n";
58 out << "height=" << x.height() << "\n";
60 out << "llx=" << x.llx() << "\n";
61 out << "lly=" << x.lly() << "\n";
62 out << "urx=" << x.urx() << "\n";
63 out << "ury=" << x.ury() << "\n";
67 int compare_graphic(graphic_smart_ptr& pattern, info_base* base_ptr)
69 char pattern_buf[LARGE_BUFSIZ];
70 ostrstream pattern_out(pattern_buf, LARGE_BUFSIZ, ios::out);
71 print_graphic(pattern, pattern_out, false);
74 strcpy(loc, pattern.locator());
76 graphic_smart_ptr x( base_ptr, loc );
77 char db_buf[LARGE_BUFSIZ];
78 ostrstream db_out(db_buf, LARGE_BUFSIZ, ios::out);
79 print_graphic(x, db_out, false);
81 return compare_stream(pattern_out, db_out);
84 int graphic_test(info_lib* infolib_ptr, const char* base_name, const char* node_id_str )
86 graphic_smart_ptr x( infolib_ptr, base_name, node_id_str );
87 cerr << form("info. about graphic %s:\n", node_id_str);
88 print_graphic(x, cerr, true);
92 void generate_graphic_instance(info_base* b_ptr, random_gen& x, ostream& out, int min_len, int max_len)
97 x.random_string(out, 15, 15); // locator
98 x.random_string(out, 0, 0); //
99 x.random_string(out, 2, 2); // version
100 x.random_string(out, 10, 30); // misc info
102 handler * y = (b_ptr -> get_obj_dict()).get_handler(
103 form("%s.%s", b_ptr -> get_base_name(), "sgml.dict")
105 x.random_string_to_be_compressed(out, min_len, max_len, y -> its_oid()); // graphic
106 x.random_string(out, 10, 30); // title