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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
###############################################################################
#
# Tests for Excel::Writer::XLSX::Worksheet methods.
#
# Copyright 2000-2023, John McNamara, jmcnamara@cpan.org
#
use strict;
use warnings;
use Excel::Writer::XLSX::Worksheet;
use Test::More tests => 2337;
###############################################################################
#
# Tests setup.
#
# Function for testing.
sub width_to_pixels {
my $width = shift;
my $max_digit_width = 7;
my $padding = 5;
my $pixels;
if ( $width < 1 ) {
$pixels = int( $width * ( $max_digit_width + $padding ) + 0.5 );
}
else {
$pixels = int( $width * $max_digit_width + 0.5 ) + $padding;
}
return $pixels;
}
# Function for testing.
sub height_to_pixels {
my $height = shift;
return int( 4 / 3 * $height );
}
###############################################################################
#
# Test _pixel_to_width().
#
for my $pixels ( 0 .. 1790 ) {
my $caption = " \tWorksheet: _pixel_to_width()";
my $got = width_to_pixels( Excel::Writer::XLSX::Worksheet::_pixels_to_width( $pixels ) );
my $expected = $pixels;
is( $got, $expected, $caption );
}
###############################################################################
#
# Test _pixel_to_height().
#
for my $pixels ( 0 .. 545 ) {
my $caption = " \tWorksheet: _pixel_to_height()";
my $got = height_to_pixels( Excel::Writer::XLSX::Worksheet::_pixels_to_height( $pixels ) );
my $expected = $pixels;
is( $got, $expected, $caption );
}
__END__
|