Skip to content

Commit

Permalink
Force specific type of number for comparison.
Browse files Browse the repository at this point in the history
A small stability fix for canopen tests.

Signed-off-by: Łukasz Dywicki <luke@code-house.org>
  • Loading branch information
splatch committed Feb 29, 2024
1 parent 2acfa02 commit 2898716
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ protected Quantity<DataAmount> readStatistic() {
statistic.set(Quantities.getQuantity(0, Units.BYTE));
assertThat(collector.getStatistic())
.extracting(Quantity::getValue)
.isEqualTo(0.0);
.extracting(Number::intValue)
.isEqualTo(0);

// one second and one byte later we expect 8 bit/s ratio.
when(clock.get()).thenReturn(2000L);
Expand All @@ -71,4 +72,4 @@ protected Quantity<DataAmount> readStatistic() {
.extracting(Number::doubleValue)
.isEqualTo(1.0);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ protected Quantity<Dimensionless> readStatistic() {
Quantity<?> collectorStatistic = collector.getStatistic();
assertThat(collectorStatistic)
.extracting(Quantity::getValue)
.extracting(Number::doubleValue)
.isEqualTo(0.0);

when(clock.get()).thenReturn(2000L);
this.statistic.set(Quantities.getQuantity(1001, AbstractUnit.ONE));
collectorStatistic = collector.getStatistic();
assertThat(collectorStatistic)
.extracting(Quantity::getValue)
.extracting(Number::doubleValue)
.isEqualTo(1.0);
}

}
}

0 comments on commit 2898716

Please sign in to comment.