Skip to content

Commit

Permalink
updated test values
Browse files Browse the repository at this point in the history
  • Loading branch information
ennerf authored and wirew0rm committed Aug 8, 2023
1 parent b63a87e commit 15b47e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ private void applyOverlapPolicy(List<TickMark> tickMarks) {

}

@Deprecated // TODO: update tests
@Deprecated // for testing purposes
List<TickMark> computeTickMarks(AxisRange range, boolean major) {
if (major) {
updateMajorTickMarks(range);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.fair_acc.chartfx.axes.spi;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand Down Expand Up @@ -160,12 +161,12 @@ void testHelper() {

axis.setSide(Side.BOTTOM);
assertEquals(+1.0, axis.calculateNewScale(10, -5.0, +5.0));
assertEquals(+17, axis.computePrefHeight(100), 2);
assertEquals(+25, axis.computePrefHeight(100), 2);
assertEquals(+150.0, axis.computePrefWidth(-1));
axis.setSide(Side.LEFT);
assertEquals(-1.0, axis.calculateNewScale(10, -5.0, +5.0));
assertEquals(+150, axis.computePrefHeight(-1));
assertEquals(+15, axis.computePrefWidth(100), 2);
assertEquals(+22, axis.computePrefWidth(100), 2);

assertDoesNotThrow(axis::clear);
assertDoesNotThrow(axis::forceRedraw);
Expand All @@ -192,6 +193,8 @@ void testTickMarks() {
throw new IllegalStateException("majorTickMarks " + tm + " is invisible");
}
}));
assertArrayEquals(new double[]{-5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0},
majorTickMarks.stream().mapToDouble(TickMark::getValue).toArray());

final List<TickMark> minorTickMarks = axis.computeTickMarks(autoRange, false);
assertNotNull(minorTickMarks);
Expand All @@ -201,17 +204,20 @@ void testTickMarks() {
throw new IllegalStateException("minorTickMarks " + tm + " is invisible");
}
}));
assertArrayEquals(new double[]{-5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0},
majorTickMarks.stream().mapToDouble(TickMark::getValue).toArray());

axis.invertAxis(true);
majorTickMarks.clear();
majorTickMarks.addAll(axis.computeTickMarks(autoRange, true));
axis.computeTickMarks(autoRange, true);
assertEquals(10, majorTickMarks.size());
assertDoesNotThrow(() -> majorTickMarks.forEach(tm -> {
if (!tm.isVisible()) {
throw new IllegalStateException("tm " + tm + " is invisible");
}
}));
axis.getTickMarks().setAll(majorTickMarks);
assertArrayEquals(new double[]{-5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0},
majorTickMarks.stream().mapToDouble(TickMark::getValue).toArray());

}

@Test
Expand Down

0 comments on commit 15b47e7

Please sign in to comment.