Skip to content

Commit 710a68c

Browse files
kiszkhvanhovell
authored andcommitted
[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](apache#20995 (comment)) ```[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 apache#21000 from kiszk/SPARK-23892.
1 parent 6a73457 commit 710a68c

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

common/unsafe/src/test/java/org/apache/spark/unsafe/types/UTF8StringSuite.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.*;
2626

2727
import com.google.common.collect.ImmutableMap;
28-
import org.apache.spark.unsafe.Platform;
2928
import org.apache.spark.unsafe.memory.ByteArrayMemoryBlock;
3029
import org.apache.spark.unsafe.memory.OnHeapMemoryBlock;
3130
import org.junit.Test;
@@ -53,8 +52,8 @@ private static void checkBasic(String str, int len) {
5352

5453
assertTrue(s1.contains(s2));
5554
assertTrue(s2.contains(s1));
56-
assertTrue(s1.startsWith(s1));
57-
assertTrue(s1.endsWith(s1));
55+
assertTrue(s1.startsWith(s2));
56+
assertTrue(s1.endsWith(s2));
5857
}
5958

6059
@Test

common/unsafe/src/test/scala/org/apache/spark/unsafe/types/UTF8StringPropertyCheckSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class UTF8StringPropertyCheckSuite extends FunSuite with GeneratorDrivenProperty
164164
def padding(origin: String, pad: String, length: Int, isLPad: Boolean): String = {
165165
if (length <= 0) return ""
166166
if (length <= origin.length) {
167-
if (length <= 0) "" else origin.substring(0, length)
167+
origin.substring(0, length)
168168
} else {
169169
if (pad.length == 0) return origin
170170
val toPad = length - origin.length

0 commit comments

Comments
 (0)