my
$loaded
;
BEGIN { $| = 1;
print
"1..20\n"
; }
END {
print
"not ok 1\n"
unless
$loaded
;}
$loaded
= 1;
print
"ok 1\n"
;
@Text::CSV::Base::ISA
=
qw(Text::CSV)
;
my
$empty
= Text::CSV::Base->new();
if
(
$empty
->version() and
$empty
->parse(
''
) and
$empty
->combine(
''
)) {
print
"ok 2\n"
;
}
else
{
print
"not ok 2\n"
;
}
my
$csv
= Text::CSV::Base->new( {
always_quote
=> 1 } );
if
(!
$csv
->combine()) {
print
"ok 3\n"
;
}
else
{
print
"not ok 3\n"
;
}
if
(!
$csv
->combine(
'abc'
,
"def\n"
,
'ghi'
)) {
print
"ok 4\n"
;
}
else
{
print
"not ok 4\n"
;
}
if
(
$csv
->combine(
''
) && (
$csv
->string eq
q("")
)) {
print
"ok 5\n"
;
}
else
{
print
"not ok 5\n"
;
}
if
(
$csv
->combine(
''
,
''
) && (
$csv
->string eq
q("","")
)) {
print
"ok 6\n"
;
}
else
{
print
"not ok 6\n"
;
}
if
(
$csv
->combine(
''
,
'I said, "Hi!"'
,
''
) &&
(
$csv
->string eq
q("","I said, ""Hi!""","")
)) {
print
"ok 7\n"
;
}
else
{
print
"not ok 7\n"
;
}
if
(
$csv
->combine(
'"'
,
'abc'
) && (
$csv
->string eq
q("""","abc")
)) {
print
"ok 8\n"
;
}
else
{
print
"not ok 8\n"
;
}
if
(
$csv
->combine(
'abc'
,
'"'
) && (
$csv
->string eq
q("abc","""")
)) {
print
"ok 9\n"
;
}
else
{
print
"not ok 9\n"
;
}
if
(
$csv
->combine(
'abc'
,
'def'
,
'ghi'
) &&
(
$csv
->string eq
q("abc","def","ghi")
)) {
print
"ok 10\n"
;
}
else
{
print
"not ok 10\n"
;
}
if
(
$csv
->combine(
"abc\tdef"
,
'ghi'
) &&
(
$csv
->string eq
qq("abc\tdef","ghi")
)) {
print
"ok 11\n"
;
}
else
{
print
"not ok 11\n"
;
}
if
(!
$csv
->parse()) {
print
"ok 12\n"
;
}
else
{
print
"not ok 12\n"
;
}
if
(!
$csv
->parse(
'"abc'
)) {
print
"ok 13\n"
;
}
else
{
print
"not ok 13\n"
;
}
if
(!
$csv
->parse(
'ab"c'
)) {
print
"ok 14\n"
;
}
else
{
print
"not ok 14\n"
;
}
if
(!
$csv
->parse(
'"ab"c"'
)) {
print
"ok 15\n"
;
}
else
{
print
"not ok 15\n"
;
}
if
(!
$csv
->parse(
qq("abc\nc")
)) {
print
"ok 16\n"
;
}
else
{
print
"not ok 16\n"
;
}
if
(!
$csv
->status()) {
print
"ok 17\n"
;
}
else
{
print
"not ok 17\n"
;
}
if
(
$csv
->parse(
q(",")
) and (
$csv
->fields())[0] eq
','
) {
print
"ok 18\n"
;
}
else
{
print
"not ok 18\n"
;
}
if
(
$csv
->parse(
qq("","I said,\t""Hi!""","")
) and
(
$csv
->fields())[0] eq
''
and
(
$csv
->fields())[1] eq
qq(I said,\t"Hi!")
and
(
$csv
->fields())[2] eq
''
) {
print
"ok 19\n"
;
}
else
{
print
"not ok 19\n"
;
}
if
(
$csv
->status()) {
print
"ok 20\n"
;
}
else
{
print
"not ok 20\n"
;
}