File: 04_md.t

package info (click to toggle)
libhtml-format-perl 2.16-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 404 kB
  • sloc: perl: 2,018; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 1,044 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
use strict;
use warnings;
use File::Spec;    # try to keep pathnames neutral
use Test::More 0.96;

use lib 't/lib';
use Test::HTML::Formatter;

Test::HTML::Formatter->test_files(
    class_suffix       => 'FormatMarkdown',
    filename_extension => 'md',
    callback_test_file => sub {
        my ( $self, $infile, $expfile ) = @_;

        # read file content - split into lines, but we exclude the
        # doccomm line since it includes a timestamp and version information
        open( my $fh, '<', $expfile ) or die "Unable to open expected file $expfile - $!\n";
        my $exp_text = do { local ($/); <$fh> };
        my $exp_lines = [ split( /\n/, $exp_text ) ];

        # read and convert file
        my $text = HTML::FormatMarkdown->format_file( $infile, leftmargin => 5, rightmargin => 50 );
        my $got_lines = [ split( /\n/, $text ) ];

        ok( length($text), '  Returned a string from conversion' );
        is_deeply( $got_lines, $exp_lines, '  Correct text string returned' );
    }
);

# finish up
done_testing();