-
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
d96482d
commit 7aaf1f3
Showing
5 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
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
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
35 changes: 35 additions & 0 deletions
35
src/test/java/org/jd/core/v1/model/javasyntax/statement/DoWhileStatementTest.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,35 @@ | ||
package org.jd.core.v1.model.javasyntax.statement; | ||
|
||
import org.jd.core.v1.model.javasyntax.expression.Expression; | ||
import org.jd.core.v1.model.javasyntax.expression.IntegerConstantExpression; | ||
import org.jd.core.v1.service.converter.classfiletojavasyntax.visitor.TestVisitor; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class DoWhileStatementTest { | ||
|
||
@Test | ||
public void testDoWhileStatement() { | ||
// Test constructor | ||
Expression condition = new IntegerConstantExpression(1, 10); | ||
BaseStatement statements = new Statements(); | ||
DoWhileStatement doWhileStatement = new DoWhileStatement(condition, statements); | ||
|
||
assertTrue(doWhileStatement.getCondition() instanceof IntegerConstantExpression); | ||
assertEquals(10, doWhileStatement.getCondition().getIntegerValue()); | ||
assertTrue(doWhileStatement.getStatements() instanceof Statements); | ||
assertTrue(doWhileStatement.isDoWhileStatement()); | ||
|
||
// Test the setCondition method | ||
Expression newCondition = new IntegerConstantExpression(1, 20); | ||
doWhileStatement.setCondition(newCondition); | ||
assertEquals(20, doWhileStatement.getCondition().getIntegerValue()); | ||
|
||
// Test the accept method with a simple visitor | ||
TestVisitor visitor = new TestVisitor(); | ||
doWhileStatement.accept(visitor); | ||
assertEquals(1, visitor.getDoWhileStatementCount()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/test/java/org/jd/core/v1/model/javasyntax/statement/IfStatementTest.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,35 @@ | ||
package org.jd.core.v1.model.javasyntax.statement; | ||
|
||
import org.jd.core.v1.model.javasyntax.expression.Expression; | ||
import org.jd.core.v1.model.javasyntax.expression.IntegerConstantExpression; | ||
import org.jd.core.v1.service.converter.classfiletojavasyntax.visitor.TestVisitor; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class IfStatementTest { | ||
|
||
@Test | ||
public void testIfStatement() { | ||
// Test constructor | ||
Expression condition = new IntegerConstantExpression(1, 10); | ||
BaseStatement statements = new Statements(); | ||
IfStatement ifStatement = new IfStatement(condition, statements); | ||
|
||
assertTrue(ifStatement.getCondition() instanceof IntegerConstantExpression); | ||
assertEquals(10, ifStatement.getCondition().getIntegerValue()); | ||
assertTrue(ifStatement.getStatements() instanceof Statements); | ||
assertTrue(ifStatement.isIfStatement()); | ||
|
||
// Test the setCondition method | ||
Expression newCondition = new IntegerConstantExpression(1, 20); | ||
ifStatement.setCondition(newCondition); | ||
assertEquals(20, ifStatement.getCondition().getIntegerValue()); | ||
|
||
// Test the accept method with a simple visitor | ||
TestVisitor visitor = new TestVisitor(); | ||
ifStatement.accept(visitor); | ||
assertEquals(1, visitor.getIfStatementCount()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/test/java/org/jd/core/v1/model/javasyntax/statement/WhileStatementTest.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,35 @@ | ||
package org.jd.core.v1.model.javasyntax.statement; | ||
|
||
import org.jd.core.v1.model.javasyntax.expression.Expression; | ||
import org.jd.core.v1.model.javasyntax.expression.IntegerConstantExpression; | ||
import org.jd.core.v1.service.converter.classfiletojavasyntax.visitor.TestVisitor; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class WhileStatementTest { | ||
|
||
@Test | ||
public void testWhileStatement() { | ||
// Test constructor | ||
Expression condition = new IntegerConstantExpression(1, 10); | ||
BaseStatement statements = new Statements(); | ||
WhileStatement whileStatement = new WhileStatement(condition, statements); | ||
|
||
assertTrue(whileStatement.getCondition() instanceof IntegerConstantExpression); | ||
assertEquals(10, whileStatement.getCondition().getIntegerValue()); | ||
assertTrue(whileStatement.getStatements() instanceof Statements); | ||
assertTrue(whileStatement.isWhileStatement()); | ||
|
||
// Test the setCondition method | ||
Expression newCondition = new IntegerConstantExpression(1, 20); | ||
whileStatement.setCondition(newCondition); | ||
assertEquals(20, whileStatement.getCondition().getIntegerValue()); | ||
|
||
// Test the accept method with a simple visitor | ||
TestVisitor visitor = new TestVisitor(); | ||
whileStatement.accept(visitor); | ||
assertEquals(1, visitor.getWhileStatementCount()); | ||
} | ||
} |