mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-21 20:22:45 +02:00
[Test] Fixed DecimalFormatterTest
This commit is contained in:
parent
77b8be26f3
commit
e18e262401
|
@ -0,0 +1,48 @@
|
|||
package com.djrapitops.plan.data.store.mutators.formatting;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||
import com.djrapitops.plan.utilities.formatting.DecimalFormatter;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Test for {@link DecimalFormatter} class.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class DecimalFormatterTest {
|
||||
|
||||
private DecimalFormatter underTest;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
PlanConfig config = Mockito.mock(PlanConfig.class);
|
||||
when(config.getString(Settings.FORMAT_DECIMALS)).thenReturn("#.##");
|
||||
|
||||
underTest = new DecimalFormatter(config);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCutDecimalsWhichIsRoundedDown() {
|
||||
double d = 0.05234;
|
||||
|
||||
String result = underTest.apply(d);
|
||||
|
||||
assertTrue("0.05".equals(result) || "0,05".equals(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCutDecimalsWhichIsRoundedUp() {
|
||||
double d = 0.05634;
|
||||
|
||||
String result = underTest.apply(d);
|
||||
|
||||
assertTrue("0.06".equals(result) || "0,06".equals(result));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package com.djrapitops.plan.utilities.formatting;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test for {@link DecimalFormatter} class.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class DecimalFormatterTest {
|
||||
|
||||
@Test
|
||||
@Ignore("Config missing")
|
||||
public void testCutDecimalsWhichIsRoundedDown() {
|
||||
double d = 0.05234;
|
||||
|
||||
String result = new DecimalFormatter(null).apply(d);
|
||||
|
||||
assertTrue("0.05".equals(result) || "0,05".equals(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("Config missing")
|
||||
public void testCutDecimalsWhichIsRoundedUp() {
|
||||
double d = 0.05634;
|
||||
|
||||
String result = new DecimalFormatter(null).apply(d);
|
||||
|
||||
assertTrue("0.06".equals(result) || "0,06".equals(result));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user