This commit is contained in:
Johanna Stuber 2021-02-11 10:12:30 +01:00
commit 367c3be0e1
2 changed files with 41 additions and 0 deletions

View File

@ -14,6 +14,9 @@ public class TreeNumberGenerator {
}
protected void push() {
if (current < 0) {
throw new IllegalStateException("The first step must add a step to the tree");
}
numbers.add(current);
}

View File

@ -0,0 +1,38 @@
package edu.kit.typicalc.view.content.typeinferencecontent.latexcreator;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
class TreeNumberGeneratorTest {
@Test
void normalFunctionalityTest() {
List<Integer> expected = List.of(0, 1, 1, 1, 2, 2, 3);
TreeNumberGenerator generator = new TreeNumberGenerator();
generator.incrementPush();
generator.incrementPush();
generator.push();
generator.push();
generator.incrementPush();
generator.push();
generator.incrementPush();
List<Integer> actual = generator.getNumbers();
assertEquals(expected.size(), actual.size());
for (int i = 0; i < expected.size(); i++) {
assertEquals(expected.get(i), actual.get(i));
}
}
@Test
void pushExceptionTest() {
TreeNumberGenerator generator = new TreeNumberGenerator();
assertThrows(IllegalStateException.class, generator::push);
}
}