-
Notifications
You must be signed in to change notification settings - Fork 10
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
Д3 Ширшова Анастасия #5
Open
captainger
wants to merge
19
commits into
48x:master
Choose a base branch
from
captainger:master
base: master
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.
+66
−0
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8d780e9
hm is done
captainger e3a87d1
Delete compiler.xml
captainger c310a11
Delete misc.xml
captainger a40dbda
Delete modules.xml
captainger f954ba5
Delete Maven__junit_junit_4_12.xml
captainger 73abc9c
Delete Maven__org_hamcrest_hamcrest_all_1_3.xml
captainger 6c6b06a
Delete workspace.xml
captainger b2fff6f
Delete vcs.xml
captainger 03c5e15
Delete techno-atom-sample-1.iml
captainger ae3c548
Delete ClassToBeTested.class
captainger 1fccb4e
Delete TestBeforeAndAfter.class
captainger 4e8f073
Delete TestBeforeClassAndAfterClass.class
captainger 93f8397
Delete TestHamcrestMatchers.class
captainger 28c6141
Delete TestSampleNegativeTest1.class
captainger 769a727
Delete TestSampleTest1.class
captainger 94db5ff
Delete TestStringSorter.class
captainger 6fe90b2
Delete TestGenerateIntSequence.class
captainger 1cb8d5a
Delete TestGenerateIntSequence.java
captainger 72e3dd6
Create TestGenerateIntSequence.java
captainger 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
66 changes: 66 additions & 0 deletions
66
src/test/java/ru/odnoklassniki/generateIntSequence/TestGenerateIntSequence.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,66 @@ | ||
package ru.odnoklassniki.generateIntSequence; | ||
|
||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import ru.odnoklassniki.ClassToBeTested; | ||
|
||
import java.util.List; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.hasSize; | ||
|
||
public class TestGenerateIntSequence { | ||
|
||
@Test | ||
public void testLengthOfSequenceIsEqualToItemsCount() throws Exception { | ||
final int startingNumber = 0; | ||
final int itemsCounts = 5; | ||
final List<Integer> result = ClassToBeTested.generateIntSequence(startingNumber, itemsCounts); | ||
|
||
Assert.assertThat( | ||
"The length of sequence isn't equal to 5", | ||
result, | ||
hasSize(equalTo(itemsCounts)) | ||
); | ||
} | ||
|
||
@Test | ||
public void testSequenceIsCorrect() throws Exception { | ||
final int startingNumber = 4; | ||
final int itemsCounts = 3; | ||
final List<Integer> result = ClassToBeTested.generateIntSequence(startingNumber, itemsCounts); | ||
|
||
Assert.assertNotNull(result); | ||
Assert.assertEquals(3, result.size()); | ||
Assert.assertEquals(4, result.get(0).intValue()); | ||
Assert.assertEquals(5, result.get(1).intValue()); | ||
Assert.assertEquals(6, result.get(2).intValue()); | ||
} | ||
|
||
@Test | ||
public void testIfItemCounterIsNegativeExceptionThrown() throws Exception { | ||
final int startingNumber = 1; | ||
final int itemsCounts = -9; | ||
|
||
try { | ||
ClassToBeTested.generateIntSequence(startingNumber, itemsCounts); | ||
Assert.fail("Method didn't throw an exception when ItemCounter is negative"); | ||
} catch (IllegalArgumentException e) { | ||
Assert.assertEquals("itemsCount must be greater than 0", e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
public void testIfFinishNumberIsGreaterThenIntMaxValueExceptionThrown() throws Exception { | ||
final int startingNumber = Integer.MAX_VALUE - 1; | ||
final int itemsCounts = 50; | ||
|
||
try { | ||
ClassToBeTested.generateIntSequence(startingNumber, itemsCounts); | ||
Assert.fail("Method didn't throw an exception when final number is greater then integer.MAX_VALUE"); | ||
} catch (IllegalArgumentException e) { | ||
Assert.assertEquals("can't generate an int greater than integer's max value", e.getMessage()); | ||
} | ||
} | ||
} |
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.
Очень маленькое замечание - при нескольких проверках в одном тесте лучше писать fail-message для каждой проверки. Так проще потом разгребать результаты падения.