-
Notifications
You must be signed in to change notification settings - Fork 22
/
test_lookup2.cc
164 lines (85 loc) · 2.54 KB
/
test_lookup2.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
// ** Copyright UCAR (c) 1992 - 2021
// ** University Corporation for Atmospheric Research (UCAR)
// ** National Center for Atmospheric Research (NCAR)
// ** Research Applications Lab (RAL)
// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
////////////////////////////////////////////////////////////////////////
static const bool debug = false;
////////////////////////////////////////////////////////////////////////
using namespace std;
#include <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <cmath>
#include "vx_util.h"
#include "config_file.h"
////////////////////////////////////////////////////////////////////////
static ConcatString program_name;
static MetConfig config;
////////////////////////////////////////////////////////////////////////
static void test_lookup(const char * name);
////////////////////////////////////////////////////////////////////////
int main(int argc, char * argv [])
{
program_name = get_short_name(argv[0]);
if ( argc == 1 ) {
cerr << "\n\n usage: " << program_name << " config_file_list\n\n";
exit ( 1 );
}
//
// redirect stderr to stdout
//
if ( dup2(1, 2) < 0 ) {
cerr << "\n\n " << program_name << ": dup2 failed\n\n";
exit ( 1 );
}
config.set_debug(debug);
int j;
bool status = false;
for (j=1; j<argc; ++j) { // j starts at one, here
status = config.read(argv[j]);
if ( ! status ) {
cerr << "\n\n " << program_name << ": failed to parse config file \"" << argv[j] << "\"\n\n";
exit ( 1 );
}
}
//
// test
//
test_lookup("top");
test_lookup("top.mid");
test_lookup("top.mid.there");
test_lookup("top.mid.hello");
test_lookup("top.mid.bot");
test_lookup("top.mid.bot.dolly");
test_lookup("top.mid.bot.there");
test_lookup("top.mid.bot.hello");
cout << "\n\n";
//
// done
//
return ( 0 );
}
////////////////////////////////////////////////////////////////////////
void test_lookup(const char * name)
{
const DictionaryEntry * e = (const DictionaryEntry *) 0;
e = config.lookup(name);
if ( !e ) {
cout << "\n\n " << program_name << ": lookup test for \"" << name << "\" failed!\n\n";
exit ( 1 );
}
//
// success
//
cout << "\n\n " << program_name << ": lookup test for \"" << name << "\" succeeded.\n\n";
e->dump(cout);
cout << "\n\n";
//
// done
//
return;
}
////////////////////////////////////////////////////////////////////////