-
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
60c88dd
commit b927174
Showing
2 changed files
with
37 additions
and
1 deletion.
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
36 changes: 36 additions & 0 deletions
36
src/test/java/org/jd/core/v1/model/javasyntax/expression/ParenthesesExpressionTest.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,36 @@ | ||
package org.jd.core.v1.model.javasyntax.expression; | ||
|
||
import org.jd.core.v1.model.javasyntax.type.PrimitiveType; | ||
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 ParenthesesExpressionTest { | ||
|
||
@Test | ||
public void testParenthesesExpression() { | ||
// Test constructor with Expression | ||
Expression expression = new IntegerConstantExpression(1, 10); | ||
ParenthesesExpression parenthesesExpression = new ParenthesesExpression(expression); | ||
|
||
assertTrue(parenthesesExpression.getExpression() instanceof IntegerConstantExpression); | ||
assertTrue(parenthesesExpression.getType() instanceof PrimitiveType); | ||
|
||
// Test constructor with lineNumber and Expression | ||
ParenthesesExpression parenthesesExpressionWithLineNumber = new ParenthesesExpression(2, expression); | ||
assertTrue(parenthesesExpressionWithLineNumber.getExpression() instanceof IntegerConstantExpression); | ||
assertEquals(2, parenthesesExpressionWithLineNumber.getLineNumber()); | ||
|
||
// Test the copyTo method | ||
Expression copiedExpression = parenthesesExpression.copyTo(3); | ||
assertEquals(3, copiedExpression.getLineNumber()); | ||
assertTrue(copiedExpression instanceof ParenthesesExpression); | ||
|
||
// Test the accept method with a simple visitor | ||
TestVisitor visitor = new TestVisitor(); | ||
copiedExpression.accept(visitor); | ||
assertEquals(1, visitor.getParenthesesExpressionCount()); | ||
} | ||
} |