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: doc_test.cc /main/4 1996/07/18 16:02:13 drk $ */
25 #ifdef REGRESSION_TEST
27 #include "oliasdb/doc_test.h"
29 #define LARGE_BUFSIZ 2048
32 void print_doc(doc_smart_ptr& x, ostream& out, Boolean out_it_oid, Boolean out_tag_list)
34 if ( out_it_oid == true )
35 out << "its_oid=" << x.its_oid();
37 out << "short_title=" << x.short_title();
38 out << "long_title=" << x.long_title();
39 out << "seq_num=" << x.seq_num();
42 if ( x.license_terms()) {
43 const char* w = x.license_terms();
44 int u = x.license_terms_size();
45 for (int i=0; i<u; i++ )
50 out << "license_terms_size=" << x.license_terms_size();
52 if ( out_tag_list == true ) {
53 cerr << "tag list of the doc";
54 short_list_handler* z = x.tab_list();
55 (*z) -> asciiOut(cerr); cerr << "\n";
60 int compare_doc(doc_smart_ptr& pattern, info_base* base_ptr)
62 char pattern_buf[LARGE_BUFSIZ];
63 ostringstream pattern_out(pattern_buf, LARGE_BUFSIZ, ios::out);
64 print_doc(pattern, pattern_out, false, false);
66 doc_smart_ptr x( base_ptr, pattern.seq_num());
67 char db_buf[LARGE_BUFSIZ];
68 ostringstream db_out(db_buf, LARGE_BUFSIZ, ios::out);
69 print_doc(x, db_out, false, false);
71 return compare_stream(pattern_out, db_out);
74 int doc_test_oid( info_lib* infolib_ptr, const char* base_name, const char* oid_str )
76 oid_t id((char*)oid_str, true, false);
77 doc_smart_ptr x( infolib_ptr, base_name, id);
78 print_doc(x, cerr, true, true);
83 int doc_test_doc_oid( info_lib* infolib_ptr, const char* base_name, const char* oid_str )
85 oid_t id((char*)oid_str, true, false);
86 doc_smart_ptr x(id, infolib_ptr, base_name);
87 print_doc(x, cerr, true, true);
93 doc_test_int(info_lib* infolib_ptr,
94 const char* base_name,
95 const char* seq_num_str)
98 doc_smart_ptr x( infolib_ptr, base_name, atoi(seq_num_str));
99 print_doc(x, cerr, true, true);
104 void generate_doc_instance(random_gen& x, ostream& out, int seq_num, int min_tabs, int max_tabs)
108 x.random_oid(out, 1001, 0); // id
109 x.random_string(out, 10, 20); // title
110 x.random_string(out, 10, 40); // title
111 x.random_integer(out, seq_num); // seq number
116 int tabs = x.pick_a_value(min_tabs, max_tabs);
118 for ( int i=0; i<tabs; i++ )
119 x.random_string(out, 10, 40); // tab node locator
123 x.random_string(out, 10, 100); // license term