Skip to content

Commit

Permalink
Fixed tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
rxin committed Jun 11, 2015
1 parent 77c64bd commit 8e89a3c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import org.apache.spark.unsafe.types.UTF8String
class UTF8StringSuite extends SparkFunSuite {
test("basic") {
def check(str: String, len: Int) {

assert(UTF8String.fromString(str).length === len)
assert(UTF8String.fromBytes(str.getBytes("utf8")).length() === len)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ public boolean contains(final UTF8String substring) {
public boolean startsWith(final UTF8String prefix) {
final byte[] b = prefix.getBytes();
// TODO: Avoid copying.
return b.length > bytes.length && Arrays.equals(Arrays.copyOfRange(bytes, 0, b.length), b);
return b.length <= bytes.length && Arrays.equals(Arrays.copyOfRange(bytes, 0, b.length), b);
}

public boolean endsWith(final UTF8String suffix) {
final byte[] b = suffix.getBytes();
return b.length > bytes.length &&
return b.length <= bytes.length &&
Arrays.equals(Arrays.copyOfRange(bytes, bytes.length - b.length, bytes.length), b);
}

Expand Down

0 comments on commit 8e89a3c

Please sign in to comment.