Skip to content
Permalink
Browse files
Unit test for JENKINS-16630
  • Loading branch information
fredg02 committed Feb 7, 2013
1 parent f19f772 commit 6437fe2e7804371243aab0c19283063df8f61ea9
Showing with 20 additions and 0 deletions.
  1. +20 −0 core/src/test/java/hudson/FunctionsTest.java
@@ -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;
@@ -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.