From c2d27fdb1a0f283c6e6ce5183b5ba0527e131d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hohwiller?= Date: Tue, 10 Mar 2020 09:28:54 +0100 Subject: [PATCH] Add support for String.isBlank() (#482) --- .../java/org/teavm/classlib/java/lang/TString.java | 10 ++++++++++ .../java/org/teavm/classlib/java/lang/StringTest.java | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TString.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TString.java index cfe1d6d7b..06c465e34 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TString.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TString.java @@ -146,6 +146,16 @@ public class TString extends TObject implements TSerializable, TComparable srcEnd || srcEnd > length() || dstBegin < 0 diff --git a/tests/src/test/java/org/teavm/classlib/java/lang/StringTest.java b/tests/src/test/java/org/teavm/classlib/java/lang/StringTest.java index 30ab6049a..8a12ea7a2 100644 --- a/tests/src/test/java/org/teavm/classlib/java/lang/StringTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/lang/StringTest.java @@ -17,6 +17,7 @@ package org.teavm.classlib.java.lang; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; @@ -311,4 +312,12 @@ public class StringTest { assertEquals(0, str.length()); assertEquals("", str); } + + @Test + public void testIsBlank() { + assertTrue(new String(new char[0]).isBlank()); + assertTrue(new String(new char[] { ' ', ' ' }).isBlank()); + assertFalse(new String(new char[] { ' ', 'x', ' ' }).isBlank()); + assertFalse(new String(new char[] { 'a', ' ' }).isBlank()); + } }