Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Migrate CtUnresolvedImportTest to JUnit5 #4224

Merged
merged 1 commit into from
Oct 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/test/java/spoon/test/imports/CtUnresolvedImportTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package spoon.test.imports;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import spoon.reflect.declaration.CtImport;
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtReference;
Expand All @@ -9,14 +9,13 @@
import java.util.HashSet;
import java.util.Set;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import static spoon.testing.utils.ModelUtils.build;

public class CtUnresolvedImportTest {

@Test
public void testEquality() throws Exception {

final Factory factory = build(A.class);
CtImport i1 = factory.createUnresolvedImport("spoon.A", false);
CtImport i2 = factory.createUnresolvedImport("spoon.A", false);
Expand All @@ -25,7 +24,6 @@ public void testEquality() throws Exception {
CtImport i5 = factory.createUnresolvedImport("spoon.m", true);
CtImport i6 = factory.createUnresolvedImport("spoon.m", true);


CtReference ref = factory.createReference("spoon.A");
CtImport i7 = factory.createImport(ref);

Expand All @@ -45,6 +43,8 @@ public void testEquality() throws Exception {
assertEquals(i1.hashCode(), i2.hashCode());
assertNotEquals(i1, i3);

// hashCode() and equals() should work as expected for set-element-membership identification based on
// the contained reference and isStatic field
Set<CtImport> imports = new HashSet<>();
assertTrue(imports.add(i1));
assertFalse(imports.add(i2));
Expand All @@ -55,5 +55,4 @@ public void testEquality() throws Exception {
assertTrue(imports.add(i7));
assertEquals(5, imports.size());
}

}