summaryrefslogtreecommitdiff
path: root/tests/versekeytest.cpp
blob: 90248be23261abdc308286b696deee315c53cc1a (plain)
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
 * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
 *	CrossWire Bible Society
 *	P. O. Box 2528
 *	Tempe, AZ  85280-2528
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation version 2.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 */

#include <iostream>
#include <stdio.h>
#include <stdlib.h>

#include <versekey.h>
#include <listkey.h>
#include <localemgr.h>
#include <swmgr.h>
#include <swmodule.h>
#ifndef NO_SWORD_NAMESPACE
using namespace sword;
#endif

using std::cout;
using std::endl;

int main(int argc, char **argv) {
/*
VerseKey currentVerse;
currentVerse.AutoNormalize(0);
currentVerse.Headings(1);
currentVerse.Persist(1);
currentVerse = "jn2";
cout << currentVerse << endl;

	SWMgr mgr;
	SWModule *mod = mgr.getModule("KJVgb");
*/
	VerseKey *parser = new VerseKey(); //(VerseKey *)mod->CreateKey();

	ListKey scope = parser->ParseVerseList("amos 2:2", *parser, true);

	cout << ((scope++ == scope) ? "single" : "multiple") << "\n";

	scope = parser->ParseVerseList("amos", *parser, true);

	cout << ((scope++ == scope) ? "single" : "multiple") << "\n";

	scope = parser->ParseVerseList("amos", *parser, true);

	ListKey result;

	scope++;
	scope++;
	scope++;
	scope++;

	VerseKey *x = new VerseKey(); //(VerseKey *)mod->CreateKey();
	*x = scope;
	x->clearBound();

	std::cout << "x: " << x->getText() << "\n";

	result << *x;

	std::cout << result.getText() << "\n";

	result = TOP;

	std::cout << result.getText() << "\n";

     const char *bounds = "lk,acts";
     scope = parser->ParseVerseList(bounds, *parser, true);

     VerseKey boundTest("lk", "acts");

     boundTest.setText("Is.1.13");
     std::cout << "Error: " << (int)boundTest.Error() << ": " << boundTest << "\n";
     boundTest.setText("1Sam.21.1");
     std::cout << "Error: " << (int)boundTest.Error() << ": " << boundTest << "\n";
     boundTest.setText("acts.5.1");
     std::cout << "Error: " << (int)boundTest.Error() << ": " << boundTest << "\n";
     boundTest.setText("rom.5.1");
     std::cout << "Error: " << (int)boundTest.Error() << ": " << boundTest << "\n";


     *x = "Is.1.13";
     scope = *x;
//     if (scope == x) std::cout << "Error restricting bounds: " << x.getText() << " is in " << bounds << "\n";
     if (!scope.Error()) std::cout << "Error restricting bounds: " << x->getText() << " is in " << bounds << "\n";

     *x = "1Sam.21.1";
     scope = *x;
     if (!scope.Error()) std::cout << "Error restricting bounds: " << x->getText() << " is in " << bounds << "\n";

/*
	VerseKey *y = (VerseKey *)mod->CreateKey();
	(*y) = "lev 1.1";
	cout << (*y) << "\n";
	(*y)++;
	cout << (*y) << "\n";
	(*y)--;
	cout << (*y) << "\n";
	(*y)--;
	cout << (*y) << "\n";

	mod->setKey("Ruth 1.1");
	cout << mod->getKeyText() << "\n";
	(*mod)++;
	cout << mod->getKeyText() << "\n";
	(*mod)--;
	cout << mod->getKeyText() << "\n";
*/
	VerseKey vk;

	cout << "\nNormalization on; headings on ====\n\n";

	vk.AutoNormalize(1);
	vk.Headings(1);

	vk = "jn3.50";
/* TODO: these report 1 number off from what I think they should report 
	cout << "jn.3.50: " << vk << "\n";
	vk++;
	cout << "++: " << vk << "\n";
	vk--;
	cout << "--: " << vk << "\n";
*/
	vk = MAXVERSE;
	cout << "MAXVERSE: " << vk << "\n";
	vk = MAXCHAPTER;
	cout << "MAXCHAPTER: " << vk << "\n";
	vk = TOP;
	cout << "TOP: " << vk << "\n";
	vk = BOTTOM;
	cout << "BOTTOM: " << vk << "\n";

	cout << "\nNormalization off; headings on ====\n\n";
	
	vk.AutoNormalize(0);
	vk.Headings(1);

	vk = "jn3.50";
	cout << "jn.3.50: " << vk << "\n";
/* TODO: These probably are undefined and likely to be ok
	vk++;
	cout << "++: " << vk << "\n";
	vk--;
	cout << "--: " << vk << "\n";
	vk = MAXVERSE;
	cout << "MAXVERSE: " << vk << "\n";
*/
	vk = MAXCHAPTER;
	cout << "MAXCHAPTER: " << vk << "\n";
	vk = TOP;
	cout << "TOP: " << vk << "\n";
	vk = BOTTOM;
	cout << "BOTTOM: " << vk << "\n";

	cout << "\nNormalization on; headings off ====\n\n";
	
	vk.AutoNormalize(1);
	vk.Headings(0);

	vk = "jn3.50";
	cout << "jn.3.50: " << vk << "\n";
	vk++;
	cout << "++: " << vk << "\n";
	vk--;
	cout << "--: " << vk << "\n";
	vk = MAXVERSE;
	cout << "MAXVERSE: " << vk << "\n";
	vk = MAXCHAPTER;
	cout << "MAXCHAPTER: " << vk << "\n";
	vk = TOP;
	cout << "TOP: " << vk << "\n";
	vk = BOTTOM;
	cout << "BOTTOM: " << vk << "\n";

	cout << "\nNormalization off; headings off ====\n\n";
	
	vk.AutoNormalize(0);
	vk.Headings(0);

	vk = "jn3.50";
	cout << "jn.3.50: " << vk << "\n";
/* TODO: These probably are undefined and likely to be ok
	vk++;
	cout << "++: " << vk << "\n";
	vk--;
	cout << "--: " << vk << "\n";
	vk = MAXVERSE;
	cout << "MAXVERSE: " << vk << "\n";
*/
	vk = MAXCHAPTER;
	cout << "MAXCHAPTER: " << vk << "\n";
	vk = TOP;
	cout << "TOP: " << vk << "\n";
	vk = BOTTOM;
	cout << "BOTTOM: " << vk << "\n";

	VerseKey yo = "jn.3.16";
	VerseKey yo2 = yo++;
	cout << yo2 << ": " << (int)yo2.Error() <<  endl;

	VerseKey vkey;
	VerseKey tmpkey = "1sam 1:1";
	vkey.AutoNormalize(1);                          // line 147
	vkey = tmpkey;
	int chapter = (vkey.Chapter()-1);
	vkey.Chapter(chapter);

	cout << tmpkey << ": Chapter() - 1: " << vkey << endl;


	return 0;
}