-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nbauma109
committed
May 21, 2023
1 parent
cfa2c5c
commit d96482d
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/test/java/org/jd/core/v1/model/javasyntax/statement/StatementsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.jd.core.v1.model.javasyntax.statement; | ||
|
||
import org.jd.core.v1.service.converter.classfiletojavasyntax.visitor.TestVisitor; | ||
import org.junit.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertThrows; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class StatementsTest { | ||
@Test | ||
public void testStatements() { | ||
// Test constructor with List | ||
Statement statement1 = new ExpressionStatement(null); | ||
Statement statement2 = new ExpressionStatement(null); | ||
Statements statementsWithList = new Statements(Arrays.asList(statement1, statement2)); | ||
assertTrue(statementsWithList.isStatements()); | ||
|
||
// Test constructor with single statement and statements array | ||
Statements statementsWithStatementArray = new Statements(statement1, statement2); | ||
assertTrue(statementsWithStatementArray.isStatements()); | ||
|
||
// Test IllegalArgumentException | ||
List<Statement> statements = Collections.singletonList(statement1); | ||
assertThrows(IllegalArgumentException.class, () -> new Statements(statements)); | ||
assertThrows(IllegalArgumentException.class, () -> new Statements(statement1)); | ||
|
||
// Test the accept method with a simple visitor | ||
TestVisitor visitor = new TestVisitor(); | ||
statementsWithStatementArray.accept(visitor); | ||
assertEquals(1, visitor.getStatementsCount()); | ||
} | ||
} |