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: toc_test.cc /main/4 1996/07/18 16:04:09 drk $ */
25 #ifdef REGRESSION_TEST
27 #include "oliasdb/toc_test.h"
29 #define LARGE_BUFSIZ 2048
32 void print_toc(toc_smart_ptr& x, ostream& out)
34 x.toc_node_oid().asciiOut(out); out << "\n";
35 x.parent().asciiOut(out); out << "\n";
37 out << "children of the toc: ";
38 oid_list_handler* y = x.children();
39 (*y) -> asciiOut(out); out << "\n";
43 out << "subtree node count: ";
44 out << x.subtree_size() << "\n";
47 int compare_toc(toc_smart_ptr& pattern, info_base* base_ptr)
49 char pattern_buf[LARGE_BUFSIZ];
50 ostringstream pattern_out(pattern_buf, LARGE_BUFSIZ, ios::out);
51 print_toc(pattern, pattern_out);
53 toc_smart_ptr x(base_ptr, pattern.toc_node_oid());
54 char db_buf[LARGE_BUFSIZ];
55 ostringstream db_out(db_buf, LARGE_BUFSIZ, ios::out);
58 return compare_stream(pattern_out, db_out);
62 toc_test(info_lib* infolib_ptr, const char* base_name, const char* node_id_str )
64 oid_t id((char*)node_id_str, true, false);
65 toc_smart_ptr x( infolib_ptr, base_name, id );
70 void generate_toc_instance(random_gen& x, ostream& out, int instance_num, int min_nodes, int max_nodes)
74 x.random_oid(out, 1001, instance_num); // toc node id
75 x.random_oid(out, 1001, 0); // parent node id
76 x.random_integer(out); //
81 int nodes = x.pick_a_value(min_nodes, max_nodes);
83 for ( int i=0; i<nodes; i++ )
84 x.random_oid(out, 1001, 0); // id