File: workbook_get_worksheet_by_name.t

package info (click to toggle)
libexcel-writer-xlsx-perl 0.95-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 14,056 kB
  • ctags: 985
  • sloc: perl: 19,659; makefile: 40
file content (55 lines) | stat: -rw-r--r-- 1,303 bytes parent folder | download | duplicates (2)
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
###############################################################################
#
# Tests for Excel::Writer::XLSX::Workbook methods.
#
# reverse ('(c)'), MAy 2016, John McNamara, jmcnamara@cpan.org
#

use lib 't/lib';
use TestFunctions qw(_expected_to_aref _got_to_aref _is_deep_diff _new_workbook);
use strict;
use warnings;

use Test::More tests => 4;


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


###############################################################################
#
# Test the get_worksheet_by_name() method.
#
$caption = " \tWorkbook: get_worksheet_by_name()";

$workbook = _new_workbook(\$got);

# Test a valid implicit name.
$expected = $workbook->add_worksheet();
$got      = $workbook->get_worksheet_by_name('Sheet1');
is($got, $expected, $caption);

# Test a valid explicit name.
$expected = $workbook->add_worksheet('Sheet 2');
$got      = $workbook->get_worksheet_by_name('Sheet 2');
is($got, $expected, $caption);

# Test an invalid name.
$expected = undef;
$got      = $workbook->get_worksheet_by_name('Sheet3');
is($got, $expected, $caption);

# Test an invalid name.
$expected = undef;
$got      = $workbook->get_worksheet_by_name();
is($got, $expected, $caption);