/*
 * Copyright 2011 gitblit.com.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.gitblit.tests;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import com.gitblit.utils.ByteFormat;

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));
	}
}

@@ -678,24 +678,52 @@
 tEquals;%0D%0A%0D%0A
+import java.util.Locale;%0D%0A%0D%0A
 import org.j
@@ -734,16 +734,16 @@
 .Test;%0D%0A
-
 %0D%0Aimport
@@ -867,16 +867,146 @@
 tion %7B%0D%0A
+%09%09// sets locale for this test%0D%0A%09%09Locale defaultLocale = Locale.getDefault();%0D%0A%0D%0A%09%09try %7B%0D%0A%09%09%09Locale.setDefault(Locale.ENGLISH);%0D%0A%09
 %09%09ByteFo
@@ -1034,24 +1034,25 @@
 eFormat();%0D%0A
+%09
 %09%09assertEqua
@@ -1077,32 +1077,33 @@
 format(10));%0D%0A%09%09
+%09
 assertEquals(%2210
@@ -1132,24 +1132,25 @@
 24 * 10));%0D%0A
+%09
 %09%09assertEqua
@@ -1186,32 +1186,33 @@
 1024 * 1000));%0D%0A
+%09
 %09%09assertEquals(%22
@@ -1248,32 +1248,33 @@
 24 * 1000));%0D%0A%09%09
+%09
 assertEquals(%221,
@@ -1323,16 +1323,17 @@
 0));%0D%0A%09%09
+%09
 assertEq
@@ -1388,15 +1388,73 @@
 000));%0D%0A
+%09%09%7D finally %7B%0D%0A%09%09%09Locale.setDefault(defaultLocale);%0D%0A%09%09%7D%0D%0A
 %09%7D%0D%0A%7D%0D%0A

Change locale to english for ByteFormatTest to run successful on systems with german locale