Project

General

Profile

Bug #439

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

Added by Lari Taskula over 1 year ago. Updated over 1 year 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

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

Actions

History

#1

Updated by Lari Taskula over 1 year ago

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

Updated by Lari Taskula over 1 year ago

Reopening, found another issue with float.

#3

Updated by Lari Taskula over 1 year ago

  • % Done changed from 100 to 50
#4

Updated by Lari Taskula over 1 year ago

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

Updated by Lari Taskula over 1 year 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

#6

Updated by Lari Taskula over 1 year 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.

Also available in: Atom PDF