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
Formatter #210
Formatter #210
Conversation
* Test inputs that are not percentages | ||
*/ | ||
@Test(expected = InvalidPercentageException.class) | ||
public void testPercenteageFormat() { |
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.
Typo
try { | ||
result = Integer.parseInt(port); | ||
} catch (NumberFormatException e) { | ||
throw new InvalidPortException(port, "contains non-digits"); |
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.
Schöner wäre ein Regex. So hat man halt exceptions im normalen Ablauf
@@ -3,31 +3,80 @@ | |||
/** | |||
* This class provides static methods to check input formats. |
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.
* @param tried The value that was tried to parse | ||
* @param reason The reason for the failture | ||
* | ||
* @param reason The reason for the failure |
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.
Warum Leerzeile?
/** | ||
* JUnit test class for FormatChecker.java | ||
* @author Maximilian Schwarzmann | ||
* |
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.
|
||
input = "20b10"; | ||
result = FormatChecker.checkPort(input); | ||
assertEquals(20000, result); |
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.
Das Assert brauchst du nicht (wenn doch, bitte Zahl anpassen)
* Test negative percentage | ||
*/ | ||
@Test(expected = InvalidPercentageException.class) | ||
public void testPercenteageRange() { |
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.
Typo
* Test valid port | ||
*/ | ||
@Test | ||
public void testHostPort() { |
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.
Port? Da wird ein Hostname getestet
input = "&/(&"; | ||
FormatChecker.checkHost(input); | ||
} | ||
} |
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.
Newline
if (host == null) { | ||
throw new InvalidHostException(host, "is null"); | ||
} | ||
String hostnamePattern = "[0-9a-zA-Z\\-_.]+"; |
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.
Musst mal schauen, ob man den Punkt auch escapen muss
|
… and fixed checkstyle violations
No description provided.