[ 
https://issues.apache.org/jira/browse/YUNIKORN-1403?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17734979#comment-17734979
 ] 

Wilfred Spiegelenburg commented on YUNIKORN-1403:
-------------------------------------------------

The addition of the equal sign sounds reasonable. These tests added to the file 
with the change do trigger the correct overflows then:
{code:java}
    checkOverflow(0, 1000)
    checkOverflow(0, 1000)
    checkOverflow(math.MaxInt64, 10)
    checkOverflow(math.MinInt64, 10) {code}
The last two represent the current overflow tests and they both trigger 
correctly and return the correct values.

We do not need to "clamp" as it is implicitly done by the {{absResValue := 
int64(div)}} call. The overflow check is informative. The code will give you 
the most correct value it can in the case of an overflow.

> CalculateAbsUsedCapacity: overflow unit tests
> ---------------------------------------------
>
>                 Key: YUNIKORN-1403
>                 URL: https://issues.apache.org/jira/browse/YUNIKORN-1403
>             Project: Apache YuniKorn
>          Issue Type: Improvement
>          Components: core - common, test - unit
>            Reporter: Wilfred Spiegelenburg
>            Assignee: Simon Blessenohl
>            Priority: Major
>              Labels: newbie, pull-request-available
>
> CalculateAbsUsedCapacity is guarded against positive and negative overflow. 
> The postive case is unit tested. The negative case is not unit tested.
> Need to add a test case for te negative side:
> {code}
> // protect against negative integer overflow
> if absResValue > 0 && div < 0 {
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to