-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: assure no negative Ti and Td (#872)
* feat: assure no negative Ti and Td * feat: also check for Kp test: added tests
- Loading branch information
1 parent
b94fbd7
commit 94d3785
Showing
2 changed files
with
130 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
src/test/java/neqsim/processSimulation/controllerDevice/ControllerDeviceBaseClassTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package neqsim.processSimulation.controllerDevice; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ControllerDeviceBaseClassTest { | ||
|
||
static ControllerDeviceBaseClass c; | ||
|
||
@BeforeAll | ||
static void setUp() { | ||
c = new ControllerDeviceBaseClass("testPID"); | ||
} | ||
|
||
@Test | ||
void testSetControllerParameters() { | ||
double zero = 0; | ||
double positive = 9.9; | ||
double negative = -0.1; | ||
|
||
c.setControllerParameters(zero, zero, zero); | ||
|
||
Assertions.assertEquals(zero, c.getKp()); | ||
Assertions.assertEquals(zero, c.getTd()); | ||
Assertions.assertEquals(zero, c.getTi()); | ||
|
||
c.setControllerParameters(positive, positive, positive); | ||
Assertions.assertEquals(positive, c.getKp()); | ||
Assertions.assertEquals(positive, c.getTd()); | ||
Assertions.assertEquals(positive, c.getTi()); | ||
|
||
c.setControllerParameters(negative, positive, positive); | ||
Assertions.assertEquals(positive, c.getKp()); | ||
Assertions.assertEquals(positive, c.getTd()); | ||
Assertions.assertEquals(positive, c.getTi()); | ||
|
||
c.setControllerParameters(positive, negative, positive); | ||
Assertions.assertEquals(positive, c.getKp()); | ||
Assertions.assertEquals(positive, c.getTd()); | ||
Assertions.assertEquals(positive, c.getTi()); | ||
|
||
c.setControllerParameters(positive, positive, negative); | ||
Assertions.assertEquals(positive, c.getKp()); | ||
Assertions.assertEquals(positive, c.getTd()); | ||
Assertions.assertEquals(positive, c.getTi()); | ||
} | ||
|
||
@Test | ||
void testGetKp() { | ||
double kp = c.getKp(); | ||
Assertions.assertEquals(c.getKp(), kp); | ||
} | ||
|
||
@Test | ||
void testGetTd() { | ||
double td = c.getTd(); | ||
Assertions.assertEquals(c.getTd(), td); | ||
} | ||
|
||
@Test | ||
void testGetTi() { | ||
double ti = c.getTi(); | ||
Assertions.assertEquals(c.getTi(), ti); | ||
} | ||
|
||
@Test | ||
void testGetUnit() { | ||
String unit = c.getUnit(); | ||
Assertions.assertEquals(c.getUnit(), unit); | ||
} | ||
|
||
@Test | ||
void testIsReverseActing() { | ||
boolean isReverse = c.isReverseActing(); | ||
Assertions.assertEquals(isReverse, c.isReverseActing()); | ||
} | ||
|
||
@Test | ||
void testSetReverseActing() { | ||
boolean testValue = true; | ||
boolean oldValue = c.isReverseActing(); | ||
c.setReverseActing(testValue); | ||
Assertions.assertEquals(testValue, c.isReverseActing()); | ||
c.setReverseActing(oldValue); | ||
Assertions.assertEquals(oldValue, c.isReverseActing()); | ||
} | ||
|
||
@Test | ||
void testSetUnit() { | ||
String testUnit = "test"; | ||
String oldUnit = c.getUnit(); | ||
c.setUnit(testUnit); | ||
Assertions.assertEquals(testUnit, c.getUnit()); | ||
c.setUnit(oldUnit); | ||
Assertions.assertEquals(oldUnit, c.getUnit()); | ||
} | ||
} |