root/libswish3/tags/10Feb2008/src/test.pl

Revision 1913, 1.4 kB (checked in by karpet, 2 years ago)

for all the world to see

  • Property svn:executable set to
Line 
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 21;
7
8
9 my %docs = (
10     'UPPERlower.XML'   => '17',
11     'badxml.xml'       => '10',
12     'contractions.xml' => '13',
13     'foo.txt'          => '16',
14     'latin1.xml'       => '3',
15     'latin1.txt'       => '3',
16     'min.txt'          => '1',
17     'multi_props.xml'  => '25',
18     'nested_meta.xml'  => '18',
19     't.html'           => '6',
20     'testutf.xml'      => '8746',   #'8685',
21     'utf.xml'          => '30',
22     'words.txt'        => '55',
23     'words.xml'        => '52',
24     'has_nulls.txt'    => '13',
25     'no_such_file.txt' => '0',
26     'meta.html'        => '23',
27     'empty_doc.html'   => '0',
28     'no_words.html'    => '0',
29     'html_broken.html' => '2',
30
31            );
32            
33 my %stdindocs = (
34     'doc.xml'           => '8404'
35    
36     );
37
38 for my $file (sort keys %docs)
39 {
40     cmp_ok(words($file), '==', $docs{$file}, "$file -> $docs{$file} words");
41 }
42
43 for my $file (sort keys %stdindocs)
44 {
45     cmp_ok(fromstdin($file), '==', $stdindocs{$file}, "stdin $file -> $stdindocs{$file} words");
46 }
47
48 sub words
49 {
50     my $file = shift;
51     my $o = join(' ', `./swish_lint test_docs/$file`);
52     my ($count) = ($o =~ m/nwords: (\d+)/);
53     return $count || 0;
54 }
55
56 sub fromstdin
57 {
58     my $file = shift;
59     my $o = join(' ', `./swish_lint - < test_stdin/$file`);
60     my ($count) = ($o =~ m/nwords: (\d+)/);
61     return $count || 0;
62 }
Note: See TracBrowser for help on using the browser.