Skip to content

Commit

Permalink
Merge pull request #119 from simonharrer/fix-locale-test-run-bug
Browse files Browse the repository at this point in the history
Change locale to english for ByteFormatTest to run successful on systems...
  • Loading branch information
gitblit committed Oct 24, 2013
2 parents 0365f62 + ea01a53 commit 020a4d6
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/test/java/com/gitblit/tests/ByteFormatTest.java
Expand Up @@ -17,6 +17,8 @@

import static org.junit.Assert.assertEquals;

import java.util.Locale;

import org.junit.Test;

import com.gitblit.utils.ByteFormat;
Expand All @@ -25,12 +27,20 @@ public class ByteFormatTest {

@Test
public void testByteFormat() throws Exception {
ByteFormat format = new ByteFormat();
assertEquals("10 b", format.format(10));
assertEquals("10 KB", format.format(1024 * 10));
assertEquals("1,000 KB", format.format(1024 * 1000));
assertEquals("2.0 MB", format.format(2 * 1024 * 1000));
assertEquals("1,000.0 MB", format.format(1024 * 1024 * 1000));
assertEquals("2.0 GB", format.format(2 * 1024 * 1024 * 1000));
// sets locale for this test
Locale defaultLocale = Locale.getDefault();

try {
Locale.setDefault(Locale.ENGLISH);
ByteFormat format = new ByteFormat();
assertEquals("10 b", format.format(10));
assertEquals("10 KB", format.format(1024 * 10));
assertEquals("1,000 KB", format.format(1024 * 1000));
assertEquals("2.0 MB", format.format(2 * 1024 * 1000));
assertEquals("1,000.0 MB", format.format(1024 * 1024 * 1000));
assertEquals("2.0 GB", format.format(2 * 1024 * 1024 * 1000));
} finally {
Locale.setDefault(defaultLocale);
}
}
}

0 comments on commit 020a4d6

Please sign in to comment.