From 4b448f097d559dca83e9611a40282dda01af4b59 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Tue, 1 Nov 2011 15:58:50 -0400 Subject: [PATCH] round numbers so that they can be compared --- t/58object.t | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/t/58object.t b/t/58object.t index 4da295be..28be915e 100644 --- a/t/58object.t +++ b/t/58object.t @@ -174,15 +174,24 @@ is_deeply([$row1[1]->attributes], ['NUM', 13, 'NAME', 'obj1'], "new: Row 1 colum ok (scalar @row2, 'new: Fetch second row'); cmp_ok(ref $row2[1], 'eq', 'DBD::Oracle::Object', 'new: Row 2 column 2 is an DBD::Oracle::Object'); cmp_ok(uc $row2[1]->type_name, "eq", uc "$schema.$sub_type", "new: Row 2 column 2 object type"); -is_deeply([$row2[1]->attributes], ['NUM', undef, 'NAME', 'obj2', - 'DATETIME', '2004-11-30T14:27:18', 'AMOUNT', 12345.6789], "new: Row 1 column 2 object attributes"); + +my %attrs = $row2[1]->attributes; + +$attrs{AMOUNT} = sprintf "%9.4f", $attrs{AMOUNT}; + +is_deeply( \%attrs, {'NUM', undef, 'NAME', 'obj2', + 'DATETIME', '2004-11-30T14:27:18', 'AMOUNT', '12345.6789'}, "new: Row 1 column 2 object attributes"); @row3 = $sth->fetchrow(); ok (scalar @row3, 'new: Fetch third row'); cmp_ok(ref $row3[1], 'eq', 'DBD::Oracle::Object', 'new: Row 3 column 2 is an DBD::Oracle::Object'); cmp_ok(uc $row3[1]->type_name, "eq", uc "$schema.$sub_type", "new: Row 3 column 2 object type"); -is_deeply([$row3[1]->attributes], ['NUM', 5, 'NAME', 'obj3', - 'DATETIME', undef, 'AMOUNT', 777.666], "new: Row 1 column 2 object attributes"); + +%attrs = $row3[1]->attributes; +$attrs{AMOUNT} = sprintf "%6.3f", $attrs{AMOUNT}; + +is_deeply( \%attrs, {'NUM', 5, 'NAME', 'obj3', + 'DATETIME', undef, 'AMOUNT', '777.666'}, "new: Row 1 column 2 object attributes"); ok (!$sth->fetchrow(), 'new: No more rows expected'); @@ -196,7 +205,10 @@ my $expected_hash = { DATETIME => undef, AMOUNT => 777.666, }; -is_deeply($obj->attr_hash, $expected_hash, 'DBD::Oracle::Object->attr_hash'); +my $attrs = $obj->attr_hash; +$attrs->{AMOUNT} = sprintf "%6.3f", $attrs->{AMOUNT}; + +is_deeply($attrs, $expected_hash, 'DBD::Oracle::Object->attr_hash'); is_deeply($obj->attr, $expected_hash, 'DBD::Oracle::Object->attr'); is($obj->attr("NAME"), 'obj3', 'DBD::Oracle::Object->attr("NAME")');