[SPARK-23892][TEST] Improve converge and fix lint error in UTF8String-related tests

## What changes were proposed in this pull request?

This PR improves test coverage in `UTF8StringSuite` and code efficiency in `UTF8StringPropertyCheckSuite`.

This PR also fixes lint-java issue in `UTF8StringSuite` reported at [here](https://github.com/apache/spark/pull/20995#issuecomment-379325527)

```[ERROR] src/test/java/org/apache/spark/unsafe/types/UTF8StringSuite.java:[28,8] (imports) UnusedImports: Unused import - org.apache.spark.unsafe.Platform.```

## How was this patch tested?

Existing UT

Author: Kazuaki Ishizaki <ishizaki@jp.ibm.com>

Closes #21000 from kiszk/SPARK-23892.
This commit is contained in:
Kazuaki Ishizaki 2018-04-08 20:26:31 +02:00 committed by Herman van Hovell
parent 6a734575a8
commit 710a68cec2
2 changed files with 3 additions and 4 deletions

View file

@ -25,7 +25,6 @@ import java.nio.charset.StandardCharsets;
import java.util.*;
import com.google.common.collect.ImmutableMap;
import org.apache.spark.unsafe.Platform;
import org.apache.spark.unsafe.memory.ByteArrayMemoryBlock;
import org.apache.spark.unsafe.memory.OnHeapMemoryBlock;
import org.junit.Test;
@ -53,8 +52,8 @@ public class UTF8StringSuite {
assertTrue(s1.contains(s2));
assertTrue(s2.contains(s1));
assertTrue(s1.startsWith(s1));
assertTrue(s1.endsWith(s1));
assertTrue(s1.startsWith(s2));
assertTrue(s1.endsWith(s2));
}
@Test

View file

@ -164,7 +164,7 @@ class UTF8StringPropertyCheckSuite extends FunSuite with GeneratorDrivenProperty
def padding(origin: String, pad: String, length: Int, isLPad: Boolean): String = {
if (length <= 0) return ""
if (length <= origin.length) {
if (length <= 0) "" else origin.substring(0, length)
origin.substring(0, length)
} else {
if (pad.length == 0) return origin
val toPad = length - origin.length