-
-
Notifications
You must be signed in to change notification settings - Fork 571
Floating long to long #8159
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
Floating long to long #8159
Conversation
…nt numbers, and fix handling of wrapping mek energy to other types (other types to mek already had the handling)
…E for if something is at 1 J
| double defaultConversion = 2.5; | ||
| double inverseConversion = 1 / defaultConversion; | ||
| int capacity = 1_000; | ||
| int convertedCapacity = (int) (capacity / defaultConversion); |
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 think for a test, this should be a fixed value, and the calculation in a comment. Personally I'd also put them in screaming snake case for readability
| //Ensure the config starts out at the default value | ||
| .thenExecute(() -> MekanismConfig.general.forgeConversionRate.set(defaultConversion)) | ||
|
|
||
| // WRAPPING STRICT ENERGY TO FORGE ENERGY |
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.
these test should have extra comments detailing why they're doing what they're doing. e.g. "insert more than converted capacity", "ensure capped at converted amount"
| int accepted = handler.receiveEnergy(capacity, false); | ||
| helper.assertValueEqual(accepted, 0, "accepted energy"); | ||
| //Note: Needed energy should be 1 even though we can't accept it | ||
| helper.assertValueEqual(handler.getEnergyStored(), convertedCapacity - 1, "stored energy"); |
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 would have done this the other way. Calculation should go in the first argument, expected result should be 1
| int accepted = handler.receiveEnergy(capacity, false); | ||
| helper.assertValueEqual(accepted, 0, "accepted energy"); | ||
| }) | ||
| //Test against a small empty container |
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.
test what against an empty container. If 1RF is 2.5 Joules, shouldn't it store 2 Joules?
| helper.assertValueEqual(extracted, 0, "extracted energy"); | ||
| int accepted = handler.receiveEnergy(capacity, false); | ||
| helper.assertValueEqual(accepted, convertedCapacity, "accepted energy"); | ||
| helper.assertValueEqual(handler.getEnergyStored(), convertedCapacity, "stored energy"); |
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.
these checks should not use wrappers.
interact via the wrappers, check with the unwrapped storage. Applies to all these tests
Changes proposed in this pull request:
Change
FloatingLongtolong