use Test::More tests => 5; use HTML::GenToc; # Insert your test code below #=================================================== $toc = new HTML::GenToc(debug=>0, quiet=>1); #---------------------------------------------------------- # string input and output $html1 ="
This is a paragraph.
Another paragraph.
"; $html2 ="This is a paragraph.
Another paragraph.
"; $out_str = $toc->generate_toc( make_anchors=>1, make_toc=>0, to_string=>1, filenames=>["fred.html"], input=>$html1, toc_entry=>{ 'H1' =>1, 'H2' =>2, }, toc_end=>{ 'H1' =>'/H1', 'H2' =>'/H2', }, ); is($out_str, $html2, "(1) generate_anchors matches strings"); $out_str = $toc->generate_toc( make_anchors=>0, make_toc=>1, to_string=>1, filenames=>["fred.html"], input=>$html2, ); $ok_toc_str1='This is a paragraph.
Another paragraph.
'; is($out_str, $ok_toc_str2, "(3) generate_toc matches inline toc string"); # # Reset undef $toc; $toc = new HTML::GenToc(debug=>0, quiet=>1); $html1 ="This is a paragraph.
Another paragraph.
"; $html2 ="This is a paragraph.
Another paragraph.
"; $out_str = $toc->generate_toc( make_anchors=>1, make_toc=>0, to_string=>1, use_id=>1, filenames=>["fred.html"], input=>$html1, toc_entry=>{ 'H1' =>1, 'H2' =>2, }, toc_end=>{ 'H1' =>'/H1', 'H2' =>'/H2', }, ); is($out_str, $html2, "(4) generate_anchors (id) matches strings"); $out_str = $toc->generate_toc( make_anchors=>0, make_toc=>1, to_string=>1, filenames=>["fred.html"], input=>$html2, ); $ok_toc_str1='