File: sub_write_cell.t

package info (click to toggle)
libexcel-writer-xlsx-perl 1.07-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 16,256 kB
  • sloc: perl: 21,048; makefile: 40
file content (97 lines) | stat: -rw-r--r-- 2,347 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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
###############################################################################
#
# Tests for Excel::Writer::XLSX::Worksheet methods.
#
# Copyright 2000-2020, John McNamara, jmcnamara@cpan.org
#

use lib 't/lib';
use TestFunctions '_new_worksheet';
use strict;
use warnings;

use Test::More tests => 5;

###############################################################################
#
# Tests setup.
#
my $expected;
my $got;
my $caption;
my $worksheet;
my $format = undef;

###############################################################################
#
# Test the _write_cell() method for numbers.
#
$caption  = " \tWorksheet: _write_cell()";
$expected = '<c r="A1"><v>1</v></c>';

$worksheet = _new_worksheet(\$got);

$worksheet->_write_cell( 0, 0, [ 'n', 1 ] );

is( $got, $expected, $caption );


###############################################################################
#
# Test the _write_cell() method for strings.
#
$caption  = " \tWorksheet: _write_cell()";
$expected = '<c r="B4" t="s"><v>0</v></c>';

$worksheet = _new_worksheet(\$got);

$worksheet->_write_cell( 3, 1, [ 's', 0 ] );

is( $got, $expected, $caption );


###############################################################################
#
# Test the _write_cell() method for formulas with an optional value.
#
$caption  = " \tWorksheet: _write_cell()";
$expected = '<c r="C2"><f>A3+A5</f><v>0</v></c>';

$worksheet = _new_worksheet(\$got);

$worksheet->_write_cell( 1, 2, [ 'f', 'A3+A5', $format, 0 ] );

is( $got, $expected, $caption );


###############################################################################
#
# Test the _write_cell() method for formulas without an optional value.
#
$caption  = " \tWorksheet: _write_cell()";
$expected = '<c r="C2"><f>A3+A5</f><v>0</v></c>';

$worksheet = _new_worksheet(\$got);

$worksheet->_write_cell( 1, 2, [ 'f', 'A3+A5'] );

is( $got, $expected, $caption );


###############################################################################
#
# Test the _write_cell() method for array formulas with an optional value.
#
$caption  = " \tWorksheet: _write_cell()";
$expected = '<c r="A1"><f t="array" ref="A1">SUM(B1:C1*B2:C2)</f><v>9500</v></c>';

$worksheet = _new_worksheet(\$got);

$worksheet->_write_cell( 0, 0, [ 'a', 'SUM(B1:C1*B2:C2)', $format, 'A1', 9500 ] );

is( $got, $expected, $caption );


__END__