-
-
Notifications
You must be signed in to change notification settings - Fork 747
Update tests bird watcher #3077
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
Open
jagdish-15
wants to merge
1
commit into
exercism:main
Choose a base branch
from
jagdish-15:update-tests-bird-watcher
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+18
−14
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,35 @@ | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Tag; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
|
|
||
| import static org.assertj.core.api.Assertions.*; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| public class BirdWatcherTest { | ||
|
|
||
| private static final int DAY1 = 0; | ||
| private static final int DAY2 = 2; | ||
| private static final int DAY3 = 5; | ||
| private static final int DAY4 = 3; | ||
| private static final int DAY5 = 7; | ||
| private static final int DAY6 = 8; | ||
| private static final int TODAY = 4; | ||
| private static final int DAY1 = 7; | ||
| private static final int DAY2 = 0; | ||
| private static final int DAY3 = 4; | ||
| private static final int DAY4 = 8; | ||
| private static final int DAY5 = 5; | ||
| private static final int DAY6 = 2; | ||
| private static final int TODAY = 3; | ||
|
|
||
| private BirdWatcher birdWatcher; | ||
| private final int[] lastWeek = {DAY1, DAY2, DAY3, DAY4, DAY5, DAY6, TODAY}; | ||
| private final int[] currentWeek = {DAY1, DAY2, DAY3, DAY4, DAY5, DAY6, TODAY}; | ||
| private final int[] lastWeek = {0, 2, 5, 3, 7, 8, 4}; | ||
|
|
||
| @BeforeEach | ||
| public void setUp() { | ||
| birdWatcher = new BirdWatcher(lastWeek); | ||
| birdWatcher = new BirdWatcher(currentWeek); | ||
| } | ||
|
|
||
| @Test | ||
| @Tag("task:1") | ||
| @DisplayName("The getLastWeek method correctly returns last week's counts") | ||
| public void itTestGetLastWeek() { | ||
| assertThat(birdWatcher.getLastWeek()) | ||
| .containsExactly(DAY1, DAY2, DAY3, DAY4, DAY5, DAY6, TODAY); | ||
| .isEqualTo(lastWeek); | ||
| } | ||
|
|
||
| @Test | ||
|
|
@@ -42,13 +43,16 @@ public void itTestGetToday() { | |
| @Tag("task:3") | ||
| @DisplayName("The incrementTodaysCount method correctly increments today's counts") | ||
| public void itIncrementTodaysCount() { | ||
| int firstSixDaysBeforeIncrement = birdWatcher.getCountForFirstDays(6); | ||
| birdWatcher.incrementTodaysCount(); | ||
| int firstSixDaysAfterIncrement = birdWatcher.getCountForFirstDays(6); | ||
| assertThat(birdWatcher.getToday()).isEqualTo(TODAY + 1); | ||
| assertThat(firstSixDaysAfterIncrement).isEqualTo(firstSixDaysBeforeIncrement); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, this is a clever way (using
public void itIncrementDoesNotChangeCountForOtherDays() {
birdWatcher.incrementTodaysCount();
assertThat(birdWatcher.getCountForFirstDays(6)).isEqualTo(DAY1 + DAY2 + DAY3 + DAY4 + DAY5 + DAY6);
} |
||
| } | ||
|
|
||
| @Test | ||
| @Tag("task:4") | ||
| @DisplayName("The hasDayWithoutBirds method returns true when day had no visits") | ||
| @DisplayName("The hasDayWithoutBirds method returns true when at least one day had no visits") | ||
| public void itHasDayWithoutBirds() { | ||
| assertThat(birdWatcher.hasDayWithoutBirds()).isTrue(); | ||
| } | ||
|
|
@@ -88,7 +92,7 @@ public void itTestGetCountForMoreDaysThanTheArraySize() { | |
| @Tag("task:6") | ||
| @DisplayName("The getBusyDays method returns the correct count of busy days") | ||
| public void itTestGetCountForBusyDays() { | ||
| // DAY3, DAY5 and DAY6 are all >= 5 birds | ||
| // DAY1, DAY4 and DAY5 are all >= 5 birds | ||
| assertThat(birdWatcher.getBusyDays()).isEqualTo(3); | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to invalidate solutions that return the array in
getLastWeek, like this one.If our objective is to just capture the
incrementTodaysCount, I think we could just changeitIncrementTodaysCount.