-
Notifications
You must be signed in to change notification settings - Fork 31
update the match flags to 64 bit #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6a0a88f
update the match flags to 64 bit and adjust some things with the part…
phlptp 38471ff
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 00497d7
test the setDefaultFlags and minimum partition
phlptp fd52e3e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 968c626
declare constant type for older C++ standards
phlptp 5aa63b6
clean up code a bit and add missing test
phlptp ab08313
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4898919
update conversion flags documentation
phlptp 9c9c624
Merge branch 'match_flags_update' of https://github.com/LLNL/units in…
phlptp 774d305
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,6 +142,7 @@ TEST(unitStrings, siPrefixes) | |
| TEST(unitStrings, siPrefixesStrict) | ||
| { | ||
| EXPECT_EQ(to_string(unit_from_string("mm", strict_si)), "mm"); | ||
| EXPECT_EQ(to_string(unit_from_string("mF", strict_si)), "mF"); | ||
| EXPECT_EQ(to_string(unit_from_string("cm", strict_si)), "cm"); | ||
| EXPECT_EQ(to_string(unit_from_string("um", strict_si)), "um"); | ||
| EXPECT_EQ(to_string(unit_from_string("nm", strict_si)), "nm"); | ||
|
|
@@ -694,7 +695,8 @@ TEST(stringToUnits, exponentForms) | |
| EXPECT_EQ( | ||
| (precise::micro * precise::meter).pow(2), unit_from_string("um2")); | ||
| EXPECT_EQ(precise::cm.pow(5), unit_from_string("cm5")); | ||
| EXPECT_EQ(unit_from_string("CM2", true), unit_from_string("cm2")); | ||
| EXPECT_EQ( | ||
| unit_from_string("CM2", case_insensitive), unit_from_string("cm2")); | ||
| } | ||
|
|
||
| TEST(stringToUnits, complex) | ||
|
|
@@ -753,13 +755,16 @@ TEST(stringToUnits, equivalents) | |
| EXPECT_EQ(unit_from_string("/gram"), unit_from_string("/g")); | ||
| EXPECT_EQ(unit_from_string(" per g"), precise::g.inv()); | ||
| EXPECT_EQ(unit_from_string("/deciliter"), unit_from_string("/dL")); | ||
| EXPECT_EQ(unit_from_string("DM2/S2", true), unit_from_string("dm2/s2")); | ||
| EXPECT_EQ( | ||
| unit_from_string("DM2/S2", case_insensitive), | ||
| unit_from_string("dm2/s2")); | ||
| EXPECT_EQ(unit_from_string("/cu. m"), m.pow(3).inv()); | ||
| EXPECT_EQ(unit_from_string("a gregorian"), precise::time::ag); | ||
| EXPECT_EQ(unit_from_string("cubic inches"), unit_from_string("[cin_i]")); | ||
| EXPECT_EQ(unit_from_string("/mcl"), unit_from_string("/uL")); | ||
| EXPECT_EQ(unit_from_string("/sec"), unit_from_string("/s")); | ||
| EXPECT_EQ(unit_from_string("g.m"), unit_from_string("gram meter")); | ||
| EXPECT_EQ(unit_from_string("gf.m"), unit_from_string("gram-force meter")); | ||
| } | ||
|
|
||
| TEST(stringToUnits, equivalents2) | ||
|
|
@@ -984,6 +989,60 @@ TEST(stringToUnits, invalid) | |
| EXPECT_FALSE(is_valid(unit_from_string("_liquid_()"))); | ||
| } | ||
|
|
||
| TEST(stringToUnits, ParseIssues) | ||
| { | ||
| auto u1 = unit_from_string("Metres"); | ||
| EXPECT_EQ(u1, precise::m); | ||
|
|
||
| u1 = unit_from_string("degrees C"); | ||
| EXPECT_EQ(u1, precise::degC); | ||
|
|
||
| u1 = unit_from_string("gramm"); | ||
| EXPECT_EQ(u1, precise::g * precise::m); | ||
| u1 = unit_from_string("kilogramm"); | ||
| EXPECT_EQ(u1, precise::kilo * precise::g * precise::m); | ||
|
Comment on lines
+1000
to
+1003
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel that this is a very surprising behavior. Mixing full words (kilo and gram) with symbols (m), especially without an operator or spacing in between is not really intuitive and of limited use? Supporting |
||
| } | ||
|
|
||
| TEST(stringToUnits, partitionMinimum) | ||
| { | ||
| auto u1 = unit_from_string("milefoot"); | ||
| EXPECT_EQ(u1, precise::mile * precise::ft); | ||
|
|
||
| u1 = unit_from_string("milefoot", minimum_partition_size2); | ||
| EXPECT_EQ(u1, precise::mile * precise::ft); | ||
|
|
||
| u1 = unit_from_string("milefoot", minimum_partition_size3); | ||
| EXPECT_EQ(u1, precise::mile * precise::ft); | ||
|
|
||
| u1 = unit_from_string("milefoot", minimum_partition_size4); | ||
| EXPECT_EQ(u1, precise::mile * precise::ft); | ||
|
|
||
| u1 = unit_from_string("milefoot", minimum_partition_size5); | ||
| EXPECT_TRUE(is_error(u1)); | ||
|
|
||
| u1 = unit_from_string("milefoot", minimum_partition_size6); | ||
| EXPECT_TRUE(is_error(u1)); | ||
|
|
||
| u1 = unit_from_string("milefoot", minimum_partition_size7); | ||
| EXPECT_TRUE(is_error(u1)); | ||
| } | ||
|
|
||
| TEST(stringToUnits, partitionMinimumDefault) | ||
| { | ||
| auto u1 = unit_from_string("mifoot"); | ||
| EXPECT_EQ(u1, precise::mile * precise::ft); | ||
|
|
||
| auto prev = setDefaultFlags(minimum_partition_size3); | ||
| EXPECT_EQ(prev, 0ULL); | ||
| EXPECT_EQ(getDefaultFlags(), minimum_partition_size3); | ||
|
|
||
| u1 = unit_from_string("mifoot"); | ||
| EXPECT_TRUE(is_error(u1)); | ||
|
|
||
| prev = setDefaultFlags(0ULL); | ||
| EXPECT_EQ(prev, minimum_partition_size3); | ||
| } | ||
|
|
||
| TEST(userDefinedUnits, definitions) | ||
| { | ||
| precise_unit clucks(19.3, precise::m * precise::A); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentionally commented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am changing the domain codes so this relationship doesn't hold at present, there may be further modifications to restore them but not sure what the best approach is yet.