Last active
August 29, 2015 14:23
-
-
Save tadams/3b6f53703a828d26c7e0 to your computer and use it in GitHub Desktop.
Negative Logic Example
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
public List<Class> buildClassHierarchy(Class cls) { | |
List<Class> classHierarchy = new ArrayList<>(); | |
while (!Object.class.equals(cls) && cls != null) { | |
classHierarchy.add(cls); | |
cls = cls.getSuperclass(); | |
} | |
return classHierarchy; | |
} | |
... | |
@Test | |
public void shouldReturnClassHiearchy() { | |
List<Class> classHierarchy = logic.buildClassHierarchy(MyMap.class); | |
assertThat(classHierarchy).contains(MyMap.class, HashMap.class, AbstractMap.class); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment