ChangeScreen: Show file size increase/decrease for binary files
Reviewers are interested in the size of a change that was done to a file. This is why for non-binary files the number of inserted/deleted lines is shown. So far for binary files there was no indication of how big the change was, but now the file size increase/decrease is shown. Change-Id: Ie595754af1536ce430206c2553a7656f526d7769 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// 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.google.gerrit.client;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.googlecode.gwt.test.GwtModule;
|
||||
import com.googlecode.gwt.test.GwtTest;
|
||||
|
||||
import static com.google.gerrit.client.FormatUtil.formatBytes;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
@GwtModule("com.google.gerrit.GerritGwtUI")
|
||||
@Ignore
|
||||
public class FormatUtilTest extends GwtTest {
|
||||
@Test
|
||||
public void testFormatBytes() {
|
||||
assertEquals("+/- 0 B", formatBytes(0));
|
||||
assertEquals("+27 B", formatBytes(27));
|
||||
assertEquals("+999 B", formatBytes(999));
|
||||
assertEquals("+1000 B", formatBytes(1000));
|
||||
assertEquals("+1023 B", formatBytes(1023));
|
||||
assertEquals("+1.0 KiB", formatBytes(1024));
|
||||
assertEquals("+1.7 KiB", formatBytes(1728));
|
||||
assertEquals("+108.0 KiB", formatBytes(110592));
|
||||
assertEquals("+6.8 MiB", formatBytes(7077888));
|
||||
assertEquals("+432.0 MiB", formatBytes(452984832));
|
||||
assertEquals("+27.0 GiB", formatBytes(28991029248L));
|
||||
assertEquals("+1.7 TiB", formatBytes(1855425871872L));
|
||||
assertEquals("+8.0 EiB", formatBytes(9223372036854775807L));
|
||||
|
||||
assertEquals("-27 B", formatBytes(-27));
|
||||
assertEquals("-1.7 MiB", formatBytes(-1728));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user