mirror of
https://gitlab.kit.edu/uskyk/typicalc.git
synced 2024-11-09 19:00:48 +00:00
test TreeNumberGenerator
This commit is contained in:
parent
9a12342c27
commit
e621c764be
@ -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