Skip to content

Commit

Permalink
Merge pull request alibaba#186 from Diffblue-benchmarks/add-diffblue-…
Browse files Browse the repository at this point in the history
…tests

Add unit tests for com.alibaba.jvm.sandbox.api.util.GaStringUtils
  • Loading branch information
oldmanpushcart authored Aug 30, 2019
2 parents 3e73cb3 + 5af4aab commit b766206
Showing 1 changed file with 55 additions and 0 deletions.
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"));
}
}

0 comments on commit b766206

Please sign in to comment.