Skip to content

Commit

Permalink
Fix exception message #367
Browse files Browse the repository at this point in the history
  • Loading branch information
making committed Dec 11, 2015
1 parent b95b38b commit 7ac0810
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ public final class FullHalfPair implements Serializable {
*/
public FullHalfPair(String fullwidth, String halfwidth) {
if (fullwidth == null || fullwidth.length() != 1) {
throw new IllegalArgumentException("fullwidth must be 1 length string");
throw new IllegalArgumentException("fullwidth must be 1 length string (fullwidth = " + fullwidth + ")");
}
if (halfwidth == null
|| (halfwidth.length() != 1 && halfwidth.length() != 2)) {
throw new IllegalArgumentException("halfwidth must be 1 or 2 length string");
throw new IllegalArgumentException("halfwidth must be 1 or 2 length string (halfwidth = " + halfwidth + ")");
}
this.fullwidth = fullwidth;
this.halfwidth = halfwidth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,45 @@ public class FullHalfPairsBuilderTest {
@Test
public void testFullIsNull() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("fullwidth must be 1 length string");
expectedException.expectMessage("fullwidth must be 1 length string (fullwidth = null)");
new FullHalfPairsBuilder().pair(null, "a").build();
}

@Test
public void testFullIsEmptyString() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("fullwidth must be 1 length string");
expectedException.expectMessage("fullwidth must be 1 length string (fullwidth = )");
new FullHalfPairsBuilder().pair("", "a").build();
}

@Test
public void testFullIsTwoString() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("fullwidth must be 1 length string");
expectedException.expectMessage("fullwidth must be 1 length string (fullwidth = aa)");
new FullHalfPairsBuilder().pair("aa", "a").build();
}

@Test
public void testHalfIsNull() {
expectedException.expect(IllegalArgumentException.class);
expectedException
.expectMessage("halfwidth must be 1 or 2 length string");
.expectMessage("halfwidth must be 1 or 2 length string (halfwidth = null)");
new FullHalfPairsBuilder().pair("a", null).build();
}

@Test
public void testHalfIsEmptyString() {
expectedException.expect(IllegalArgumentException.class);
expectedException
.expectMessage("halfwidth must be 1 or 2 length string");
.expectMessage("halfwidth must be 1 or 2 length string (halfwidth = )");
new FullHalfPairsBuilder().pair("a", "").build();
}

@Test
public void testHalfIsThreeString() {
expectedException.expect(IllegalArgumentException.class);
expectedException
.expectMessage("halfwidth must be 1 or 2 length string");
.expectMessage("halfwidth must be 1 or 2 length string (halfwidth = aaa)");
new FullHalfPairsBuilder().pair("a", "aaa").build();
}

Expand Down

0 comments on commit 7ac0810

Please sign in to comment.