Skip to content
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

Add simple unit tests #7696

Merged
merged 3 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ void extractURLFormLink() {
formatter.format("away.php?to=http%3A%2F%2Fwikipedia.org&a=snippet"));
}

@Test
void validURLUnmodified() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to gradually migrate to Google's casing rules: https://google.github.io/styleguide/javaguide.html#s5.3-camel-case

Thus, please introduce defined camel case

Suggested change
void validURLUnmodified() {
void validUrlUnmodified() {

// the caller has to pay attention that this does not happen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should not happen? Maybe just remove the comment.

The call seems IMHO legal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's on me, I copy-pasted and forgot to remove it.

assertEquals("http://wikipedia.org", formatter.format("http://wikipedia.org"));
}

@Test
void latexCommandsNotRemoved() {
assertEquals("http://pi.informatik.uni-siegen.de/stt/36\\_2/./03\\_Technische\\_Beitraege/ZEUS2016/beitrag\\_2.pdf", formatter.format("http://pi.informatik.uni-siegen.de/stt/36\\_2/./03\\_Technische\\_Beitraege/ZEUS2016/beitrag\\_2.pdf"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public void removeHyphensBeforeNewlines() {
assertEquals("water", formatter.format("wa-\rter"));
}

@Test
public void withoutHyphensUnmodified() {
assertEquals("water", formatter.format("water"));
}

@Test
public void removeHyphensBeforePlatformSpecificNewlines() {
String newLine = String.format("%n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public void removeLineFeed() {
assertEquals("n linebreak", formatter.format("n\nlinebreak"));
}

@Test
public void withoutNewLineUnmodified() {
assertEquals("no linebreak", formatter.format("no linebreak"));
}

@Test
public void removePlatformSpecificNewLine() {
String newLine = String.format("%n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public void setUp() {

@Test
public void test() {
assertEquals("lower", formatter.format("lower"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you maybe change that to a paramterized test? We aim for having one assertion per test case. See also #6207

grafik

assertEquals("lower", formatter.format("LOWER"));
assertEquals("lower {UPPER}", formatter.format("LOWER {UPPER}"));
assertEquals("lower {U}pper", formatter.format("LOWER {U}PPER"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ public void singleClosingBraceCorrectlyRemoved() throws Exception {
public void bracePairWithEscapedBackslashCorrectlyRemoved() throws Exception {
assertEquals("\\some text\\", formatter.format("\\{some text\\}"));
}

@Test
public void withoutBracketsUnmodified() throws Exception {
assertEquals("some text", formatter.format("some text"));
}
}