|
| 1 | +############################################################################### |
| 2 | +# |
| 3 | +# Tests the output of Excel::Writer::XLSX against Excel generated files. |
| 4 | +# |
| 5 | +# Copyright 2000-2024, John McNamara, jmcnamara@cpan.org |
| 6 | +# |
| 7 | +# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later |
| 8 | +# |
| 9 | + |
| 10 | +use lib 't/lib'; |
| 11 | +use TestFunctions qw(_compare_xlsx_files _is_deep_diff); |
| 12 | +use strict; |
| 13 | +use warnings; |
| 14 | + |
| 15 | +use Test::More tests => 1; |
| 16 | + |
| 17 | +############################################################################### |
| 18 | +# |
| 19 | +# Tests setup. |
| 20 | +# |
| 21 | +my $filename = 'autofit14.xlsx'; |
| 22 | +my $dir = 't/regression/'; |
| 23 | +my $got_filename = $dir . "ewx_$filename"; |
| 24 | +my $exp_filename = $dir . 'xlsx_files/' . $filename; |
| 25 | + |
| 26 | +my $ignore_members = []; |
| 27 | +my $ignore_elements = {}; |
| 28 | + |
| 29 | + |
| 30 | +############################################################################### |
| 31 | +# |
| 32 | +# Test the creation of a simple Excel::Writer::XLSX file. |
| 33 | +# |
| 34 | +use Excel::Writer::XLSX; |
| 35 | + |
| 36 | +my $workbook = Excel::Writer::XLSX->new( $got_filename ); |
| 37 | +my $worksheet = $workbook->add_worksheet(); |
| 38 | + |
| 39 | +$worksheet->write_string( 0, 0, "This is some long text to test autofit" ); |
| 40 | + |
| 41 | +$worksheet->autofit(200); |
| 42 | + |
| 43 | +$workbook->close(); |
| 44 | + |
| 45 | + |
| 46 | +############################################################################### |
| 47 | +# |
| 48 | +# Compare the generated and existing Excel files. |
| 49 | +# |
| 50 | + |
| 51 | +my ( $got, $expected, $caption ) = _compare_xlsx_files( |
| 52 | + |
| 53 | + $got_filename, |
| 54 | + $exp_filename, |
| 55 | + $ignore_members, |
| 56 | + $ignore_elements, |
| 57 | +); |
| 58 | + |
| 59 | +_is_deep_diff( $got, $expected, $caption ); |
| 60 | + |
| 61 | + |
| 62 | +############################################################################### |
| 63 | +# |
| 64 | +# Cleanup. |
| 65 | +# |
| 66 | +unlink $got_filename; |
| 67 | + |
| 68 | +__END__ |
| 69 | +
|
| 70 | +
|
| 71 | +
|
0 commit comments