Last active
March 10, 2017 21:54
-
-
Save dschinkel/68723984b4b4d43550ab1b3d2e5e9715 to your computer and use it in GitHub Desktop.
First few tests
This file contains hidden or 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
import org.junit.Test; | |
import static junit.framework.TestCase.*; | |
/* requirements: Implement the following behavior: | |
set() - creation with or without specified size | |
add() | |
clear() | |
contains() | |
isEmpty() | |
iterator() | |
remove() | |
size() | |
*/ | |
public class SetTest { | |
@Test | |
public void canCreateAnEmptySet(){ | |
Set set = createSet(); | |
assertTrue(set.isEmpty()); | |
} | |
@Test | |
public void anEmptySetHasNoSize(){ | |
Set set = createSet(); | |
assertEquals(0, set.size()); | |
} | |
@Test | |
public void canCreateSetForSpecificSize() { | |
Set set = createSet(4); | |
assertEquals(4, set.size()); | |
} | |
@Test | |
public void setsWithSizeGreaterThanZeroShouldNotBeEmpty() { | |
Set set = createSet(4); | |
assertFalse(set.isEmpty()); | |
} | |
@Test | |
public void canClearASet() { | |
Set set = createSet(4); | |
set.clear(); | |
assertSame(0, set.size()); | |
} | |
@Test | |
public void clearingASetEmptiesTheSet() { | |
Set set = createSet(4); | |
set.clear(); | |
assertTrue(set.isEmpty()); | |
} | |
private Set createSet() { | |
return new Set(); | |
} | |
private Set createSet(int size) { | |
return new Set(size); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment