Created
February 22, 2017 08:52
-
-
Save madhu314/3ee01ac5fcff315fb6d8a59d38123827 to your computer and use it in GitHub Desktop.
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
@Test public void testInsertions() throws Exception { | |
assertThat(fixture.sortedList().size()).isEqualTo(0); | |
for (int i = 0; i < fixture.shuffledArticles().size(); i++) { | |
Article articleToAdd = fixture.shuffledArticles().get(i).dupe(); | |
int positionTobeInserted = -1; | |
for (int j = 0; j < fixture.sortedList().size(); j++) { | |
Article jth = fixture.sortedList().get(j); | |
if (jth.compare(articleToAdd) >= 0) { | |
positionTobeInserted = j; | |
break; | |
} | |
} | |
if (positionTobeInserted == -1) { | |
positionTobeInserted = fixture.sortedList().size(); | |
} | |
fixture.sortedList().add(articleToAdd); | |
assertThat(fixture.callbackRecorder().insertions().size()).isEqualTo(i + 1); | |
Pair<Integer, Integer> insertionPair = fixture.callbackRecorder().insertions().get(i); | |
assertThat(insertionPair.first).isEqualTo(positionTobeInserted); | |
} | |
assertThat(fixture.callbackRecorder().deletions().size()).isEqualTo(0); | |
assertThat(fixture.callbackRecorder().moves().size()).isEqualTo(0); | |
assertThat(fixture.callbackRecorder().changes().size()).isEqualTo(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment