Skip to content

Instantly share code, notes, and snippets.

@rhamedy
Created September 24, 2020 01:29
Show Gist options
  • Save rhamedy/b267c0bef327146fc4bafb091c983d63 to your computer and use it in GitHub Desktop.
Save rhamedy/b267c0bef327146fc4bafb091c983d63 to your computer and use it in GitHub Desktop.
Generated unit tests by Diffblue Cover plugin
package com.diffblue.demo;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
public class UtilityTest {
@Test
public void testSum() {
assertEquals(2, Utility.sum(1, 1));
}
@Test
public void testDivide() {
assertEquals(1.0, Utility.divide(1, 1));
assertThrows(RuntimeException.class, () -> Utility.divide(1, 0));
}
@Test
public void testIsColorSupported() {
assertTrue(Utility.isColorSupported(Utility.Color.RED));
}
@Test
public void testCalculateFactorial() {
assertEquals(3628800L, Utility.calculateFactorial(10));
}
@Test
public void testIsPrime() {
assertFalse(Utility.isPrime(1, 1));
assertTrue(Utility.isPrime(2, 1));
}
@Test
public void testIsEven() {
assertFalse(Utility.isEven(1));
assertTrue(Utility.isEven(0));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment