2 * This file is part of storage-units. It is subject to the license terms in the LICENSE file found in the top-level
3 * directory of this distribution and at http://creativecommons.org/publicdomain/zero/1.0/. No part of storage-units,
4 * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
7 package de
.xn__ho_hia
.utils
.storage_unit
;
9 import java
.math
.BigInteger
;
11 import org
.junit
.Assert
;
12 import org
.junit
.experimental
.theories
.DataPoints
;
13 import org
.junit
.experimental
.theories
.Theories
;
14 import org
.junit
.experimental
.theories
.Theory
;
15 import org
.junit
.runner
.RunWith
;
17 import de
.xn__ho_hia
.quality
.null_analysis
.Nullsafe
;
23 @RunWith(Theories
.class)
24 public class StorageUnitsBigBinaryTest
{
26 private static final BigInteger MULTIPLIER
= NullsafeMath
.asBigInteger(1024);
32 public static Object
[][] INPUT_RESULTS
= {
33 { BigInteger
.ONE
, Kibibyte
.class },
34 { MULTIPLIER
, Kibibyte
.class },
35 { MULTIPLIER
.pow(2), Mebibyte
.class },
36 { MULTIPLIER
.pow(3), Gibibyte
.class },
37 { MULTIPLIER
.pow(4), Tebibyte
.class },
38 { MULTIPLIER
.pow(5), Pebibyte
.class },
39 { MULTIPLIER
.pow(6), Exbibyte
.class },
40 { MULTIPLIER
.pow(7), Zebibyte
.class },
41 { MULTIPLIER
.pow(8), Yobibyte
.class },
42 { MULTIPLIER
.pow(9), Yobibyte
.class },
47 * The number of bytes to wrap + the expected return class.
49 @SuppressWarnings({ "nls", "static-method", "unchecked" })
51 public void shouldCreateCorrectBinaryUnit(final Object
[] input
) {
53 final BigInteger bytes
= (BigInteger
) input
[0];
54 final Class
<?
extends StorageUnit
<?
>> expectedClass
= (Class
<?
extends StorageUnit
<?
>>) input
[1];
57 final StorageUnit
<?
> unit
= StorageUnits
.binaryValueOf(Nullsafe
.nonNull(bytes
));
61 bytes
+ " should result in " + expectedClass
.getSimpleName() + " but got "
62 + unit
.getClass().getSimpleName(),
63 expectedClass
, unit
.getClass());