-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Set private the lists fEmpty, fFull and remove unnecessary boxing on ListTest #1389
Set private the lists fEmpty, fFull and remove unnecessary boxing on ListTest #1389
Conversation
Change from protected to private fEmpty and fFull Remove unnecesary boxing on fFull.remove()
@@ -11,8 +11,9 @@ | |||
* A sample test case, testing {@link java.util.ArrayList}. | |||
*/ | |||
public class ListTest extends TestCase { | |||
protected List<Integer> fEmpty; | |||
protected List<Integer> fFull; | |||
private List<Integer> fEmpty; |
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.
While you are changing this, could you please rename "fEmpty" to "empty" or "emptyList"?
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.
Just to be more clear about the samples, on my way to do the changes
protected List<Integer> fFull; | ||
private List<Integer> fEmpty; | ||
|
||
private List<Integer> fFull; | ||
|
||
public static void main(String[] args) { |
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.
While you are changing this file, please remove the main method.
…me fFull to fullList Requested changes
@kcooney Ready Requested Changes
Checklist
|
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.
Thanks!
} | ||
|
||
public void testElementAt() { | ||
int i = fFull.get(0); | ||
int i = fullList.get(0); | ||
assertTrue(i == 1); |
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.
Do you think we should use assertEquals()
(with as useful message) instead of assertTrue()
so you'll get a useful stack trace if this fails? Future users might look at this file as an example of how to write a good JUnit test.
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.
Yes is more readable 👍
protected List<Integer> fEmpty; | ||
protected List<Integer> fFull; | ||
private List<Integer> emptyList; | ||
|
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.
Why the extra blank line?
protected List<Integer> fFull; | ||
private List<Integer> emptyList; | ||
|
||
private List<Integer> fullList; |
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.
style-nit: remove extra blank line after this declaration.
@kcooney Ready 👍 Requested Changes
Checklist
|
* Set private to fEmpty, fFull and remove unnecesary boxing on ListTest * Change from protected to private fEmpty and fFull * Remove unnecesary boxing on fFull.remove() * Remove main method from ListTest, rename fEmpty to emptyList and rename fFull to fullList
* Set private to fEmpty, fFull and remove unnecesary boxing on ListTest * Change from protected to private fEmpty and fFull * Remove unnecesary boxing on fFull.remove() * Remove main method from ListTest, rename fEmpty to emptyList and rename fFull to fullList
Description of change
fEmpty
andfFull
lists, because there is no need to keep accessible from the package and subclassfFull.remove()
because Java creates an Integer object fromi
and adds to the objectfFull
Requested Changes
fEmpty
toemptyList
fFull
tofullList
assertTrue()
forassertEquals()
ontestElementAt()
methodChecklist
mvn verify
References:
Controlling Access to Members of a Class
Autoboxing and Unboxing