This repository has been archived by the owner on Dec 28, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial error handling code and tests.
- Loading branch information
Showing
9 changed files
with
201 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"caption" : "Test error handling.", | ||
"description" : "Reads a normal file without error.", | ||
"xlsx_file" : "data01.xlsx", | ||
"expected" : { | ||
"error_code" : 0, | ||
"error_text" : "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"caption" : "Test error handling.", | ||
"description" : "Returns error when file not found.", | ||
"xlsx_file" : "error01.xlsx", | ||
"expected" : { | ||
"error_code" : 1, | ||
"error_text" : "File not found. t/regression/xlsx_files/error01.xlsx" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"caption" : "Test error handling.", | ||
"description" : "Returns a zip error when not a valid zip file.", | ||
"xlsx_file" : "error02.xlsx", | ||
"expected" : { | ||
"error_code" : 2, | ||
"error_text" : "File has zip error. format error: can\'t find EOCD signature " | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
############################################################################### | ||
# | ||
# Tests for Excel::Writer::XLSX. | ||
# | ||
# reverse('©'), February 2012, John McNamara, jmcnamara@cpan.org | ||
# | ||
|
||
use lib 't/lib'; | ||
use TestFunctions qw(_is_deep_diff _read_json); | ||
use strict; | ||
use warnings; | ||
use Excel::Reader::XLSX; | ||
|
||
use Test::More tests => 1; | ||
|
||
############################################################################### | ||
# | ||
# Test setup. | ||
# | ||
my $json_filename = 't/regression/json_files/read_error00.json'; | ||
my $json = _read_json( $json_filename ); | ||
my $caption = $json->{caption}; | ||
my $expected = $json->{expected}; | ||
my $xlsx_file = 't/regression/xlsx_files/' . $json->{xlsx_file}; | ||
my $got; | ||
|
||
|
||
############################################################################### | ||
# | ||
# Test error handling when reading data from an Excel file. | ||
# | ||
use Excel::Reader::XLSX; | ||
|
||
my $reader = Excel::Reader::XLSX->new(); | ||
my $workbook = $reader->read_file( $xlsx_file ); | ||
|
||
$got = { | ||
error_code => $reader->error_code(), | ||
error_text => $reader->error(), | ||
}; | ||
|
||
# Test the results. | ||
_is_deep_diff( $got, $expected, $caption ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
############################################################################### | ||
# | ||
# Tests for Excel::Writer::XLSX. | ||
# | ||
# reverse('©'), February 2012, John McNamara, jmcnamara@cpan.org | ||
# | ||
|
||
use lib 't/lib'; | ||
use TestFunctions qw(_is_deep_diff _read_json); | ||
use strict; | ||
use warnings; | ||
use Excel::Reader::XLSX; | ||
|
||
use Test::More tests => 1; | ||
|
||
############################################################################### | ||
# | ||
# Test setup. | ||
# | ||
my $json_filename = 't/regression/json_files/read_error01.json'; | ||
my $json = _read_json( $json_filename ); | ||
my $caption = $json->{caption}; | ||
my $expected = $json->{expected}; | ||
my $xlsx_file = 't/regression/xlsx_files/' . $json->{xlsx_file}; | ||
my $got; | ||
|
||
|
||
############################################################################### | ||
# | ||
# Test error handling when reading data from an Excel file. | ||
# | ||
use Excel::Reader::XLSX; | ||
|
||
my $reader = Excel::Reader::XLSX->new(); | ||
my $workbook = $reader->read_file( $xlsx_file ); | ||
|
||
$got = { | ||
error_code => $reader->error_code(), | ||
error_text => $reader->error(), | ||
}; | ||
|
||
# Test the results. | ||
_is_deep_diff( $got, $expected, $caption ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
############################################################################### | ||
# | ||
# Tests for Excel::Writer::XLSX. | ||
# | ||
# reverse('©'), February 2012, John McNamara, jmcnamara@cpan.org | ||
# | ||
|
||
use lib 't/lib'; | ||
use TestFunctions qw(_is_deep_diff _read_json); | ||
use strict; | ||
use warnings; | ||
use Excel::Reader::XLSX; | ||
|
||
use Test::More tests => 1; | ||
|
||
############################################################################### | ||
# | ||
# Test setup. | ||
# | ||
my $json_filename = 't/regression/json_files/read_error02.json'; | ||
my $json = _read_json( $json_filename ); | ||
my $caption = $json->{caption}; | ||
my $expected = $json->{expected}; | ||
my $xlsx_file = 't/regression/xlsx_files/' . $json->{xlsx_file}; | ||
my $got; | ||
|
||
|
||
############################################################################### | ||
# | ||
# Test error handling when reading data from an Excel file. | ||
# | ||
use Excel::Reader::XLSX; | ||
|
||
my $reader = Excel::Reader::XLSX->new(); | ||
my $workbook = $reader->read_file( $xlsx_file ); | ||
|
||
$got = { | ||
error_code => $reader->error_code(), | ||
error_text => $reader->error(), | ||
}; | ||
|
||
# Test the results. | ||
_is_deep_diff( $got, $expected, $caption ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is just a text file to test error handling. |