-
Notifications
You must be signed in to change notification settings - Fork 228
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
Refactoring AbstractRib and adding tests #598
Conversation
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.
Pretty awesome.
|
||
/* | ||
If prefixes don't match exactly, look at the current bit. That determines whether we look | ||
left of right. As long as the child is not null, recurse. |
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.
left or
right
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.
Either use Java multiline comment form
/*
* ...
*/
or Java single-line block comment form:
// Line 1
// Line 2
// Line 3
|
||
// Assertions | ||
// Check routes size | ||
assertThat(_rib.getRoutes().size(), is(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.
can use Matchers.hasSize
for this, I think. Assuming it's a Collection
, not a Map
.
|
||
@Test | ||
public void testRibConstructor() { | ||
// Test: the setupEmptyRib() fixture |
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.
Drop these comments -- structuring the test in a logical order with, optionally, whitespace between sections is good enough :)
|
||
@Test | ||
public void testMultiOverlappingRouteAdd() { | ||
// Setup/Test: Add multiple routes with overlapping prefixes |
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 type of comment where useful for understanding test goals should go in the function javadoc.
|
||
match = _rib.longestPrefixMatch(new Ip("10.1.1.2")); | ||
assertThat(match.size(), equalTo(1)); | ||
assertThat(match, contains(routes.get(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.
also test one that doesn't match (even though the rib is not empty ;).
import org.junit.Test; | ||
|
||
/** | ||
* Test the AbstractRib tree logic. To avoid worrying about route preference comparisons, testing |
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.
Simpler:
/** Tests of {@link AbstractRib}. */
Then move the bit about StaticRoute to the _rib
variable.
My general rule here is that public Javadoc is for people looking at "What does X do?" whereas private documentation is for people reading the code ("how does X work?").
[And, I don't think I care how we test AbstractRib until I'm reading the code.]
*/ | ||
public class AbstractRibTest { | ||
private AbstractRib<StaticRoute> _rib; | ||
private StaticRoute _mostGeneralRoute; |
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.
private static final StaticRoute MOST_GENERAL_ROUTE = ...
Since it's a constant that will never change per test.
Fixes #591