DexByteCodeConverter { @VisibleForTesting @NonNull static Optional<Long> parseSizeToBytes(@NonNull String sizeParameter) { long multiplier = 1; if (SdkUtils.endsWithIgnoreCase(sizeParameter, "k")) { multiplier = 1024; } else if (SdkUtils.endsWithIgnoreCase(sizeParameter, "m")) { multiplier = 1024 * 1024; } else if (SdkUtils.endsWithIgnoreCase(sizeParameter, "g")) { multiplier = 1024 * 1024 * 1024; } if (multiplier != 1) { sizeParameter = sizeParameter.substring(0, sizeParameter.length() - 1); } try { return Optional.of(multiplier * Long.parseLong(sizeParameter)); } catch (NumberFormatException e) { return Optional.empty(); } } DexByteCodeConverter(ILogger logger, TargetInfo targetInfo,
            JavaProcessExecutor javaProcessExecutor,
            boolean verboseExec); void convertByteCode(
            @NonNull Collection<File> inputs,
            @NonNull File outDexFolder,
            boolean multidex,
            @Nullable File mainDexList,
            @NonNull DexOptions dexOptions,
            boolean optimize,
            @NonNull ProcessOutputHandler processOutputHandler); void runDexer(
            @NonNull final DexProcessBuilder builder,
            @NonNull final DexOptions dexOptions,
            @NonNull final ProcessOutputHandler processOutputHandler);  }
@Test public void checkSizeParser() { assertEquals(123L, (long) DexByteCodeConverter.parseSizeToBytes("123").get()); assertEquals(2048L, (long) DexByteCodeConverter.parseSizeToBytes("2k").get()); assertEquals(2048L, (long) DexByteCodeConverter.parseSizeToBytes("2K").get()); assertEquals(1024L * 1024L * 7L, (long) DexByteCodeConverter.parseSizeToBytes("7M").get()); assertEquals(1024L * 1024L * 1024L * 17L, (long) DexByteCodeConverter.parseSizeToBytes("17g").get()); assertFalse(DexByteCodeConverter.parseSizeToBytes("foo").isPresent()); }