forked from alibaba/jvm-sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request alibaba#186 from Diffblue-benchmarks/add-diffblue-…
…tests Add unit tests for com.alibaba.jvm.sandbox.api.util.GaStringUtils
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
sandbox-api/src/test/java/com/alibaba/jvm/sandbox/api/util/GaStringUtilsTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.alibaba.jvm.sandbox.api.util; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class GaStringUtilsTests { | ||
|
||
@Test | ||
public void testGetJavaClassName() { | ||
Assert.assertEquals("java.lang.String", | ||
GaStringUtils.getJavaClassName(String.class)); | ||
} | ||
|
||
@Test | ||
public void testGetJavaClassNameArray() { | ||
Assert.assertNull(GaStringUtils.getJavaClassNameArray(null)); | ||
Assert.assertNull(GaStringUtils.getJavaClassNameArray(new Class[]{})); | ||
|
||
Class[] classes = new Class[]{String.class, Integer.class}; | ||
String[] strings = | ||
new String[]{"java.lang.String", "java.lang.Integer"}; | ||
|
||
Assert.assertArrayEquals(strings, | ||
GaStringUtils.getJavaClassNameArray(classes)); | ||
} | ||
|
||
@Test | ||
public void testIsEmpty() { | ||
Assert.assertTrue(GaStringUtils.isEmpty("")); | ||
Assert.assertTrue(GaStringUtils.isEmpty(null)); | ||
|
||
Assert.assertFalse(GaStringUtils.isEmpty("foo")); | ||
} | ||
|
||
@Test | ||
public void testMatching() { | ||
Assert.assertFalse(GaStringUtils.matching(null, "bar")); | ||
Assert.assertFalse(GaStringUtils.matching("foo", null)); | ||
Assert.assertFalse(GaStringUtils.matching(null, null)); | ||
Assert.assertFalse(GaStringUtils.matching("foo", "bar")); | ||
Assert.assertFalse(GaStringUtils.matching("foobar", "foo")); | ||
Assert.assertFalse(GaStringUtils.matching("foobar", "*a")); | ||
Assert.assertFalse(GaStringUtils.matching("foo", "\\o")); | ||
Assert.assertFalse(GaStringUtils.matching("foo", "\\*")); | ||
Assert.assertFalse(GaStringUtils.matching("foo", "f\\?o")); | ||
Assert.assertFalse(GaStringUtils.matching("fooMatching", "fool\\*ing")); | ||
|
||
Assert.assertTrue(GaStringUtils.matching("foo", "*")); | ||
Assert.assertTrue(GaStringUtils.matching("foo", "?oo")); | ||
Assert.assertTrue(GaStringUtils.matching("foo", "**o")); | ||
Assert.assertTrue(GaStringUtils.matching("foo", "f?o")); | ||
Assert.assertTrue(GaStringUtils.matching("fooMatching", "foo*")); | ||
Assert.assertTrue(GaStringUtils.matching("fooMatching", "foo*ing")); | ||
} | ||
} |