mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-08 18:30:42 +00:00
Merge branch 'master' of https://git.scc.kit.edu/pse-typinferenz/typicalc
This commit is contained in:
commit
367c3be0e1
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user