Download benchmarks/reference/java-fraction.junit4.java from SevdanurGenc/LLM-Automated-Test-Generation-Agent: direct link, hf CLI and curl.
- Browser
- Download file 1.94 kB
-
https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/reference/java-fraction.junit4.java
- Command line
-
hf download hf://SevdanurGenc/LLM-Automated-Test-Generation-Agent/benchmarks/reference/java-fraction.junit4.java
-
curl -L -o java-fraction.junit4.java https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/reference/java-fraction.junit4.java
1.94 kB
| import org.junit.Test; | |
| import static org.junit.Assert.*; | |
| public class FractionTest { | |
| public void reducesAndNormalizesSign() { | |
| Fraction f = new Fraction(4, -8); | |
| assertEquals(-1, f.numerator()); | |
| assertEquals(2, f.denominator()); | |
| assertEquals("-1/2", f.toString()); | |
| } | |
| public void wholeNumberToString() { assertEquals("3", new Fraction(6, 2).toString()); } | |
| public void zeroIsZeroOverOne() { | |
| Fraction z = new Fraction(0, 5); | |
| assertEquals(0, z.numerator()); | |
| assertEquals(1, z.denominator()); | |
| } | |
| public void zeroDenominator() { new Fraction(1, 0); } | |
| public void add() { assertEquals(new Fraction(5, 6), new Fraction(1, 2).add(new Fraction(1, 3))); } | |
| public void subtract() { assertEquals(new Fraction(1, 6), new Fraction(1, 2).subtract(new Fraction(1, 3))); } | |
| public void multiply() { assertEquals(new Fraction(1, 6), new Fraction(1, 2).multiply(new Fraction(1, 3))); } | |
| public void divide() { assertEquals(new Fraction(3, 2), new Fraction(1, 2).divide(new Fraction(1, 3))); } | |
| public void divideByZero() { new Fraction(1, 2).divide(new Fraction(0, 3)); } | |
| public void toDouble() { assertEquals(0.75, new Fraction(3, 4).toDouble(), 1e-12); } | |
| public void compare() { | |
| assertTrue(new Fraction(1, 3).compareTo(new Fraction(1, 2)) < 0); | |
| assertTrue(new Fraction(2, 3).compareTo(new Fraction(1, 2)) > 0); | |
| assertEquals(0, new Fraction(2, 4).compareTo(new Fraction(1, 2))); | |
| } | |
| public void equalsAndHashCode() { | |
| Fraction a = new Fraction(2, 4), b = new Fraction(1, 2); | |
| assertEquals(a, b); | |
| assertEquals(a.hashCode(), b.hashCode()); | |
| assertEquals(a, a); | |
| assertNotEquals(a, new Fraction(1, 3)); | |
| assertNotEquals(a, "1/2"); | |
| } | |
| } | |