Skip to content

Commit

Permalink
Unit test for JENKINS-16630
Browse files Browse the repository at this point in the history
  • Loading branch information
fredg02 committed Feb 7, 2013
1 parent f19f772 commit 6437fe2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/src/test/java/hudson/FunctionsTest.java
Expand Up @@ -23,6 +23,9 @@
*/
package hudson;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

import hudson.model.Action;
import static org.junit.Assert.*;
import org.junit.Test;
Expand Down Expand Up @@ -117,4 +120,21 @@ private static StaplerRequest createMockRequest(String contextPath) {
when(req.getContextPath()).thenReturn(contextPath);
return req;
}

@Test
@Bug(16630)
public void testhumanReadableFileSize(){
DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance();
DecimalFormatSymbols symbols = format.getDecimalFormatSymbols();
char sep = symbols.getDecimalSeparator();
assertEquals("0 B", Functions.humanReadableByteSize(0));
assertEquals("1023 B", Functions.humanReadableByteSize(1023));
assertEquals("1"+sep+"00 KB", Functions.humanReadableByteSize(1024));
assertEquals("1"+sep+"50 KB", Functions.humanReadableByteSize(1536));
assertEquals("20"+sep+"00 KB", Functions.humanReadableByteSize(20480));
assertEquals("1023"+sep+"00 KB", Functions.humanReadableByteSize(1047552));
assertEquals("1"+sep+"00 MB", Functions.humanReadableByteSize(1048576));
assertEquals("1"+sep+"50 GB", Functions.humanReadableByteSize(1610612700));
}

}

0 comments on commit 6437fe2

Please sign in to comment.