Skip to content

Commit

Permalink
Tell apart unit tests from integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
irzinfante committed Sep 25, 2022
1 parent 3c7e0c1 commit c842369
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>eu.irzinfante</groupId>
<artifactId>fixed-mps</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import eu.irzinfante.fixedmps.util.MPSUtil;
import eu.irzinfante.fixedmps.core.Constraint.ConstraintBuilder;

public class MPSTest {
public class IntegrationsTests {

@Test
public void defaultTest() {
Expand Down
53 changes: 53 additions & 0 deletions src/test/java/eu/irzinfante/fixedmps/UnitTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package eu.irzinfante.fixedmps;

import static org.junit.Assert.*;

import org.junit.Test;

import eu.irzinfante.fixedmps.core.Constraint;
import eu.irzinfante.fixedmps.core.Constraint.ConstraintBuilder;
import eu.irzinfante.fixedmps.core.Variable;
import eu.irzinfante.fixedmps.core.Variable.VarBuilder;

public class UnitTests {

@Test
public void variableTest() {
Variable variable1 = new VarBuilder().build();
assertEquals(0, variable1.getObjCoeff(), 0);
assertEquals(0, variable1.getLowerBound(), 0);
assertEquals(Double.MAX_VALUE, variable1.getUpperBound(), 0);
assertFalse(variable1.isInteger());

Variable variable2 = new VarBuilder(1).lowerBound(-10).upperBound(5).integer().build();
assertEquals(1, variable2.getObjCoeff(), 0);
assertEquals(-10, variable2.getLowerBound(), 0);
assertEquals(5, variable2.getUpperBound(), 0);
assertTrue(variable2.isInteger());

Variable variable3 = new VarBuilder(-5).binary();
assertEquals(-5, variable3.getObjCoeff(), 0);
assertEquals(0, variable3.getLowerBound(), 0);
assertEquals(1, variable3.getUpperBound(), 0);
assertTrue(variable3.isInteger());
}

@Test
public void constraintTest() {
Constraint constraint1 = new ConstraintBuilder(0, 1, 2).greaterThan(1);
assertArrayEquals(new double[] {0, 1, 2}, constraint1.getCoeffs(), 0);
assertEquals(1, constraint1.getFree(), 0);
assertEquals('G', constraint1.getType());

Constraint constraint2 = new ConstraintBuilder(-2, 2).lessThan(13);
assertArrayEquals(new double[] {-2, 2}, constraint2.getCoeffs(), 0);
assertEquals(13, constraint2.getFree(), 0);
assertEquals('L', constraint2.getType());

Constraint constraint3 = new ConstraintBuilder(3.14).equalTo(0);
assertArrayEquals(new double[] {3.14}, constraint3.getCoeffs(), 0);
assertEquals(0, constraint3.getFree(), 0);
assertEquals('E', constraint3.getType());
}

}

0 comments on commit c842369

Please sign in to comment.