Select Git revision
CenterDecorator.java
Forked from
SAYEH Nahlane ghina / graphic-2020..
Source project has a limited visibility.
-
SAYEH Nahlane ghina authoredSAYEH Nahlane ghina authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
BackPackSolverTest.java 994 B
package fr.univamu.progav.td2;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
class BackPackSolverTest {
private final static List<BackPackSolver.Item> ITEMS =
List.of(
new BackPackSolver.Item("Alfa",5,8),
new BackPackSolver.Item("Bravo",4,7),
new BackPackSolver.Item("Charlie",4,6),
new BackPackSolver.Item("Delta",3,4),
new BackPackSolver.Item("Echo",2,3)
);
public static final int AVAILABLE_VOLUME = 10;
@Test
void findBestValueBackpack() {
BackPackSolver bp = new BackPackSolver(ITEMS, AVAILABLE_VOLUME);
List<BackPackSolver.Item> selection = bp.findBestValueBackpack(0);
int totalVolume = selection.stream().mapToInt(BackPackSolver.Item::volume).sum();
int totalValue = selection.stream().mapToInt(BackPackSolver.Item::value).sum();
assertTrue(totalVolume <= AVAILABLE_VOLUME);
assertEquals(16,totalValue);
assertEquals(3,selection.size());
}
}