|
1 | 1 | package com.thealgorithms.greedyalgorithms;
|
2 | 2 |
|
3 |
| -import org.junit.jupiter.api.Test; |
4 | 3 | import static org.junit.jupiter.api.Assertions.*;
|
| 4 | +import org.junit.jupiter.api.Test; |
5 | 5 |
|
6 | 6 | import java.util.List;
|
7 | 7 |
|
8 | 8 | public class EgyptianFractionTest {
|
| 9 | + EgyptianFraction ef = new EgyptianFraction(); |
| 10 | + |
9 | 11 | @Test
|
10 |
| - public void testGetEgyptianFraction() { |
11 |
| - EgyptianFraction ef = new EgyptianFraction(); |
| 12 | + public void testGetEgyptianFraction_NormalCase() { |
12 | 13 | List<String> result = ef.getEgyptianFraction(5, 6);
|
13 | 14 | assertEquals(List.of("1/2", "1/3"), result);
|
14 | 15 | }
|
| 16 | + |
| 17 | + @Test |
| 18 | + public void testGetEgyptianFraction_SimpleFraction() { |
| 19 | + List<String> result = ef.getEgyptianFraction(1, 2); |
| 20 | + assertEquals(List.of("1/2"), result); |
| 21 | + } |
| 22 | + |
| 23 | + @Test |
| 24 | + public void testGetEgyptianFraction_WholeNumber() { |
| 25 | + List<String> result = ef.getEgyptianFraction(2, 1); |
| 26 | + assertEquals(List.of("1/1", "1/2", "1/3", "1/6"), result); // Example output |
| 27 | + } |
| 28 | + |
| 29 | + @Test |
| 30 | + public void testGetEgyptianFraction_OneOverOne() { |
| 31 | + List<String> result = ef.getEgyptianFraction(1, 1); |
| 32 | + assertEquals(List.of("1/1"), result); |
| 33 | + } |
| 34 | + |
| 35 | + @Test |
| 36 | + public void testGetEgyptianFraction_OneOverThree() { |
| 37 | + List<String> result = ef.getEgyptianFraction(1, 3); |
| 38 | + assertEquals(List.of("1/3"), result); |
| 39 | + } |
15 | 40 | }
|
0 commit comments