Skip to content

Unit test focusing on hard-coded constants - #44

Closed
hugovdm wants to merge 5 commits into
sffc:units-stagingfrom
hugovdm:units_constants
Closed

hugovdm wants to merge 5 commits into
sffc:units-stagingfrom
hugovdm:units_constants

Conversation

@hugovdm

@hugovdm hugovdm commented May 26, 2020 •

Copy link
Copy Markdown
Collaborator

Blocked on #48 which will open up some internals for more direct testing.

Checklist

This includes a Markdown document describing plans for ICU4J and then
possibly backporting to ICU4C.
@hugovdm
hugovdm requested review from sffc and younies and removed request for sffc and younies May 26, 2020 18:02
cleaned up before merging into the upstream unicode-org ICU repository. Some of
this content belongs in header files.

## Internal Implementation Details: ICU4C

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation docs should go as comments in the header or source files.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm moving this to a Google Doc - much easier to comment/discuss, and intended as a way to help us better structure our approach to ICU4J.


// Tests freshness of the constants in units.txt by simply loading each directly
// specified conversion rate into UnitConverter.
void UnitsTest::testConstantFreshness() {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you testing? There are no assertions in this function.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example output when I change the "acre to meter-squared" definition to use a non-existent "acore_to_m2" constant:

     testConstantFreshness data: expected success but got error: U_INVALID_FORMAT_ERROR - UnitConverter(<acre>, <square-meter>, status).
     If U_INVALID_FORMAT_ERROR, please check that "icu4c/source/i18n/unitconverter.cpp" has all constants?
     Factor for "acre" is: "acre_to_m2".
     Full list of constants: "G" "PI" "ft2_to_m2" "ft3_to_m3" "ft_to_m" "gal_imp_to_m3" "gal_to_m3" "gravity" "in3_to_m3" "lb_to_kg" - (Are you missing data?)

@hugovdm hugovdm changed the title Unit test focusing on hard-coded constants. Add: docs/plans. Unit test focusing on hard-coded constants Jun 9, 2020
@hugovdm
hugovdm marked this pull request as draft June 16, 2020 16:57
@hugovdm

hugovdm commented Jul 10, 2020

Copy link
Copy Markdown
Collaborator Author

Closing this PR in favour of icu-units#20 - its first commit (678b3d5) is a squashed version of this PR, rebased on units-staging.

@hugovdm hugovdm closed this Jul 10, 2020
@hugovdm
hugovdm deleted the units_constants branch July 10, 2020 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants