// Path: src/main/java/org/sonar/plugins/stash/StashPluginUtils.java
// public static String formatPercentage(double d) {
// 
//   // Defining that our percentage is precise down to 0.1%
//   DecimalFormat df = new DecimalFormat("0.0");
// 
//   // Protecting this method against non-US locales that would not use '.' as decimal separation
//   DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
//   decimalFormatSymbols.setDecimalSeparator('.');
//   df.setDecimalFormatSymbols(decimalFormatSymbols);
// 
//   // Making sure that we round the 0.1% properly out of the double value
//   df.setRoundingMode(RoundingMode.HALF_UP);
//   return df.format(d);
// }
// 
// Path: src/main/java/org/sonar/plugins/stash/StashPluginUtils.java
// public static boolean roundedPercentageGreaterThan(double left, double right) {
//   return (left > right) && !formatPercentage(left).equals(formatPercentage(right));
// }


import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.sonar.plugins.stash.StashPluginUtils.formatPercentage;
import static org.sonar.plugins.stash.StashPluginUtils.roundedPercentageGreaterThan;

package org.sonar.plugins.stash;




public class StashPluginUtilsTest {

  @Test
  public void testFormatPercentage() {
    assertEquals("10.9", formatPercentage(10.90));
    assertEquals("10.9", formatPercentage(10.94));
    assertEquals("11.0", formatPercentage(10.96));
    assertEquals("11.0", formatPercentage(11.0));
    assertEquals("31.3", formatPercentage(31.25));
    assertEquals("50.3", formatPercentage(50.29));
    // This test can fail with 50.2 instead of 50.3 if run with an older version of the JDK 8
    //    (failed with v25 & worked with v131)
  }

  @Test
  public void testRoundedPercentageGreaterThan() {
    assertTrue(roundedPercentageGreaterThan(0.1, 0.0));
    assertTrue(roundedPercentageGreaterThan(0.2, 0.1));
    assertTrue(roundedPercentageGreaterThan(1, 0.1));
    assertTrue(roundedPercentageGreaterThan(1.1, 0.1));

    assertFalse(roundedPercentageGreaterThan(0.0, 0.1));
    assertFalse(roundedPercentageGreaterThan(0.1, 0.2));
    assertFalse(roundedPercentageGreaterThan(1.1, 1.2));

    assertFalse(roundedPercentageGreaterThan(1.01, 1.00));
    assertFalse(roundedPercentageGreaterThan(1.04, 1.00));


// Path: src/main/java/org/sonar/plugins/stash/StashPluginUtils.java
// public static String formatPercentage(double d) {
// 
//   // Defining that our percentage is precise down to 0.1%
//   DecimalFormat df = new DecimalFormat("0.0");
// 
//   // Protecting this method against non-US locales that would not use '.' as decimal separation
//   DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
//   decimalFormatSymbols.setDecimalSeparator('.');
//   df.setDecimalFormatSymbols(decimalFormatSymbols);
// 
//   // Making sure that we round the 0.1% properly out of the double value
//   df.setRoundingMode(RoundingMode.HALF_UP);
//   return df.format(d);
// }
// 
// Path: src/main/java/org/sonar/plugins/stash/StashPluginUtils.java
// public static boolean roundedPercentageGreaterThan(double left, double right) {
//   return (left > right) && !formatPercentage(left).equals(formatPercentage(right));
// }


// Path: src/test/java/org/sonar/plugins/stash/StashPluginUtilsTest.java
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.sonar.plugins.stash.StashPluginUtils.formatPercentage;
import static org.sonar.plugins.stash.StashPluginUtils.roundedPercentageGreaterThan;

package org.sonar.plugins.stash;




public class StashPluginUtilsTest {

  @Test
  public void testFormatPercentage() {
    assertEquals("10.9", formatPercentage(10.90));
    assertEquals("10.9", formatPercentage(10.94));
    assertEquals("11.0", formatPercentage(10.96));
    assertEquals("11.0", formatPercentage(11.0));
    assertEquals("31.3", formatPercentage(31.25));
    assertEquals("50.3", formatPercentage(50.29));
    // This test can fail with 50.2 instead of 50.3 if run with an older version of the JDK 8
    //    (failed with v25 & worked with v131)
  }

  @Test
  public void testRoundedPercentageGreaterThan() {
    assertTrue(roundedPercentageGreaterThan(0.1, 0.0));
    assertTrue(roundedPercentageGreaterThan(0.2, 0.1));
    assertTrue(roundedPercentageGreaterThan(1, 0.1));
    assertTrue(roundedPercentageGreaterThan(1.1, 0.1));

    assertFalse(roundedPercentageGreaterThan(0.0, 0.1));
    assertFalse(roundedPercentageGreaterThan(0.1, 0.2));
    assertFalse(roundedPercentageGreaterThan(1.1, 1.2));

    assertFalse(roundedPercentageGreaterThan(1.01, 1.00));
    assertFalse(roundedPercentageGreaterThan(1.04, 1.00));


    assertTrue(roundedPercentageGreaterThan(1.05, 1.00));
