Skip to content

Commit

Permalink
Add tests for new method
Browse files Browse the repository at this point in the history
  • Loading branch information
dabico committed Feb 6, 2024
1 parent 404cfc9 commit 2794af1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/test/java/ch/usi/si/seart/treesitter/LanguageTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ch.usi.si.seart.treesitter;

import lombok.Cleanup;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -100,4 +102,21 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext extensionCo
void testAssociatedWithThrows(Class<Throwable> throwableType, Path path) {
Assertions.assertThrows(throwableType, () -> Language.associatedWith(path));
}

@Test
void testNextState() {
Language language = Language.PYTHON;
@Cleanup Parser parser = Parser.getFor(language);
@Cleanup Tree tree = parser.parse("pass");
Node root = tree.getRootNode();
Assertions.assertEquals(0, language.nextState(root));
}

@Test
void testNextStateThrows() {
Assertions.assertThrows(NullPointerException.class, () -> Language.JAVA.nextState(null));
Assertions.assertThrows(NullPointerException.class, () -> Language._INVALID_.nextState(null));
Assertions.assertThrows(IllegalArgumentException.class, () -> Language.JAVA.nextState(empty));
Assertions.assertThrows(IllegalArgumentException.class, () -> Language._INVALID_.nextState(empty));
}
}

0 comments on commit 2794af1

Please # to comment.