-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
errorprone :: update UnusedException messages (#895)
- Loading branch information
Showing
5 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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,22 @@ | ||
package emissary.util.magic; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
class MagicMathTest { | ||
|
||
@Test | ||
void testStringToInt() { | ||
int x = MagicMath.stringToInt("13"); | ||
assertEquals(13, x); | ||
|
||
// existing behavior | ||
assertThrows(NullPointerException.class, () -> MagicMath.stringToInt(null)); | ||
|
||
String entry = "blah"; | ||
Exception exception = assertThrows(NumberFormatException.class, () -> MagicMath.stringToInt(entry)); | ||
assertEquals("java.lang.NumberFormatException: For input string: \"blah\"", exception.toString()); | ||
} | ||
} |
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,25 @@ | ||
package emissary.util.search; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
class ByteTokenizerTest { | ||
|
||
@Test | ||
void testEncodingConstructor() throws Exception { | ||
|
||
byte[] testBytes = "these are test bytes".getBytes(StandardCharsets.UTF_8); | ||
ByteTokenizer byteTokenizer = new ByteTokenizer(testBytes, 0, 12, " ", StandardCharsets.UTF_8.name()); | ||
assertEquals(3, byteTokenizer.countTokens()); | ||
|
||
assertThrows(UnsupportedEncodingException.class, () -> new ByteTokenizer(testBytes, 0, 12, " ", null)); | ||
|
||
Exception exception = assertThrows(UnsupportedEncodingException.class, () -> new ByteTokenizer(testBytes, 0, 12, " ", "fake-encoding")); | ||
assertEquals("java.io.UnsupportedEncodingException: java.nio.charset.UnsupportedCharsetException: fake-encoding", exception.toString()); | ||
} | ||
} |