\r
import static org.junit.Assert.assertEquals;\r
\r
+import java.util.Locale;\r
+\r
import org.junit.Test;\r
\r
import com.gitblit.utils.ByteFormat;\r
\r
@Test\r
public void testByteFormat() throws Exception {\r
- ByteFormat format = new ByteFormat();\r
- assertEquals("10 b", format.format(10));\r
- assertEquals("10 KB", format.format(1024 * 10));\r
- assertEquals("1,000 KB", format.format(1024 * 1000));\r
- assertEquals("2.0 MB", format.format(2 * 1024 * 1000));\r
- assertEquals("1,000.0 MB", format.format(1024 * 1024 * 1000));\r
- assertEquals("2.0 GB", format.format(2 * 1024 * 1024 * 1000));\r
+ // sets locale for this test\r
+ Locale defaultLocale = Locale.getDefault();\r
+\r
+ try {\r
+ Locale.setDefault(Locale.ENGLISH);\r
+ ByteFormat format = new ByteFormat();\r
+ assertEquals("10 b", format.format(10));\r
+ assertEquals("10 KB", format.format(1024 * 10));\r
+ assertEquals("1,000 KB", format.format(1024 * 1000));\r
+ assertEquals("2.0 MB", format.format(2 * 1024 * 1000));\r
+ assertEquals("1,000.0 MB", format.format(1024 * 1024 * 1000));\r
+ assertEquals("2.0 GB", format.format(2 * 1024 * 1024 * 1000));\r
+ } finally {\r
+ Locale.setDefault(defaultLocale);\r
+ }\r
}\r
}\r