forked from elunez/eladmin
-
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 elunez#49 from Diffblue-benchmarks/add-diffblue-te…
…sts-FileUtilTest Add unit tests for me.zhengjie.utils.FileUtil
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
eladmin-common/src/test/java/me/zhengjie/utils/FileUtilTest.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,36 @@ | ||
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)); | ||
} | ||
} |