File: sub_write_colors.t

package info (click to toggle)
libexcel-writer-xlsx-perl 0.79-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 11,716 kB
  • ctags: 930
  • sloc: perl: 18,380; makefile: 40
file content (79 lines) | stat: -rw-r--r-- 2,061 bytes parent folder | download | duplicates (3)
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
###############################################################################
#
# Tests for Excel::Writer::XLSX::Package::Styles methods.
#
# reverse ('(c)'), February 2011, John McNamara, jmcnamara@cpan.org
#

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

use Test::More tests => 3;


###############################################################################
#
# Tests setup.
#
my $expected;
my $got;
my $caption;
my $style;


###############################################################################
#
# Test the _write_colors() method.
#
$caption  = " \tStyles: _write_colors()";
$expected = '<colors><mruColors><color rgb="FF26DA55"/></mruColors></colors>';

$style = _new_style(\$got);

$style->{_custom_colors} = [ 'FF26DA55' ];

$style->_write_colors();

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


###############################################################################
#
# Test the _write_colors() method.
#
$caption  = " \tStyles: _write_colors()";
$expected = '<colors><mruColors><color rgb="FF646462"/><color rgb="FF792DC8"/><color rgb="FF26DA55"/></mruColors></colors>';

$style = _new_style(\$got);

$style->{_custom_colors} = [ 'FF26DA55', 'FF792DC8', 'FF646462' ];

$style->_write_colors();

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


###############################################################################
#
# Test the _write_colors() method. Test that the mruColors are limited to 10.
#
$caption  = " \tStyles: _write_colors()";
$expected = '<colors><mruColors><color rgb="FFD97827"/><color rgb="FFB97847"/><color rgb="FF913AC6"/><color rgb="FFE3FA06"/><color rgb="FF0CF49C"/><color rgb="FF600FF1"/><color rgb="FFA1A759"/><color rgb="FFE31DAF"/><color rgb="FF583AC6"/><color rgb="FF5EA29C"/></mruColors></colors>';

$style = _new_style(\$got);

$style->{_custom_colors} = [
    'FF792DC8', 'FF646462', 'FF5EA29C', 'FF583AC6', 'FFE31DAF', 'FFA1A759',
    'FF600FF1', 'FF0CF49C', 'FFE3FA06', 'FF913AC6', 'FFB97847', 'FFD97827'
];

$style->_write_colors();

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


__END__