Imported Robodoc.
[robodoc.git] / Source / Test / multidoc_test1.pl
1 #!/usr/bin/perl -w
2 #
3
4 use strict;
5 use ROBOTest;
6 ROBOTest::start("Multidoc Test");
7
8 use IO::File;
9
10
11
12 sub Fail {
13     my $ok = shift;
14     if ( $ok ) {
15         print "OK\n";
16     } else {
17         print "FAIL\n";
18     }
19 }
20
21
22 sub Test_Master_Index {
23     my $mi = IO::File->new("Doc1/masterindex.html");
24     my @lines = <$mi>;
25     $mi->close;
26     my %seen = ();
27     my $ok = 1;
28
29     # All header types are in the source files,
30     # so they should also be listed in the master index.
31     # Lets test this.
32     foreach my $line (@lines) {
33         if ($line =~ m/top">([^<]+)<\/a>]/i) {
34             $seen{$1}++;
35         }
36     }
37     foreach my $file ("Modules", "Sourcefiles",
38                       "Classes", "Structures", "Functions",
39                       "Variables", "Procedures",
40                       "Types", "Exceptions", "Definitions" ) {
41         $ok = 0 unless ( defined($seen{$file}) and $seen{$file} == 1 );
42     }
43     # Test if all source files are listed.
44 #    foreach my $line (@lines) {
45 #        if (($line =~ m/Source\sFiles/) ..
46 #            ($line =~ m/\/table/i)) {
47 #            if ($line =~ m/([a-z][a-z]file\.dat)/) {
48 #                $seen{$1}++;
49 #            }
50 #        }
51 #    }
52 #    foreach my $file ( qw( ccfile.dat bbfile.dat aafile.dat) ) {
53 #        $ok = 0 unless ( defined($seen{$file}) and $seen{$file} == 1 );
54 #    }
55 #    # Test table for /****d* 
56 #    foreach my $line (@lines) {
57 #        if (($line =~ m/Constants/) ..
58 #            ($line =~ m/\/table/i)) {
59 #            if ($line =~ m/_test_(\S+)_test_/) {
60 #                $seen{$1}++;
61 #            }
62 #        }
63 #    }
64 #    foreach my $name ( qw( def1 def2 ) ) {
65 #        $ok = 0 unless ( defined($seen{$name}) and $seen{$name} == 1 );
66 #    }
67 #    # Test table for /****f*
68 #    foreach my $line (@lines) {
69 #        if (($line =~ m/Functions/) ..
70 #        ($line =~ m/\/table/i)) {
71 #            if ($line =~ m/_test_(\S+)_test_/) {
72 #                $seen{$1}++;
73 #            }
74 #        }
75 #    }
76 #    foreach my $name ( qw( fun1 fun2 ) ) {
77 #        $ok = 0 unless ( defined($seen{$name}) and $seen{$name} == 1 );
78 #    }
79 #    # Test table for /****c*
80 #    foreach my $line (@lines) {
81 #        if (($line =~ m/Classes/) ..
82 #        ($line =~ m/\/table/i)) {
83 #            if ($line =~ m/_test_(\S+)_test_/) {
84 #                $seen{$1}++;
85 #            }
86 #        }
87 #    }
88 #    foreach my $name ( qw( class1 class2 class3 ) ) {
89 #        $ok = 0 unless ( defined($seen{$name}) and $seen{$name} == 1 );
90 #    }
91     return $ok;
92 }
93
94 #
95 # This tests the TOC of aafile.dat
96 #
97 #
98 sub Test_aafile_dat {
99     my $mi = IO::File->new("Doc1/aafile_dat.html");
100     my @lines = <$mi>;
101     $mi->close;
102     my %seen = ();
103     my $ok = 1;
104     # Scan the table of content
105     foreach my $line (@lines) {
106         if (($line =~ m/TABLE\sOF\sCONTENTS/i) ..
107         ($line =~ m/\/UL/i)) {
108             if ($line =~ m/\/([ABCD][ab][ab]__level\d__)/) {
109                 $seen{$1}++;
110             }
111         }
112     }
113     foreach my $name ( qw( Aaa__level1__ Bbb__level2__ Abb__level3__ Bbb__level3__ Cbb__level3__  Dbb__level3__ ) ) {
114         $ok = 0 unless ( defined($seen{$name}) and $seen{$name} == 1 );
115     }
116
117     return $ok;
118 }
119
120 ROBOTest::assertFile("Doc1/masterindex.html");
121 ROBOTest::assertDir("Doc1/Subdir");
122 ROBOTest::assertFile("Doc1/Subdir/ccfile_dat.html");
123 ROBOTest::assertFile("Doc1/aafile_dat.html");
124 ROBOTest::assertFile("Doc1/bbfile_dat.html");
125 ROBOTest::assert( Test_Master_Index(), "Master index content" );
126 ROBOTest::assert( Test_aafile_dat(), "aafile TOC" );
127
128 ROBOTest::finish;