############################################################################### # # Tests for Excel::Writer::XLSX::Worksheet methods. # # Copyright 2000-2021, John McNamara, jmcnamara@cpan.org # use lib 't/lib'; use TestFunctions qw(_expected_to_aref _got_to_aref _is_deep_diff _new_worksheet); use strict; use warnings; use Test::More tests => 1; ############################################################################### # # Tests setup. # my $expected; my $got; my $caption; my $worksheet; ############################################################################### # # Test the _assemble_xml_file() method. # # Test conditional formats. # $caption = " \tWorksheet: _assemble_xml_file()"; $worksheet = _new_worksheet(\$got); $worksheet->select(); # Start test code. $worksheet->write( 'A1', 10 ); $worksheet->write( 'A2', 20 ); $worksheet->write( 'A3', 30 ); $worksheet->write( 'A4', 40 ); $worksheet->conditional_formatting( 'A1:A4', { type => 'time_period', criteria => 'yesterday', format => undef, } ); $worksheet->conditional_formatting( 'A1:A4', { type => 'time_period', criteria => 'today', format => undef, } ); $worksheet->conditional_formatting( 'A1:A4', { type => 'time_period', criteria => 'tomorrow', format => undef, } ); $worksheet->conditional_formatting( 'A1:A4', { type => 'time_period', criteria => 'last 7 days', format => undef, } ); $worksheet->conditional_formatting( 'A1:A4', { type => 'time_period', criteria => 'last week', format => undef, } ); $worksheet->conditional_formatting( 'A1:A4', { type => 'time_period', criteria => 'this week', format => undef, } ); $worksheet->conditional_formatting( 'A1:A4', { type => 'time_period', criteria => 'next week', format => undef, } ); $worksheet->conditional_formatting( 'A1:A4', { type => 'time_period', criteria => 'last month', format => undef, } ); $worksheet->conditional_formatting( 'A1:A4', { type => 'time_period', criteria => 'this month', format => undef, } ); $worksheet->conditional_formatting( 'A1:A4', { type => 'time_period', criteria => 'next month', format => undef, } ); # End test code. $worksheet->_assemble_xml_file(); $expected = _expected_to_aref(); $got = _got_to_aref( $got ); _is_deep_diff( $got, $expected, $caption ); __DATA__ 10 20 30 40 FLOOR(A1,1)=TODAY()-1 FLOOR(A1,1)=TODAY() FLOOR(A1,1)=TODAY()+1 AND(TODAY()-FLOOR(A1,1)<=6,FLOOR(A1,1)<=TODAY()) AND(TODAY()-ROUNDDOWN(A1,0)>=(WEEKDAY(TODAY())),TODAY()-ROUNDDOWN(A1,0)<(WEEKDAY(TODAY())+7)) AND(TODAY()-ROUNDDOWN(A1,0)<=WEEKDAY(TODAY())-1,ROUNDDOWN(A1,0)-TODAY()<=7-WEEKDAY(TODAY())) AND(ROUNDDOWN(A1,0)-TODAY()>(7-WEEKDAY(TODAY())),ROUNDDOWN(A1,0)-TODAY()<(15-WEEKDAY(TODAY()))) AND(MONTH(A1)=MONTH(TODAY())-1,OR(YEAR(A1)=YEAR(TODAY()),AND(MONTH(A1)=1,YEAR(A1)=YEAR(TODAY())-1))) AND(MONTH(A1)=MONTH(TODAY()),YEAR(A1)=YEAR(TODAY())) AND(MONTH(A1)=MONTH(TODAY())+1,OR(YEAR(A1)=YEAR(TODAY()),AND(MONTH(A1)=12,YEAR(A1)=YEAR(TODAY())+1)))