838c7be13edc995257fe2ae368e1d38a840a44d7
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / oliasdb / loc_test.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: loc_test.C /main/5 1996/10/26 18:19:23 cde-hal $ */
24
25 #ifdef REGRESSION_TEST
26
27 #include "oliasdb/loc_test.h"
28
29 #define LARGE_BUFSIZ 2048
30
31
32 void print_loc(locator_smart_ptr& x, ostream& out)
33 {
34    out << x.inside_node_locator_str();
35    x.node_id().asciiOut(out); out << "\n";
36 }
37
38 int compare_locator(locator_smart_ptr& pattern, info_base* base_ptr)
39 {
40    char pattern_buf[LARGE_BUFSIZ];
41    ostringstream pattern_out(pattern_buf, LARGE_BUFSIZ, ios::out);
42    print_loc(pattern, pattern_out);
43
44    locator_smart_ptr x( base_ptr, pattern.inside_node_locator_str());
45    char db_buf[LARGE_BUFSIZ];
46    ostringstream db_out(db_buf, LARGE_BUFSIZ, ios::out);
47    print_loc(x, db_out);
48
49    return compare_stream(pattern_out, db_out);
50 }
51
52 int loc_test( info_lib* infolib_ptr, const char* base_name, const char* loc )
53 {
54    locator_smart_ptr x( infolib_ptr, base_name, loc );
55    print_loc(x, cerr);
56    return 0;
57 }
58
59 void generate_loc_instance(random_gen& x, ostream& out)
60 {
61    out << "1002\n";
62    out << "3\n";
63    x.random_string(out, 15, 15); // locator
64    x.random_oid(out, 1001, 0); // id
65    x.random_string(out, 8, 255); // label
66 }
67
68 #endif