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
61a9b45a
Unverified
Commit
61a9b45a
authored
May 08, 2019
by
elunez
Committed by
GitHub
May 08, 2019
Browse files
Merge pull request #49 from Diffblue-benchmarks/add-diffblue-tests-FileUtilTest
Add unit tests for me.zhengjie.utils.FileUtil
parents
333212a1
7137fee2
Changes
1
Hide whitespace changes
Inline
Side-by-side
eladmin-common/src/test/java/me/zhengjie/utils/FileUtilTest.java
0 → 100644
View file @
61a9b45a
package
me.zhengjie.utils
;
import
org.junit.Test
;
import
org.springframework.mock.web.MockMultipartFile
;
import
static
org
.
junit
.
Assert
.*;
import
static
me
.
zhengjie
.
utils
.
FileUtil
.*;
public
class
FileUtilTest
{
@Test
public
void
testToFile
()
{
long
retval
=
toFile
(
new
MockMultipartFile
(
"foo"
,
(
byte
[])
null
)).
getTotalSpace
();
assertEquals
(
500695072768L
,
retval
);
}
@Test
public
void
testGetExtensionName
()
{
assertEquals
(
"foo"
,
getExtensionName
(
"foo"
));
assertEquals
(
"exe"
,
getExtensionName
(
"bar.exe"
));
}
@Test
public
void
testGetFileNameNoEx
()
{
assertEquals
(
"foo"
,
getFileNameNoEx
(
"foo"
));
assertEquals
(
"bar"
,
getFileNameNoEx
(
"bar.txt"
));
}
@Test
public
void
testGetSize
()
{
assertEquals
(
"1000B "
,
getSize
(
1000
));
assertEquals
(
"1.00KB "
,
getSize
(
1024
));
assertEquals
(
"1.00MB "
,
getSize
(
1048576
));
assertEquals
(
"1.00GB "
,
getSize
(
1073741824
));
}
}
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