[go: nahoru, domu]

Skip to content

Commit

Permalink
http: better debugging message for ByteArrayContent
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaniv Inbar committed Apr 23, 2013
1 parent 4bb60cd commit 42f6e64
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public ByteArrayContent(String type, byte[] array) {
public ByteArrayContent(String type, byte[] array, int offset, int length) {
super(type);
this.byteArray = Preconditions.checkNotNull(array);
Preconditions.checkArgument(offset >= 0 && length >= 0 && offset + length <= array.length);
Preconditions.checkArgument(offset >= 0 && length >= 0 && offset + length <= array.length,
"offset %s, length %s, array length %s", offset, length, array.length);
this.offset = offset;
this.length = length;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,21 @@ public void testConstructor() throws IOException {
fail("expected " + IllegalArgumentException.class);
} catch (IllegalArgumentException e) {
// expected
assertEquals("offset -1, length 2, array length 3", e.getMessage());
}
try {
new ByteArrayContent(null, FOO, 2, 2);
fail("expected " + IllegalArgumentException.class);
} catch (IllegalArgumentException e) {
// expected
assertEquals("offset 2, length 2, array length 3", e.getMessage());
}
try {
new ByteArrayContent(null, FOO, 3, 1);
fail("expected " + IllegalArgumentException.class);
} catch (IllegalArgumentException e) {
// expected
assertEquals("offset 3, length 1, array length 3", e.getMessage());
}
}

Expand Down

0 comments on commit 42f6e64

Please sign in to comment.