QuantityFormatter { public static String quantityToRSDecimalStack(int quantity) { return quantityToRSDecimalStack(quantity, false); }  static synchronized String quantityToStackSize(long quantity); static String quantityToRSDecimalStack(int quantity); static synchronized String quantityToRSDecimalStack(int quantity, boolean precise); static synchronized long parseQuantity(String string); static synchronized String formatNumber(final long number); static synchronized String formatNumber(double number);  }
@Test public void quantityToRSDecimalStackSize() { assertEquals("0", QuantityFormatter.quantityToRSDecimalStack(0)); assertEquals("8500", QuantityFormatter.quantityToRSDecimalStack(8_500)); assertEquals("10K", QuantityFormatter.quantityToRSDecimalStack(10_000)); assertEquals("21.7K", QuantityFormatter.quantityToRSDecimalStack(21_700)); assertEquals("100K", QuantityFormatter.quantityToRSDecimalStack(100_000)); assertEquals("100.3K", QuantityFormatter.quantityToRSDecimalStack(100_300)); assertEquals("1M", QuantityFormatter.quantityToRSDecimalStack(1_000_000)); assertEquals("8.4M", QuantityFormatter.quantityToRSDecimalStack(8_450_000)); assertEquals("10M", QuantityFormatter.quantityToRSDecimalStack(10_000_000)); assertEquals("12.8M", QuantityFormatter.quantityToRSDecimalStack(12_800_000)); assertEquals("100M", QuantityFormatter.quantityToRSDecimalStack(100_000_000)); assertEquals("250.1M", QuantityFormatter.quantityToRSDecimalStack(250_100_000)); assertEquals("1B", QuantityFormatter.quantityToRSDecimalStack(1_000_000_000)); assertEquals("1.5B", QuantityFormatter.quantityToRSDecimalStack(1500_000_000)); assertEquals("2.1B", QuantityFormatter.quantityToRSDecimalStack(Integer.MAX_VALUE)); }
@Test public void quantityToPreciseStackSize() { assertEquals("0", QuantityFormatter.quantityToRSDecimalStack(0)); assertEquals("8500", QuantityFormatter.quantityToRSDecimalStack(8_500, true)); assertEquals("10K", QuantityFormatter.quantityToRSDecimalStack(10_000, true)); assertEquals("21.7K", QuantityFormatter.quantityToRSDecimalStack(21_710, true)); assertEquals("100K", QuantityFormatter.quantityToRSDecimalStack(100_000, true)); assertEquals("100.3K", QuantityFormatter.quantityToRSDecimalStack(100_310, true)); assertEquals("1M", QuantityFormatter.quantityToRSDecimalStack(1_000_000, true)); assertEquals("8.45M", QuantityFormatter.quantityToRSDecimalStack(8_450_000, true)); assertEquals("8.451M", QuantityFormatter.quantityToRSDecimalStack(8_451_000, true)); assertEquals("10M", QuantityFormatter.quantityToRSDecimalStack(10_000_000, true)); assertEquals("12.8M", QuantityFormatter.quantityToRSDecimalStack(12_800_000, true)); assertEquals("12.85M", QuantityFormatter.quantityToRSDecimalStack(12_850_000, true)); assertEquals("12.851M", QuantityFormatter.quantityToRSDecimalStack(12_851_000, true)); assertEquals("100M", QuantityFormatter.quantityToRSDecimalStack(100_000_000, true)); assertEquals("250.1M", QuantityFormatter.quantityToRSDecimalStack(250_100_000, true)); assertEquals("250.151M", QuantityFormatter.quantityToRSDecimalStack(250_151_000, true)); assertEquals("1B", QuantityFormatter.quantityToRSDecimalStack(1_000_000_000, true)); assertEquals("1.5B", QuantityFormatter.quantityToRSDecimalStack(1500_000_000, true)); assertEquals("1.55B", QuantityFormatter.quantityToRSDecimalStack(1550_000_000, true)); assertEquals("2.147B", QuantityFormatter.quantityToRSDecimalStack(Integer.MAX_VALUE, true)); }