"...git@ustchcs.com:gujinli1118/springboot-plus.git" did not exist on "926ceb9a18149e2e8eb0cd2155b6c178825edbac"
Commit 7137fee2 authored by Eric Hettiaratchi's avatar Eric Hettiaratchi
Browse files

Add unit tests for me.zhengjie.utils.FileUtil

These tests were written using Diffblue Cover.
parent 44863847
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));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment