Skip to content

Commit

Permalink
round numbers so that they can be compared
Browse files Browse the repository at this point in the history
  • Loading branch information
yanick committed Nov 1, 2011
1 parent 706e45b commit 4b448f0
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions t/58object.t
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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")');

Expand Down

0 comments on commit 4b448f0

Please sign in to comment.