Project

General

Profile

Actions

Bug #439

closed

Bug 27630 - TestBuilder real number precision to use column's size

Added by Lari Taskula about 3 years ago. Updated about 3 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
Target version:
-
Start date:
04.02.2021
Due date:
% Done:

100%

Estimated time:
Spent time:
Sponsored-by:
The National Library of Finland
Koha Bugzilla Bug#:

Description

t::lib::TestBuilder::_gen_real() always returns 2 decimal places no matter the column's size definition.

TestBuilder.pm _gen_real()
printf("%.2f", rand($max-0.1));

Our database has decimal type columns with higher than 2 decimal places. This makes comparing structures with Test::More::is_deeply impossible when the other object is built by TestBuilder, and the other fetched from database, as seen here:

  1. Structures begin differing at:
  2. $got->[0]{amount} = '90203.710000'
  3. $expected->[0]{amount} = '90203.71'

Related issues 1 (1 open0 closed)

Blocks Koha Contributions - Feature #421: Bug 20028 - Export all patron related personal data in one packageIn ProgressLari Taskula26.01.2021

Actions
Actions #1

Updated by Lari Taskula about 3 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 100
Actions #2

Updated by Lari Taskula about 3 years ago

Reopening, found another issue with float.

Actions #3

Updated by Lari Taskula about 3 years ago

  • % Done changed from 100 to 50
Actions #4

Updated by Lari Taskula about 3 years ago

  • Blocks Feature #421: Bug 20028 - Export all patron related personal data in one package added
Actions #5

Updated by Lari Taskula about 3 years ago

Created attachment 116342 [details] [review]
Bug 27630: Add test to prove different behavior with floats

To test:
1. prove t/db_dependent/TestBuilder.t
2. It might or might not pass all tests - if it passes, run it again until you
get the following error (always with either the "float" or "double" steps):

ok 5 - decimal - Builder builds same precision as DBIx returns.
not ok 6 - float - Builder builds same precision as DBIx returns.
Failed test 'float - Builder builds same precision as DBIx returns.'
at t/db_dependent/TestBuilder.t line 112.
got: '51.7080'
expected: '51.708'
Looks like you failed 1 test of 7.

Sponsored-by: The National Library of Finland

Actions #6

Updated by Lari Taskula about 3 years ago

  • Status changed from In Progress to Rejected
  • % Done changed from 50 to 100

Marking this as rejected. Using TestBuilder's build_object() is enough for now.

Actions

Also available in: Atom PDF