add ConstraintSetIndexFactoryTest

This commit is contained in:
ucrhh 2021-02-11 11:15:42 +01:00
parent ad4581fffb
commit f614869677
2 changed files with 31 additions and 1 deletions

View File

@ -26,7 +26,7 @@ public class ConstraintSetIndexFactory {
*
* @return the next constraint set index
*/
public String nextConstraintSetIndex() {
protected String nextConstraintSetIndex() {
String index = nextConstraintSetIndex == FIRST_CONSTRAINT_SET_INDEX
? ""
: nextConstraintSetIndex == FIRST_CONSTRAINT_SET_INDEX + 1

View File

@ -0,0 +1,30 @@
package edu.kit.typicalc.view.content.typeinferencecontent.latexcreator;
import org.junit.jupiter.api.Test;
import java.lang.reflect.Field;
import static edu.kit.typicalc.view.content.typeinferencecontent.latexcreator.LatexCreatorConstants.*;
import static edu.kit.typicalc.view.content.typeinferencecontent.latexcreator.LatexCreatorConstants.CURLY_RIGHT;
import static org.junit.jupiter.api.Assertions.assertEquals;
class ConstraintSetIndexFactoryTest {
@Test
void nextConstraintSetIndexTest() throws NoSuchFieldException, IllegalAccessException {
Field field = ConstraintSetIndexFactory.class.getDeclaredField("FIRST_CONSTRAINT_SET_INDEX");
field.setAccessible(true);
int firstIndex = field.getInt(null);
ConstraintSetIndexFactory factory = new ConstraintSetIndexFactory();
assertEquals("", factory.nextConstraintSetIndex());
assertEquals("" + UNDERSCORE + CURLY_LEFT + LET + CURLY_RIGHT, factory.nextConstraintSetIndex());
assertEquals("" + UNDERSCORE + CURLY_LEFT + LET + UNDERSCORE
+ CURLY_LEFT + (firstIndex + 2) + CURLY_RIGHT + CURLY_RIGHT, factory.nextConstraintSetIndex());
assertEquals("" + UNDERSCORE + CURLY_LEFT + LET + UNDERSCORE
+ CURLY_LEFT + (firstIndex + 3) + CURLY_RIGHT + CURLY_RIGHT, factory.nextConstraintSetIndex());
assertEquals("" + UNDERSCORE + CURLY_LEFT + LET + UNDERSCORE
+ CURLY_LEFT + (firstIndex + 4) + CURLY_RIGHT + CURLY_RIGHT, factory.nextConstraintSetIndex());
}
}