File: dbfcstocs.t

package info (click to toggle)
cstocs 1%3A0.178-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 328 kB
  • ctags: 39
  • sloc: perl: 1,449; makefile: 39
file content (58 lines) | stat: -rw-r--r-- 1,218 bytes parent folder | download
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
#!/usr/bin/perl
###
# Cz::Cstocs.pm

BEGIN { $^W = 0; $| = 1;
	eval 'use XBase;';
	if ($@) {
		print "1..0\n";
		exit;
		}
	print "1..4\n";
	}

###

print "Calling the external dbfcstocs program\n";

use ExtUtils::testlib;
my $libs = join " -I", '', @INC;
my $TSTDBF = 'test.dbf';
$TSTDBF = 't/' . $TSTDBF if -d 't';
my $OUTDBF = 'out-test.dbf';
$OUTDBF = 't/' . $OUTDBF if -d 't';

print "$TSTDBF and $OUTDBF.\n";

unlink $OUTDBF;

system("$^X $libs blib/script/dbfcstocs --field-names-charset=ascii il2 ascii $TSTDBF $OUTDBF");

if (not -f $OUTDBF) {
	print "not ok 1\n";
	exit;
	}
print "ok 1\n";

print "Loading the output dbf.\n";
my $table = new XBase $OUTDBF;
unless (defined $table) {
	print "Error loading the output file: $XBase::errstr\nnot ok 2\n";
	exit;
	}
print "ok 2\n";

print "Checking field names.\n";
my @fields = $table->field_names;
if ("@fields" ne "ID JMENO BYDLISTE D_NAROZENI ODMENA VYSKA") {
	print "Field names (@fields) were not converted correctly.\nnot ";
	}
print "ok 3\n";

print "Checking data.\n";
my @data = $table->get_record(0);
if ("@data" ne "0 1 Malicky Jezecek Pareziste 123 19980416 1700 0.17") {
	print "Data (@data) was not converted correctly.\nnot ";
	}
print "ok 4\n";