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
1 parent
d98ba71
commit 4129455
Showing
2 changed files
with
88 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
87 changes: 87 additions & 0 deletions
87
transfuse-support/src/test/java/org/androidtransfuse/adapter/ASTUtilsTest.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,87 @@ | ||
package org.androidtransfuse.adapter; | ||
|
||
import org.androidtransfuse.adapter.classes.ASTClassFactory; | ||
import org.junit.*; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* @author John Ericksen | ||
*/ | ||
public class ASTUtilsTest { | ||
|
||
public static class A extends B{} | ||
public static class B extends C implements D{} | ||
public interface D{} | ||
public static class C implements E{} | ||
public interface E extends F, G {} | ||
public interface F {} | ||
public interface G {} | ||
public static class H{} | ||
public interface I{} | ||
|
||
private ASTType a; | ||
private ASTType b; | ||
private ASTType c; | ||
private ASTType d; | ||
private ASTType e; | ||
private ASTType f; | ||
private ASTType g; | ||
private ASTType h; | ||
private ASTType i; | ||
private ASTType objectType; | ||
|
||
private ASTUtils astUtils; | ||
|
||
@Before | ||
public void setup() { | ||
ASTClassFactory classFactory = new ASTClassFactory(); | ||
a = classFactory.getType(A.class); | ||
b = classFactory.getType(B.class); | ||
c = classFactory.getType(C.class); | ||
d = classFactory.getType(D.class); | ||
e = classFactory.getType(E.class); | ||
f = classFactory.getType(F.class); | ||
g = classFactory.getType(G.class); | ||
h = classFactory.getType(H.class); | ||
i = classFactory.getType(I.class); | ||
objectType = classFactory.getType(Object.class); | ||
|
||
astUtils = ASTUtils.getInstance(); | ||
} | ||
|
||
@Test | ||
public void testExtends() { | ||
assertTrue(astUtils.inherits(a, b)); | ||
assertTrue(astUtils.inherits(a, c)); | ||
assertFalse(astUtils.inherits(a, h)); | ||
assertTrue(astUtils.inherits(a, objectType)); | ||
assertFalse(astUtils.inherits(b, a)); | ||
assertFalse(astUtils.inherits(c, a)); | ||
} | ||
|
||
@Test | ||
public void testInherits() { | ||
assertTrue(astUtils.inherits(a, d)); | ||
assertTrue(astUtils.inherits(a, e)); | ||
assertTrue(astUtils.inherits(a, f)); | ||
assertTrue(astUtils.inherits(a, g)); | ||
assertTrue(astUtils.inherits(e, f)); | ||
assertTrue(astUtils.inherits(e, g)); | ||
assertFalse(astUtils.inherits(e, h)); | ||
assertFalse(astUtils.inherits(d, e)); | ||
assertFalse(astUtils.inherits(a, i)); | ||
} | ||
|
||
@Test | ||
public void testNull() { | ||
assertTrue(astUtils.inherits(a, null)); | ||
assertFalse(astUtils.inherits(null, null)); | ||
} | ||
|
||
@Test | ||
public void testSelf() { | ||
assertTrue(astUtils.inherits(a, a)); | ||
} | ||
} |