-
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
498ad51
commit 1495530
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/test/java/org/jd/core/v1/model/javasyntax/declaration/FieldDeclaratorsTest.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,40 @@ | ||
package org.jd.core.v1.model.javasyntax.declaration; | ||
|
||
import org.jd.core.v1.model.javasyntax.type.PrimitiveType; | ||
import org.jd.core.v1.service.converter.classfiletojavasyntax.visitor.TestDeclarationVisitor; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class FieldDeclaratorsTest { | ||
@Test | ||
public void testFieldDeclarators() { | ||
// Arrange | ||
FieldDeclarator declarator1 = new FieldDeclarator("field1", new ExpressionVariableInitializer(null)); | ||
FieldDeclarator declarator2 = new FieldDeclarator("field2", new ExpressionVariableInitializer(null)); | ||
FieldDeclarators declarators = new FieldDeclarators(declarator1, declarator2); | ||
|
||
// Assert | ||
assertEquals(2, declarators.size()); | ||
assertEquals(declarator1, declarators.get(0)); | ||
assertEquals(declarator2, declarators.get(1)); | ||
|
||
// Act | ||
FieldDeclaration fieldDeclaration = new FieldDeclaration(1, PrimitiveType.TYPE_INT, declarators); | ||
declarators.setFieldDeclaration(fieldDeclaration); | ||
|
||
// Assert - setFieldDeclaration | ||
assertEquals(fieldDeclaration, declarator1.getFieldDeclaration()); | ||
assertEquals(fieldDeclaration, declarator2.getFieldDeclaration()); | ||
|
||
// Act & Assert - accept | ||
TestDeclarationVisitor visitor = new TestDeclarationVisitor(); | ||
declarators.accept(visitor); | ||
assertEquals(1, visitor.getFieldDeclaratorsCount()); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testFieldDeclaratorsException() { | ||
new FieldDeclarators(new FieldDeclarator("name")); | ||
} | ||
} |