Files
spring-soap/testing-modules/junit-4/src/main/java/com/baeldung/junitparams/SafeAdditionUtil.java

16 lines
360 B
Java

package com.baeldung.junitparams;
public class SafeAdditionUtil {
public int safeAdd(int a, int b) {
long result = ((long) a) + b;
if (result > Integer.MAX_VALUE) {
return Integer.MAX_VALUE;
} else if (result < Integer.MIN_VALUE) {
return Integer.MIN_VALUE;
}
return (int) result;
}
}