Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
6e692480
Unverified
Commit
6e692480
authored
Apr 18, 2019
by
elunez
Committed by
GitHub
Apr 18, 2019
Browse files
Merge pull request #42 from Diffblue-benchmarks/add-diffblue-tests
Add unit tests for me.zhengjie.utils.StringUtils
parents
44863847
39664767
Changes
1
Hide whitespace changes
Inline
Side-by-side
eladmin-common/src/test/java/me/zhengjie/utils/StringUtilsTest.java
0 → 100644
View file @
6e692480
package
me.zhengjie.utils
;
import
org.junit.Test
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
static
me
.
zhengjie
.
utils
.
StringUtils
.*;
import
static
org
.
junit
.
Assert
.*;
public
class
StringUtilsTest
{
@Test
public
void
testInString
()
{
assertTrue
(
inString
(
"?"
,
"?"
));
assertFalse
(
inString
(
"?"
,
new
String
[]{}));
}
@Test
public
void
testToCamelCase
()
{
assertNull
(
toCamelCase
(
null
));
}
@Test
public
void
testToCapitalizeCamelCase
()
{
assertNull
(
StringUtils
.
toCapitalizeCamelCase
(
null
));
assertEquals
(
"HelloWorld"
,
toCapitalizeCamelCase
(
"hello_world"
));
}
@Test
public
void
testToUnderScoreCase
()
{
assertNull
(
StringUtils
.
toUnderScoreCase
(
null
));
assertEquals
(
"hello_world"
,
toUnderScoreCase
(
"helloWorld"
));
assertEquals
(
"\u0000\u0000"
,
toUnderScoreCase
(
"\u0000\u0000"
));
assertEquals
(
"\u0000_a"
,
toUnderScoreCase
(
"\u0000A"
));
}
@Test
public
void
testGetWeekDay
()
{
SimpleDateFormat
simpleDateformat
=
new
SimpleDateFormat
(
"E"
);
assertEquals
(
simpleDateformat
.
format
(
new
Date
()),
getWeekDay
());
}
@Test
public
void
testGetIP
()
{
assertEquals
(
"127.0.0.1"
,
getIP
(
new
MockHttpServletRequest
()));
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment