-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.pl
More file actions
159 lines (125 loc) · 4.42 KB
/
Copy pathtest.pl
File metadata and controls
159 lines (125 loc) · 4.42 KB
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
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
BEGIN { $| = 1; print "1..1\n"; }
use strict;
use CIsam;
use eg::Person;
my $loaded = 1;
print "ok 1\n";
######################### End of black magic.
my $ps = new Person(IsamObjects::BUILD);
my $di;
$di = $ps->{ISAM_OBJ}->isindexinfo(0);
print "di_nkeys = " . $di->di_nkeys . "\n";
print "di_recsize = " . $di->di_recsize . "\n";
print "di_idxsize = " . $di->di_idxsize . "\n";
print "di_nrecords = " . $di->di_nrecords . "\n";
$ps->clear();
$ps->path("foo");
$ps->{last_name} = "chane";
$ps->{first_name} = "phil";
$ps->{phone} = 81857887;
$ps->{age} = 10;
$ps->{net_worth} = 5.78;
$ps->{account_balance} = -4090.45;
$ps->add();
printf ("Wrote to db:\n");
printf ("last_name = chane\n");
printf ("first_name = phil\n");
printf ("phone = 81857887\n");
printf ("age = 10\n");
printf ("net_worth = 5.78\n");
printf ("account_balance = -4090.45\n");
$ps->{last_name} = "chane you kaye";
$ps->{first_name} = "maria";
$ps->{phone} = 10928831;
$ps->{age} = 15;
$ps->{net_worth} = 17328105.00;
$ps->{account_balance} = 0.00;
$ps->add();
printf ("Wrote to db:\n");
printf ("last_name = chane you kaye\n");
printf ("first_name = maria\n");
printf ("phone = 10928831\n");
printf ("age = 15\n");
printf ("net_worth = 17328105.00\n");
printf ("account_balance = 0.00\n");
print "listing using index foo\n";
print "Make sure that the values written to db and values read from db match!\n";
$ps->path("foo");
$ps->get(&ISFIRST);
printf("Last Name: %s\n", $ps->{last_name});
printf("First Name: %s\n", $ps->{first_name});
printf("Age: %d\n", $ps->{age});
printf("Phone: %d\n", $ps->{phone});
printf("Net Worth: %f\n", $ps->{net_worth});
printf("Account Balance: %f\n\n\n", $ps->{account_balance});
while ($ps->get(&ISNEXT))
{
printf("Last Name: %s\n", $ps->{last_name});
printf("First Name: %s\n", $ps->{first_name});
printf("Age: %d\n", $ps->{age});
printf("Phone: %d\n", $ps->{phone});
printf("Net Worth: %f\n", $ps->{net_worth});
printf("Account Balance: %f\n\n\n", $ps->{account_balance});
}
print "listing using index bar\n";
print "Make sure that the values written to db and values read from db match!\n";
$ps->path("bar");
$ps->get(&ISFIRST);
printf("Last Name: %s\n", $ps->{last_name});
printf("First Name: %s\n", $ps->{first_name});
printf("Age: %d\n", $ps->{age});
printf("Phone: %d\n", $ps->{phone});
printf("Net Worth: %f\n", $ps->{net_worth});
printf("Account Balance: %f\n\n\n", $ps->{account_balance});
while ($ps->get(&ISNEXT))
{
printf("Last Name: %s\n", $ps->{last_name});
printf("First Name: %s\n", $ps->{first_name});
printf("Age: %d\n", $ps->{age});
printf("Phone: %d\n", $ps->{phone});
printf("Net Worth: %f\n", $ps->{net_worth});
printf("Account Balance: %f\n\n\n", $ps->{account_balance});
}
$ps->clear();
$ps->{last_name} = "chane you kaye";
$ps->{first_name} = "maria";
$ps->get(&ISEQUAL) or die "error" . "$ps->{ISAM_OBJ}->iserrno" . " isread ";
$ps->{phone} = 92212107;
$ps->{age} = 30;
$ps->{net_worth} = 890380.09;
$ps->{account_balance} = -90.67;
$ps->update();
printf ("Updated the db:\n");
printf ("last_name = chane you kaye\n");
printf ("first_name = maria\n");
printf ("phone = 92212107\n");
printf ("age = 30\n");
printf ("net_worth = 890380.09\n");
printf ("account_balance = -90.67\n");
print "listing using index bar\n";
print "Make sure that the values written to db and values read from db match!\n";
$ps->path("bar");
$ps->get(&ISFIRST);
printf("Last Name: %s\n", $ps->{last_name});
printf("First Name: %s\n", $ps->{first_name});
printf("Age: %d\n", $ps->{age});
printf("Phone: %d\n", $ps->{phone});
printf("Net Worth: %f\n", $ps->{net_worth});
printf("Account Balance: %f\n\n\n", $ps->{account_balance});
while ($ps->get(&ISNEXT))
{
printf("Last Name: %s\n", $ps->{last_name});
printf("First Name: %s\n", $ps->{first_name});
printf("Age: %d\n", $ps->{age});
printf("Phone: %d\n", $ps->{phone});
printf("Net Worth: %f\n", $ps->{net_worth});
printf("Account Balance: %f\n\n\n", $ps->{account_balance});
}
printf("Deleting test db ...\n");
$ps->{ISAM_OBJ}->iserase("person");
END {print "not ok 1\n" unless $loaded;}