Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @author Emily
- * @created 13. apr. 2011
- */
- @RunWith(Parameterized.class)
- public class PricesTest {
- @Parameters
- public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][] { {1d, 1d }, {1.1, 1d }, {1.24, 1d }, {1.25, 1.5 }, {1.3, 1.5 }, {1.44, 1.5 }, {1.45, 1.5 },
- {1.49, 1.5 }, {1.5, 1.5 }, {1.6, 1.5 }, {1.7, 1.5 }, {1.75, 2d } });
- }
- private final double value, expected;
- public PricesTest(double value, double expected) {
- super();
- this.value = value;
- this.expected = expected;
- }
- @Test
- public void test() {
- Assert.assertEquals(String.format("Incorrect rounding of %.2f", value), expected, Prices.nearestHalf(value), 0d);
- }
- }
Add Comment
Please, Sign In to add comment