Annotation of loncom/cfgedittests/lookup.t, revision 1.2
1.1 foxr 1: #
1.2 ! foxr 2: # $Id: lookup.t,v 1.1.1.1 2003/11/25 12:12:34 foxr Exp $
1.1 foxr 3: #
4: # Copyright Michigan State University Board of Trustees
5: #
6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
7: #
8: # LON-CAPA is free software; you can redistribute it and/or modify
9: # it under the terms of the GNU General Public License as published by
10: # the Free Software Foundation; either version 2 of the License, or
11: # (at your option) any later version.
12: #
13: # LON-CAPA is distributed in the hope that it will be useful,
14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: # GNU General Public License for more details.
17: #
18: # You should have received a copy of the GNU General Public License
19: # along with LON-CAPA; if not, write to the Free Software
20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21: #
22: # /home/httpd/html/adm/gpl.txt
23: #
24: # http://www.lon-capa.org/
25: #
26: use strict;
27: use Test;
28: use ConfigFileEdit;
29:
30:
31: # Test indexing functions.
32: # 1. Find a known line by indexing its key field.
33: # 2. Fail to find a line that's not there.
34: #
35:
36: BEGIN {plan tests=>2}
37:
38: #
39: # Test that we can lookup a line with a known ok index.
40: #
41: sub TestOkIndex {
42: my $editor = ConfigFileEdit->new("test2config.cfg", 0);
43:
44: my $line = $editor->Find("line2");
45: if(!defined($line)) {
46: ok(0);
47: }
48: if($line eq "line2:another line:field:field") {
49: ok(1);
50: } else {
51: ok(0);
52: }
53: }
54: #
55: # Test that we cannot find a line that's not there.
56: #
57: sub TestBadIndex {
58: my $editor = ConfigFileEdit->new("test2config.cfg", 0);
59:
60: my $line = $editor->Find("trash");
61: if(!defined($line)) {
62: ok(1);
63: } else {
64: ok(0);
65: }
66: }
67:
68:
69:
70: TestOkIndex;
71: TestBadIndex;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>